piyush2205 commited on
Commit
33da398
·
verified ·
1 Parent(s): f026e4d

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +18 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+
4
+ # Load zero-shot classification pipeline
5
+ classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
6
+
7
+ # Define possible topics
8
+ candidate_labels = ["politics", "sports", "technology", "education", "health", "entertainment", "climate change", "economy", "science", "travel"]
9
+
10
+ def classify_topic(text):
11
+ result = classifier(text, candidate_labels)
12
+ top_label = result['labels'][0]
13
+ score = round(result['scores'][0], 2)
14
+ return f"🏷️ Topic: {top_label} (Confidence: {score})"
15
+
16
+ # Gradio UI
17
+ iface = gr.Interface(fn=classify_topic, inputs="text", outputs="text", title="Intent / Topic Classifier")
18
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ transformers
2
+ torch
3
+ gradio