erkhem-gantulga commited on
Commit
d0ba603
1 Parent(s): 7af8128

Initial commit

Browse files
Files changed (3) hide show
  1. app.py +18 -0
  2. requirements.txt +2 -0
  3. spm.model +3 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fairseq.models.transformer import TransformerModel
3
+
4
+ model_directory='./'
5
+
6
+ model = TransformerModel.from_pretrained(
7
+ model_directory,
8
+ checkpoint_file='model.pt',
9
+ data_name_or_path='./bin',
10
+ bpe='sentencepiece',
11
+ sentencepiece_model='./spm.model'
12
+ )
13
+
14
+ def translate(text):
15
+ return model.translate(text)
16
+
17
+ iface = gr.Interface(fn=translate, inputs="text", outputs="text")
18
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ sentencepiece
2
+ fairseq==0.12.2
spm.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cdd2e21e1e7c92d40dd6dd2a9e2dd65ac6748018cc9d66ce2e7701b19d845886
3
+ size 881667