Mansurbek commited on
Commit
4e07626
1 Parent(s): 36fa644

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -27
app.py CHANGED
@@ -6,33 +6,28 @@ examples = [
6
  'Shu munosabat bilan O‘zbekiston Prezidenti global inqiroz sharoitida savdo-iqtisodiy hamkorlikni <mask> va hududlararo aloqalarni rivojlantirishning muhim masalalariga to‘xtalib o‘tdi.',
7
  ]
8
 
9
- # def fn(text):
10
- # uzroberta_v1 = pipeline("fill-mask", model="sinonimayzer/UzRoBERTa-v1")
11
- # roberta_1_8_v2 = pipeline("fill-mask", model="sinonimayzer/roberta-1.8-v2")
12
- # return uzroberta_v1(text), roberta_1_8_v2(text)
13
-
14
- # with gr.Blocks() as demo:
15
- # with gr.Row():
16
- # with gr.Column():
17
- # inp = gr.Textbox(label="Input")
18
- # with gr.Column():
19
- # output1 = gr.Label(label="UzRoBERTa-v1")
20
- # output2 = gr.Label(label="roberta-1.8-v2")
21
 
22
- # btn = gr.Button("Generate")
23
- # btn.click(fn, inputs=[inp], outputs=[output1, output2])
24
- # gr.Examples(examples, inputs=[inp])
25
-
26
- # if __name__ == "__main__":
27
- # demo.queue().launch(share=True)
28
 
29
- m1 = gr.load("sinonimayzer/UzRoBERTa-v1", src="models")
30
- m2 = gr.load("sinonimayzer/roberta-1.8-v2", src="models")
31
-
32
- def combine_models(input_text):
33
- output1 = m1.predict(input_text)
34
- output2 = m2.predict(input_text)
35
- return {"Model 1 Output": output1, "Model 2 Output": output2}
 
 
 
 
36
 
37
- demo = gr.Interface(fn=combine_models, inputs="text", outputs=["label", "label"])
38
- demo.launch()
 
6
  'Shu munosabat bilan O‘zbekiston Prezidenti global inqiroz sharoitida savdo-iqtisodiy hamkorlikni <mask> va hududlararo aloqalarni rivojlantirishning muhim masalalariga to‘xtalib o‘tdi.',
7
  ]
8
 
9
+ def df(arr):
10
+ d = {}
11
+ for val in arr:
12
+ d[val['token_str']] = val['score']
13
+ return d
 
 
 
 
 
 
 
14
 
15
+ def fn(text):
16
+ uzroberta_v1 = pipeline("fill-mask", model="sinonimayzer/UzRoBERTa-v1")
17
+ roberta_1_8_v2 = pipeline("fill-mask", model="sinonimayzer/roberta-1.8-v2")
18
+ return df(uzroberta_v1(text)), df(roberta_1_8_v2(text))
 
 
19
 
20
+ with gr.Blocks() as demo:
21
+ with gr.Row():
22
+ with gr.Column():
23
+ inp = gr.Textbox(label="Input")
24
+ with gr.Column():
25
+ output1 = gr.Label(label="UzRoBERTa-v1")
26
+ output2 = gr.Label(label="roberta-1.8-v2")
27
+
28
+ btn = gr.Button("Generate")
29
+ btn.click(fn, inputs=[inp], outputs=[output1, output2])
30
+ gr.Examples(examples, inputs=[inp])
31
 
32
+ if __name__ == "__main__":
33
+ demo.queue().launch(share=True)