mytest1 / app.py
blockenters's picture
add
e910ec9
raw
history blame contribute delete
731 Bytes
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()