Summarization / app.py
Mr-Vicky-01's picture
Upload 2 files
a0aa016 verified
raw
history blame
822 Bytes
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
import gradio as gr
checkpoint = "Mr-Vicky-01/English-Tamil-Translator"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForSeq2SeqLM.from_pretrained("Finetuned_model/")
def language_translator(text):
tokenized = tokenizer([text], return_tensors='pt')
out = model.generate(**tokenized, max_length=128)
return tokenizer.decode(out[0],skip_special_tokens=True)
examples = [
["hello everyone"],
["hardwork never fails."],
["A room without books is like a body without a soul."],
["The Sun is approximately 4.6 billion years older than Earth."],
]
demo = gr.Interface(fn=language_translator, inputs='text',outputs='text',title='English to Tamil Translator',examples=examples)
demo.launch(debug=True,share=True)