PiraiAI commited on
Commit
27eaa7a
·
verified ·
1 Parent(s): 8717ece

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2
+ import gradio as gr
3
+
4
+
5
+
6
+ def language_translator(text):
7
+ tokenized = tokenizer([text], return_tensors='pt')
8
+ out = model.generate(**tokenized, max_length=128)
9
+ return tokenizer.decode(out[0],skip_special_tokens=True)
10
+
11
+ examples = [
12
+ ["hello everyone"],
13
+ ["hardwork never fails."],
14
+ ["A room without books is like a body without a soul."],
15
+ ["The Sun is approximately 4.6 billion years older than Earth."],
16
+ ]
17
+
18
+ demo = gr.Interface(fn=language_translator, inputs='text',outputs='text',title='English to Tamil Translator',examples=examples)
19
+ demo.launch(debug=True,share=True)