Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
classifier = pipeline("sentiment-analysis")
|
| 5 |
+
|
| 6 |
+
def classify_text(text):
|
| 7 |
+
result=classifier(text)
|
| 8 |
+
label=result[0]['label']
|
| 9 |
+
score = result[0]['score']
|
| 10 |
+
|
| 11 |
+
return f"{label} with score {score}"
|
| 12 |
+
|
| 13 |
+
interface = gr.Interface(
|
| 14 |
+
fn=classify_text,
|
| 15 |
+
inputs=gr.Textbox("Write anything(*-_-)"),
|
| 16 |
+
outputs="text",
|
| 17 |
+
title="Serntiment Analysis",
|
| 18 |
+
description="Enter Text to Check the Sentiment."
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
interface.launch(debug=True,share=True)
|