from transformers import AutoTokenizer, AutoModelForSeq2SeqLM import gradio as gr checkpoint = "suriya7/English-to-Tamil" tokenizer = AutoTokenizer.from_pretrained(checkpoint) model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint) 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, how are you today?"], ["hardwork never fail"], ["A room without books is like a body without a soul"], ] demo = gr.Interface(fn=language_translator, inputs='text',outputs='text',title='Language Translator ENGLISH TO Tamil',examples=examples) demo.launch(debug=True,share=True)