Spaces:
Build error
Build error
| import gradio as gr | |
| from transformers import pipeline | |
| # 1. ์ฌ์ ํ์ต๋ ๊ฐ์ ๋ถ์ ํ์ดํ๋ผ์ธ ๋ก๋ | |
| sentiment_pipeline = pipeline("sentiment-analysis") | |
| # 2. ์์ธก ํจ์ ์ ์ | |
| def analyze_sentiment(text): | |
| results = sentiment_pipeline(text) | |
| return results | |
| # 3. Gradio UI ๊ตฌ์ฑ | |
| # - inputs: ํ ์คํธ ์ ๋ ฅ | |
| # - outputs: ๊ฒฐ๊ณผ(JSON ํ์ ํ์) | |
| demo = gr.Interface( | |
| fn=analyze_sentiment, | |
| inputs=gr.Textbox(lines=3, placeholder="ํ ์คํธ๋ฅผ ์ ๋ ฅํ์ธ์"), | |
| outputs="json", | |
| title="๊ฐ์ ๋ถ์ ๋ฐ๋ชจ", | |
| description="Hugging Face Transformers์ ํ์ดํ๋ผ์ธ์ ์ฌ์ฉํด ๊ฐ์ (๊ธ์ /๋ถ์ )์ ์์ธกํฉ๋๋ค." | |
| ) | |
| # 4. ์คํ | |
| if __name__ == "__main__": | |
| demo.launch() |