frankrobotics commited on
Commit
506611c
·
verified ·
1 Parent(s): e0ca228

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -7
app.py CHANGED
@@ -1,19 +1,28 @@
1
  import gradio as gr
2
  import json
3
 
4
- # from transformers import pipeline
5
- # classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
6
 
7
  def tagging(
8
- input: str,
9
- tags: tuple[str]
 
10
  ):
11
- text = json.loads(str)
 
 
 
 
 
 
 
12
  return text
13
 
14
  app = gr.Interface(fn=tagging, inputs=[
15
- gr.Textbox(label="Your input here"),
16
- gr.Textbox(label="Your input here")
 
17
  ], outputs="text")
18
 
19
  app.launch()
 
1
  import gradio as gr
2
  import json
3
 
4
+ from transformers import pipeline
5
+ classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
6
 
7
  def tagging(
8
+ input: str,
9
+ tags: str,
10
+ multi_label: bool
11
  ):
12
+ try:
13
+ candidate_labels = json.loads(tags)
14
+
15
+ except error:
16
+ raise gr.Error(f"Error {error}")
17
+
18
+ classifier(input, candidate_labels, multi_label)
19
+
20
  return text
21
 
22
  app = gr.Interface(fn=tagging, inputs=[
23
+ gr.Textbox(label="Your input here"),
24
+ gr.Textbox(label="Your input here"),
25
+ gr.Checkbox(label="multi_label", value=True)
26
  ], outputs="text")
27
 
28
  app.launch()