Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files- app.py +21 -0
- requirements.txt +4 -0
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
checkpoint = "Mr-Vicky-01/English-Tamil-Translator"
|
| 5 |
+
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
| 6 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("Finetuned_model/")
|
| 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 everyone"],
|
| 15 |
+
["hardwork never fails."],
|
| 16 |
+
["A room without books is like a body without a soul."],
|
| 17 |
+
["The Sun is approximately 4.6 billion years older than Earth."],
|
| 18 |
+
]
|
| 19 |
+
|
| 20 |
+
demo = gr.Interface(fn=language_translator, inputs='text',outputs='text',title='English to Tamil Translator',examples=examples)
|
| 21 |
+
demo.launch(debug=True,share=True)
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
transformers
|
| 2 |
+
gradio
|
| 3 |
+
torch
|
| 4 |
+
sentencepiece
|