Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# 'sentiment-analysis' νμ΄νλΌμΈ μ΄κΈ°ν
|
5 |
+
sentiment = pipeline('sentiment-analysis')
|
6 |
+
|
7 |
+
# κ°μ± λΆμμ μννλ ν¨μ μ μ
|
8 |
+
def get_sentiment(text):
|
9 |
+
result = sentiment(text)
|
10 |
+
return result[0]
|
11 |
+
|
12 |
+
# Gradio μΈν°νμ΄μ€ μ μ
|
13 |
+
interface = gr.Interface(fn=get_sentiment,
|
14 |
+
inputs=gr.inputs.Textbox(lines=2, placeholder="Type your text here..."),
|
15 |
+
outputs='json',
|
16 |
+
title="Sentiment Analysis",
|
17 |
+
description="Enter text to analyze sentiment.")
|
18 |
+
|
19 |
+
# Gradio μ± μ€ν
|
20 |
+
if __name__ == "__main__":
|
21 |
+
interface.launch()
|