Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
classifier = pipeline('text-classification', model="abhi227070/distilbert-base-uncased-finetuned-imdb")
|
5 |
+
|
6 |
+
def sentiment_analysis(text):
|
7 |
+
|
8 |
+
result = classifier(text)
|
9 |
+
|
10 |
+
return result[0]['label'], result[0]['score']
|
11 |
+
|
12 |
+
|
13 |
+
iface = gr.Interface(
|
14 |
+
fn = sentiment_analysis,
|
15 |
+
inputs = gr.Textbox(label="Context", placeholder="Enter your text here...", lines = 5),
|
16 |
+
outputs = [gr.Textbox(label="Result"), gr.Textbox(label="Accuracy")]
|
17 |
+
)
|
18 |
+
|
19 |
+
iface.launch()
|