Spaces:
Sleeping
Sleeping
File size: 892 Bytes
65676af 5889467 12fdfea 65676af e29c405 2e9c0d1 5889467 4dd5512 5889467 4dd5512 5889467 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
import gradio as gr
checkpoint = "Hemanth-thunder/english-tamil-mt"
def language_translator(text):
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForSeq2SeqLM.from_pretrained("finetune-EN-to-Ta/")
# model = AutoModelForSeq2SeqLM.from_pretrained("finetune-EN-to-Ta/")
tokenized = tokenizer([text], return_tensors='pt')
out = model.generate(**tokenized, max_length=128)
with tokenizer.as_target_tokenizer():
return tokenizer.decode(out[0],skip_special_tokens=True)
# examples = [
# ["how are you today?"],
# ["Translate this sentence into another language."],
# ["how to play a game"],
# ]
demo = gr.Interface(fn=language_translator, inputs='text',outputs='text',title='English To Tamil Translator')#examples=examples)
demo.launch(debug=True,share=True) |