Mariamabed commited on
Commit
2473cb3
·
verified ·
1 Parent(s): d091951

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+
4
+ # Initialize zero-shot-classification pipeline
5
+ zero_shot_classifier = pipeline("zero-shot-classification")
6
+
7
+ # Define classification function
8
+ def classify(text, labels):
9
+ classifier_labels = labels.split(",") # Split the comma-separated labels into a list
10
+ response = zero_shot_classifier(text, classifier_labels) # Perform the classification
11
+ return response
12
+
13
+ # Define Gradio interface elements
14
+ txt = gr.Textbox(lines=1, label="English", placeholder="Text to be classified")
15
+ labels = gr.Textbox(lines=1, label="Labels", placeholder="Comma-separated labels")
16
+ out = gr.Textbox(lines=1, label="Classification")
17
+
18
+ # Create the interface and launch it
19
+ gr.Interface(classify, inputs=[txt,