pydeoxy commited on
Commit
244edee
·
verified ·
1 Parent(s): 3955266

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import torch
3
+
4
+ # Translator function
5
+ translator = pipeline(task="translation",
6
+ model="facebook/nllb-200-1.3B",
7
+ torch_dtype=torch.bfloat16)
8
+
9
+ import gradio as gr
10
+
11
+ def translate(input):
12
+ output = translator(input,
13
+ src_lang="fin_Latn",
14
+ tgt_lang="eng_Latn")
15
+ return output[0]['translation_text']
16
+
17
+ gr.close_all()
18
+ demo = gr.Interface(fn=translate,
19
+ inputs=[gr.Textbox(label="Text to translate", lines=6)],
20
+ outputs=[gr.Textbox(label="Result", lines=3)],
21
+ title="Text translation with nllb-200-1.3B",
22
+ description="Translate Finnish text using the `facebook/nllb-200-1.3B` model under the hood!"
23
+ )
24
+ demo.launch()