Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline | |
# Loading translation model | |
translation_tokenizer = AutoTokenizer.from_pretrained("ieuniversity/sciencebrief_translation") | |
translation_model = AutoModelForSeq2SeqLM.from_pretrained("ieuniversity/sciencebrief_translation") | |
translator = pipeline("translation_en_to_fr", tokenizer=translation_tokenizer, model=translation_model) | |
def translate(text): | |
return translator(text)[0]['translation_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 into French using the ScienceBrief translation model.", | |
theme="compact" | |
) | |
iface_translate.launch() | |