kurianbenoy commited on
Commit
876cd0e
1 Parent(s): c86b4ff

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from blurr.data.all import *
2
+ from blurr.modeling.all import *
3
+ from huggingface_hub import hf_hub_download
4
+ from fastai.learner import load_learner
5
+ from transformers import *
6
+
7
+ pretrained_model_name = "Helsinki-NLP/opus-mt-en-ml"
8
+ model_cls = AutoModelForSeq2SeqLM
9
+ hf_arch, hf_config, hf_tokenizer, hf_model = BLURR.get_hf_objects(pretrained_model_name, model_cls=model_cls)
10
+
11
+ model = load_learner(
12
+ hf_hub_download("kurianbenoy/kde_en_ml_translation_model", "saved_model.pkl")
13
+ )
14
+
15
+ def translate_text(text):
16
+ outputs = model.blurr_translate(text)
17
+ return outputs[0]["translation_texts"]
18
+
19
+
20
+ iface = gr.Interface(
21
+ fn=translate_text,
22
+ inputs=gr.inputs.Textbox(lines=2, label="Enter Text in English", placeholder="Type text in English Here..."),
23
+ outputs="text",
24
+ theme="huggingface",
25
+ )
26
+
27
+ iface.launch()