yuvanelson commited on
Commit
6c3906f
·
verified ·
1 Parent(s): 9f84559

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +20 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
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)
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio
2
+ transformers
3
+ torch
4
+ sentencepiece