Spaces:
Runtime error
Runtime error
File size: 884 Bytes
b8f6eea |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
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()
|