File size: 625 Bytes
e0ca228
50ca8c0
 
506611c
 
50ca8c0
 
7fc3a05
506611c
 
50ca8c0
506611c
 
 
 
 
 
c248b5f
506611c
10d2573
50ca8c0
 
5bd1dfc
 
 
50ca8c0
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import gradio as gr
import json

from transformers import pipeline
classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")

def tagging(
    text_input: str,
    tags: str,
    multi_label: bool
):
  try:
      candidate_labels = json.loads(tags)
      
  except error:
     raise gr.Error(f"Error {error}")

  output = classifier(text_input, candidate_labels, multi_label=True)
    
  return output
    
app = gr.Interface(fn=tagging, inputs=[
    gr.Textbox(label="Input here"),
    gr.Textbox(label="Mags here"),
    gr.Checkbox(label="Multi_label", value=True)
], outputs="text")

app.launch()