Spaces:
Runtime error
Runtime error
File size: 604 Bytes
a13e82b c3ec281 a13e82b 204c76a 6048a31 699ee97 6048a31 44f9786 6048a31 cfba493 6048a31 6254ce6 6048a31 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import gradio as gr
import os
os.system("pip install transformers sentencepiece torch")
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("alirezamsh/small100")
model = AutoModelForSeq2SeqLM.from_pretrained("alirezamsh/small100")
def fn(text, lang):
tokenizer.tgt_lang = lang
encoded_zh = tokenizer(text, return_tensors="pt")
generated_tokens = model.generate(**encoded_zh)
return tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)
demo = gr.Interface(fn=fn, inputs=["text", "text"], outputs="text")
demo.launch() |