File size: 750 Bytes
fc23c9a
e60a37f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cd711b2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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)