you_might_speak / app.py
Deepak Sahu
training; app
2c1ff7f
raw
history blame contribute delete
2.6 kB
GRADIO_TITLE = "Langues Guesser based on Name"
GRADIO_DESCRIPTION = '''
This is a self-learning project which replicates the [pytorch tutorial](https://pytorch.org/tutorials/intermediate/char_rnn_classification_tutorial.html) with modifications.
Kindly see [my GitHub: you may speak](https://github.com/LunaticMaestro/-NLP-_you_may_speak) readme to checkout the modifications.
Model Trained for names on following languages: ['Korean ๐Ÿ‡ฐ๐Ÿ‡ท', 'Portuguese ๐Ÿ‡ต๐Ÿ‡น', 'Dutch ๐Ÿ‡ณ๐Ÿ‡ฑ', 'Italian ๐Ÿ‡ฎ๐Ÿ‡น', 'German ๐Ÿ‡ฉ๐Ÿ‡ช', 'Scottish ๐Ÿด\U000e0067\U000e0062\U000e0073\U000e0063\U000e0074\U000e007f', 'Vietnamese ๐Ÿ‡ป๐Ÿ‡ณ', 'French ๐Ÿ‡ซ๐Ÿ‡ท', 'English ๐Ÿ‡ฌ๐Ÿ‡ง', 'Arabic ๐Ÿ‡ฒ๐Ÿ‡ฆ', 'Irish ๐Ÿ‡ฎ๐Ÿ‡ช', 'Chinese ๐Ÿ‡จ๐Ÿ‡ณ', 'Japanese ๐Ÿ‡ฏ๐Ÿ‡ต', 'Russian ๐Ÿ‡ท๐Ÿ‡บ', 'Polish ๐Ÿ‡ต๐Ÿ‡ฑ', 'Czech ๐Ÿ‡จ๐Ÿ‡ฟ', 'Spanish ๐Ÿ‡ช๐Ÿ‡ธ', 'Greek ๐Ÿ‡ฌ๐Ÿ‡ท']
'''
import gradio as gr
from z_modelops import NameToLanguages
from z_inference import setup_inference, infer_lang
model, labels = setup_inference()
def get_langauge(name):
langugages = infer_lang(name, model, labels)
language_flags = {
"Korean": "\U0001F1F0\U0001F1F7", # South Korea
"Portuguese": "\U0001F1F5\U0001F1F9", # Portugal
"Dutch": "\U0001F1F3\U0001F1F1", # Netherlands
"Italian": "\U0001F1EE\U0001F1F9", # Italy
"German": "\U0001F1E9\U0001F1EA", # Germany
"Scottish": "\U0001F3F4\U000E0067\U000E0062\U000E0073\U000E0063\U000E0074\U000E007F", # Scotland (flag sequence)
"Vietnamese": "\U0001F1FB\U0001F1F3", # Vietnam
"French": "\U0001F1EB\U0001F1F7", # France
"English": "\U0001F1EC\U0001F1E7", # England (flag sequence)
"Arabic": "\U0001F1F2\U0001F1E6", # UAE (commonly associated with Arabic)
"Irish": "\U0001F1EE\U0001F1EA", # Ireland
"Chinese": "\U0001F1E8\U0001F1F3", # China
"Japanese": "\U0001F1EF\U0001F1F5", # Japan
"Russian": "\U0001F1F7\U0001F1FA", # Russia
"Polish": "\U0001F1F5\U0001F1F1", # Poland
"Czech": "\U0001F1E8\U0001F1FF", # Czech Republic
"Spanish": "\U0001F1EA\U0001F1F8", # Spain
"Greek": "\U0001F1EC\U0001F1F7" # Greece
}
return '\n'.join([lang + " " + language_flags[lang] for lang in langugages])
input_textbox = gr.Textbox(label="Your Name", placeholder="Naifeh", max_lines=1)
demo = gr.Interface(
fn=get_langauge,
inputs=input_textbox ,
outputs=gr.Label(label="You may speak"),
title=GRADIO_TITLE,
description=GRADIO_DESCRIPTION
)
demo.launch(debug=True)