Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
pip install gradio transformers
|
2 |
+
import gradio as gr
|
3 |
+
from transformers import pipeline
|
4 |
+
text_classifier = pipeline('sentiment-analysis')
|
5 |
+
def predict(text):
|
6 |
+
result = text_classifier(text)
|
7 |
+
return result[0]['label']
|
8 |
+
iface = gr.Interface(
|
9 |
+
fn=predict,
|
10 |
+
inputs=gr.Textbox(),
|
11 |
+
outputs=gr.Textbox()
|
12 |
+
)
|
13 |
+
iface = gr.Interface(
|
14 |
+
fn=predict,
|
15 |
+
inputs=gr.Textbox(),
|
16 |
+
outputs=gr.Textbox()
|
17 |
+
)
|
18 |
+
iface.launch()
|