Mr-Vicky-01 commited on
Commit
5889467
1 Parent(s): 69c193f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoTokenizer, TFAutoModelForSeq2SeqLM
2
+ import gradio as gr
3
+ checkpoint = "Hemanth-thunder/english-tamil-mt"
4
+
5
+ def language_translator(text):
6
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
7
+ model = TFAutoModelForSeq2SeqLM.from_pretrained("finetune-EN-to-Ta/")
8
+ tokenized = tokenizer([text], return_tensors='np')
9
+ out = model.generate(**tokenized, max_length=128)
10
+ with tokenizer.as_target_tokenizer():
11
+ return tokenizer.decode(out[0],skip_special_tokens=True)
12
+
13
+ # examples = [
14
+ # ["Hello, how are you today?"],
15
+ # ["Translate this sentence into another language."],
16
+ # ["Can you help me with this text?"],
17
+ # ]
18
+
19
+ demo = gr.Interface(fn=language_translator, inputs='text',outputs='text',title='Language Translator ENGLISH TO FRENCH',examples=examples)
20
+ demo.launch(debug=True,share=True)