Spaces:
Sleeping
Sleeping
File size: 903 Bytes
5889467 936fb74 5889467 68ec033 5889467 ae4603d 9fec5d1 ae4603d 5889467 ae4603d 5889467 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
from transformers import AutoTokenizer, TFAutoModelForSeq2SeqLM
import tensorflow as tf
import gradio as gr
checkpoint = "Hemanth-thunder/english-tamil-mt"
def language_translator(text):
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = TFAutoModelForSeq2SeqLM.from_pretrained("finetune-EN-to-Ta/")
# model = TFAutoModelForSeq2SeqLM.from_pretrained("checkpoint")
tokenized = tokenizer([text], return_tensors='np')
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) |