suriya7 commited on
Commit
e60a37f
·
verified ·
1 Parent(s): b206aac

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
+
4
+ checkpoint = "suriya7/English-to-Tamil"
5
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
6
+ model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint)
7
+
8
+ def language_translator(text):
9
+ tokenized = tokenizer([text], return_tensors='pt')
10
+ out = model.generate(**tokenized, max_length=128)
11
+ return tokenizer.decode(out[0],skip_special_tokens=True)
12
+
13
+ examples = [
14
+ ["Hello, how are you today?"],
15
+ ["hardwork never fail"],
16
+ ["A room without books is like a body without a soul"],
17
+ ]
18
+
19
+ demo = gr.Interface(fn=language_translator, inputs='text',outputs='text',title='Language Translator ENGLISH TO Tamil',examples=examples)
20
+ demo.launch(debug=True,share=True)