Sentiment_Analysis / gradio.py
Beeniebeen's picture
Create gradio.py
f126cd1 verified
raw history blame
No virus
655 Bytes
import gradio as gr
from transformers import pipeline
# ๊ฐ์„ฑ ๋ถ„์„ ๋ชจ๋ธ์„ ๋ถˆ๋Ÿฌ์˜ต๋‹ˆ๋‹ค.
sentiment = pipeline('sentiment-analysis')
def get_sentiment(input_text):
# ์ž…๋ ฅ ํ…์ŠคํŠธ์˜ ๊ฐ์„ฑ์„ ๋ถ„์„ํ•ฉ๋‹ˆ๋‹ค.
result = sentiment(input_text)[0]
label = result['label']
score = result['score']
return f"๊ฐ์„ฑ: {label}, ์‹ ๋ขฐ๋„: {score}"
# Gradio UI๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
input_text = gr.inputs.Textbox(lines=7, label="ํ…์ŠคํŠธ ์ž…๋ ฅ")
output_text = gr.outputs.Textbox(label="๊ฐ์„ฑ ๋ถ„์„ ๊ฒฐ๊ณผ")
# Gradio ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
gr.Interface(get_sentiment, inputs=input_text, outputs=output_text).launch()