Spaces:
Sleeping
Sleeping
Commit
·
bc98f3f
1
Parent(s):
4d447cf
add files
Browse files- requirements.txt +3 -0
- sentiment.py +18 -0
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
transformers
|
| 3 |
+
torch
|
sentiment.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
sentiment = pipeline("sentiment-analysis")
|
| 3 |
+
|
| 4 |
+
import gradio as gr
|
| 5 |
+
|
| 6 |
+
def analyze(text):
|
| 7 |
+
return sentiment(text)[0]['label']
|
| 8 |
+
|
| 9 |
+
demo = gr.Interface(
|
| 10 |
+
fn=analyze,
|
| 11 |
+
inputs="text",
|
| 12 |
+
outputs="label",
|
| 13 |
+
title="Sentiment Analysis",
|
| 14 |
+
description="Enter text to analyze its sentiment (positive/negative)"
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
if __name__ == "__main__":
|
| 18 |
+
demo.launch()
|