import gradio as gr from transformers import pipeline import torch # pipe = pipeline("image-to-text", # model="Salesforce/blip-image-captioning-base") pipe = pipeline(task="translation", model="facebook/nllb-200-distilled-600M", torch_dtype=torch.bfloat16) # text_translated = pipe(text, # src_lang="eng_Latn", # tgt_lang="fra_Latn") def launch(input): out = pipe(input, src_lang="eng_Latn", tgt_lang="fra_Latn") return out[0]['translation_text'] iface = gr.Interface(launch, inputs="text", outputs="text") iface.launch()