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 text from English to Spanish using the ScienceBrief translation model.", theme="compact" ) iface_translate.launch()