abdulsamad commited on
Commit
eaf7fab
·
verified ·
1 Parent(s): 71dda07

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import torch
3
+
4
+
5
+ translator = pipeline(task="translation",
6
+ model="./models/facebook/nllb-200-distilled-600M",
7
+ torch_dtype=torch.bfloat16)
8
+
9
+ text = """\
10
+ My puppy is adorable, \
11
+ Your kitten is cute.
12
+ Her panda is friendly.
13
+ His llama is thoughtful. \
14
+ We all have nice pets!"""
15
+
16
+
17
+ text_translated = translator(text,
18
+ src_lang="eng_Latn",
19
+ tgt_lang="fra_Latn")
20
+
21
+ text_translated