Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
sentiment_pipeline = pipeline("sentiment-analysis")
|
| 4 |
+
def get_sentiment(input_text):
|
| 5 |
+
result = sentiment_pipeline(input_text)
|
| 6 |
+
return result[0]['label']
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
#launch web UI
|
| 10 |
+
iface = gr.Interface(
|
| 11 |
+
fn = get_sentiment,
|
| 12 |
+
inputs = 'text',
|
| 13 |
+
output = 'text',
|
| 14 |
+
title = 'my first AI app'
|
| 15 |
+
description =""
|
| 16 |
+
|
| 17 |
+
)
|
| 18 |
+
iface.launch
|