Group03 commited on
Commit
f0cd791
·
verified ·
1 Parent(s): 5bcb496

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +12 -0
  2. app.py +22 -0
  3. requirements.txt +3 -0
README.md ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: G3 Tweet Classifier
3
+ emoji: 🔥
4
+ colorFrom: pink
5
+ colorTo: gray
6
+ sdk: gradio
7
+ sdk_version: 5.28.0
8
+ app_file: app.py
9
+ pinned: false
10
+ ---
11
+
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+ # Load a tweet classification model from Hugging Face
4
+ classifier = pipeline("text-classification", model="finiteautomata/bertweet-base-sentiment-analysis")
5
+
6
+ def classify_tweet(tweet):
7
+ result = classifier(tweet)[0]
8
+ label = result['label']
9
+ score = result['score']
10
+ return f"Label: {label} (Confidence: {score:.2f})"
11
+
12
+ # Create the Gradio interface
13
+ iface = gr.Interface(
14
+ fn=classify_tweet,
15
+ inputs=gr.Textbox(lines=3, placeholder="Enter a tweet here..."),
16
+ outputs="text",
17
+ title="Tweet Classifier",
18
+ description="Enter a tweet and click the button to classify it!"
19
+ )
20
+
21
+ # Launch the app
22
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ transformers
2
+ torch
3
+ gradio