File size: 725 Bytes
7e0f920
 
81087c7
7e0f920
 
 
 
 
3fbca17
7e0f920
 
3fbca17
 
 
7e0f920
 
3fbca17
 
4c5a726
7e0f920
 
b41142e
7e0f920
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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()