qgyd2021 commited on
Commit
f577279
1 Parent(s): 3582725
Files changed (1) hide show
  1. main.py +41 -0
main.py CHANGED
@@ -13,6 +13,19 @@ def get_args():
13
  return args
14
 
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  def main():
17
  args = get_args()
18
 
@@ -26,6 +39,34 @@ def main():
26
  with gr.Blocks() as blocks:
27
  gr.Markdown(value=brief_description)
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  blocks.queue().launch(
30
  share=False if platform.system() == "Windows" else False
31
  )
 
13
  return args
14
 
15
 
16
+ model_names = {
17
+ "allennlp_text_classification": {
18
+ "qgyd2021/language_identification": "https://huggingface.co/qgyd2021/language_identification"
19
+ }
20
+ }
21
+
22
+
23
+ def click_button_allennlp_text_classification(text: str, model_name: str):
24
+ print(text)
25
+ print(model_name)
26
+ return "label", 0.0
27
+
28
+
29
  def main():
30
  args = get_args()
31
 
 
39
  with gr.Blocks() as blocks:
40
  gr.Markdown(value=brief_description)
41
 
42
+ with gr.Tabs():
43
+ with gr.TabItem("AllenNLP Text Classification"):
44
+ with gr.Row():
45
+ with gr.Column(scale=3):
46
+ text = gr.Text(label="text")
47
+ ground_true = gr.Text(label="ground_true")
48
+ model_name = gr.Dropdown(
49
+ choices=list(model_names["allennlp_text_classification"].keys())
50
+ )
51
+ button = gr.Button("infer", variant="primary")
52
+
53
+ with gr.Column(scale=3):
54
+ label = gr.Text(label="label")
55
+ prob = gr.Text(label="prob")
56
+
57
+ gr.Examples(
58
+ examples=[
59
+ ["你好", "zh", "qgyd2021/language_identification"]
60
+ ],
61
+ inputs=[text, ground_true, model_name],
62
+ outputs=[label, prob],
63
+ )
64
+ button.click(
65
+ click_button_allennlp_text_classification,
66
+ inputs=[text, model_name],
67
+ outputs=[label, prob]
68
+ )
69
+
70
  blocks.queue().launch(
71
  share=False if platform.system() == "Windows" else False
72
  )