pm commited on
Commit
93019e3
1 Parent(s): 2788dae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -3
app.py CHANGED
@@ -1,7 +1,20 @@
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  demo.launch()
 
1
  import gradio as gr
2
 
 
 
3
 
4
+ classifier = pipeline(task="zero-shot-classification", model = "MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli")
5
+
6
+ def classify(text):
7
+ candidate_labels = ["positive", "negative", "neutral"]
8
+ output = classifier(text, candidate_labels)
9
+ # Process the output to match Gradio's expected input format for gr.Label
10
+ labels = output['labels']
11
+ scores = output['scores']
12
+ # Construct a simple string representation of top classifications
13
+ top_classes = ', '.join([f"{labels[i]}: {scores[i]:.2f}" for i in range(len(labels))])
14
+ return top_classes
15
+
16
+ demo = gr.Interface(fn=classify,
17
+ inputs=gr.Textbox(label="Enter something"),
18
+ outputs=gr.Label())
19
+
20
  demo.launch()