Spaces:
Sleeping
Sleeping
File size: 824 Bytes
27eaa7a 54f79c9 27eaa7a 3bdaa6b 27eaa7a |
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
tokenizer = AutoTokenizer.from_pretrained("PiraiAI/fine-tuned-bahasa-melayu-2L")
model = AutoModelForSeq2SeqLM.from_pretrained("PiraiAI/fine-tuned-bahasa-melayu-2L")
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 Bahasa Melayu Translator',examples=examples)
demo.launch(debug=True,share=True) |