import spaces from transformers import AutoModelForSeq2SeqLM,AutoTokenizer, pipeline import gradio as grad mdl_name = "NAMAA-Space/masrawy-english-to-egyptian-arabic-translator-v2.9" # mdl = AutoModelForSeq2SeqLM.from_pretrained(mdl_name) # my_tkn = AutoTokenizer.from_pretrained(mdl_name) pipe = pipeline("translation", model=mdl_name, device = 'cuda') @spaces.GPU def translate(text): # inputs = my_tkn(text, return_tensors="pt") # trans_output = mdl.generate(**inputs) response = pipe(text)[0]['translation_text'] #response = opus_translator(text) return response input_textbox = grad.Textbox(lines=5, placeholder="Enter text to translate", label="Input Text") output_textbox = grad.Textbox(lines=5, label="Egyption Arabic Translation") grad.Interface(translate, inputs=[input_textbox], outputs=output_textbox).launch()