Spaces:
Runtime error
Runtime error
Download app.py from suinY00N/SentimentAnalysis: direct link, hf CLI and curl.
- Browser
- Download file 884 Bytes
-
https://huggingface.co/spaces/suinY00N/SentimentAnalysis/resolve/main/app.py
- Command line
-
hf download hf://spaces/suinY00N/SentimentAnalysis/app.py
-
curl -L -o app.py https://huggingface.co/spaces/suinY00N/SentimentAnalysis/resolve/main/app.py
884 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # ๊ฐ์ฑ ๋ถ์ ํ์ดํ๋ผ์ธ ์ด๊ธฐํ | |
| sentiment = pipeline("sentiment-analysis") | |
| # ์ฌ์ฉ์ ์ ๋ ฅ์ ๋ํ ๊ฐ์ฑ ๋ถ์ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ ํจ์ | |
| def get_sentiment(์ ๋ ฅ): | |
| # ๊ฐ์ฑ ๋ถ์ ์คํ | |
| result = sentiment(์ ๋ ฅ) | |
| # ๊ฒฐ๊ณผ ํฌ๋งทํ ๋ฐ ๋ฐํ | |
| return result[0] | |
| # Gradio ์ฑ ์ธํฐํ์ด์ค ๊ตฌ์ฑ | |
| iface = gr.Interface( | |
| fn=get_sentiment, # ์คํํ ํจ์ | |
| inputs=gr.inputs.Textbox(lines=2, placeholder="์ฌ๊ธฐ์ ํ ์คํธ๋ฅผ ์ ๋ ฅํ์ธ์..."), # ์ ๋ ฅ๋ ์ค์ | |
| outputs="json", # ์ถ๋ ฅ ํํ | |
| clear_on_submit=True, # ์ ์ถ ํ ์ ๋ ฅ๋ ํด๋ฆฌ์ด | |
| title="ํ ์คํธ ๊ฐ์ฑ ๋ถ์", # UI ์ ๋ชฉ | |
| description="ํ ์คํธ๋ฅผ ์ ๋ ฅํ๊ณ ์ ์ถ ๋ฒํผ์ ํด๋ฆญํ์ฌ ๊ฐ์ฑ ๋ถ์ ๊ฒฐ๊ณผ๋ฅผ ํ์ธํ์ธ์." # UI ์ค๋ช | |
| ) | |
| # Gradio ์ฑ ์คํ | |
| iface.launch() | |