File size: 826 Bytes
890f040 c6f5946 890f040 657dbb4 890f040 c6f5946 890f040 0f3cc9c 890f040 c6f5946 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import gradio as gr
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("ieuniversity/sciencebrief_translation")
model = AutoModelForSeq2SeqLM.from_pretrained("ieuniversity/sciencebrief_translation")
def translate(text):
input_ids = tokenizer.encode(text, return_tensors="pt")
output_ids = model.generate(input_ids)
output_text = tokenizer.decode(output_ids[0], skip_special_tokens=True)
return output_text
iface_translate = gr.Interface(
fn=translate,
inputs=gr.inputs.Textbox(lines=10, label="Input Text"),
outputs=gr.outputs.Textbox(label="Translation"),
title="ScienceBrief Translation",
description="Translate your English text to Spanish using the ScienceBrief translation model",
theme="compact"
)
iface_translate.launch()
|