Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# κ°μ λΆμ νμ΄νλΌμΈμ μμ±ν©λλ€.
|
5 |
+
sentiment_pipeline = pipeline("sentiment-analysis")
|
6 |
+
|
7 |
+
def analyze_sentiment(text):
|
8 |
+
# μ
λ ₯λ ν
μ€νΈμ λν κ°μ λΆμμ μνν©λλ€.
|
9 |
+
result = sentiment_pipeline(text)
|
10 |
+
# λΆμ κ²°κ³Όλ₯Ό λ°νν©λλ€.
|
11 |
+
return result[0]
|
12 |
+
|
13 |
+
# Gradio μΈν°νμ΄μ€λ₯Ό μμ±ν©λλ€.
|
14 |
+
interface = gr.Interface(fn=analyze_sentiment,
|
15 |
+
inputs=gr.Textbox(lines=2, placeholder="Enter Text Here..."),
|
16 |
+
outputs="json",
|
17 |
+
title="Text Sentiment Analysis",
|
18 |
+
description="Enter a piece of text to analyze its sentiment. The model will classify it as positive or negative.")
|
19 |
+
|
20 |
+
# μ±μ μ€νν©λλ€.
|
21 |
+
if __name__ == "__main__":
|
22 |
+
interface.launch()
|