seanbenhur commited on
Commit
2705a3e
1 Parent(s): 929ad7e
Files changed (2) hide show
  1. app.py.txt +34 -0
  2. tamilatis +1 -0
app.py.txt ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from tamilatis.predict import TamilATISPredictor
2
+ from tamilatis.model import JointATISModel
3
+ import numpy as np
4
+ from sklearn.preprocessing import LabelEncoder
5
+ import gradio as gr
6
+
7
+
8
+
9
+ model_name = "microsoft/xlm-align-base"
10
+ tokenizer_name = "microsoft/xlm-align-base"
11
+ num_labels = 78
12
+ num_intents = 23
13
+ checkpoint_path = "/content/tamil_atis/xlm_align_base.bin"
14
+ intent_encoder_path = "/content/tamil_atis/intent_annotations.npy"
15
+ ner_encoder_path = "/content/tamil_atis/ner_annotations.npy"
16
+
17
+ def predict_function(text):
18
+ label_encoder = LabelEncoder()
19
+ label_encoder.classes_ = np.load(ner_encoder_path)
20
+
21
+ intent_encoder = LabelEncoder()
22
+ intent_encoder.classes_ = np.load(intent_encoder_path)
23
+
24
+ model = JointATISModel(model_name,num_labels,num_intents)
25
+ predictor = TamilATISPredictor(model,checkpoint_path,tokenizer_name,
26
+ label_encoder,intent_encoder,num_labels)
27
+ slot_prediction, intent_preds = predictor.get_predictions(text)
28
+ return slot_prediction, intent_preds
29
+
30
+
31
+ title = "Tamil ATIS"
32
+ iface = gr.Interface(fn=predict_function, inputs="text", title=title,theme="huggingface",outputs=["text","text"])
33
+ iface.launch(share=True)
34
+
tamilatis ADDED
@@ -0,0 +1 @@
 
 
1
+ Subproject commit b1022a9187d9d47c18b360fc45b7f55d3b40824f