aiqtest1 / app.py
seawolf2357's picture
Create app.py
ec5aa0b verified
raw
history blame
853 Bytes
import gradio as gr
from transformers import pipeline
# 감정 뢄석 νŒŒμ΄ν”„λΌμΈμ„ μƒμ„±ν•©λ‹ˆλ‹€.
sentiment_pipeline = pipeline("sentiment-analysis")
def analyze_sentiment(text):
# μž…λ ₯된 ν…μŠ€νŠΈμ— λŒ€ν•œ 감정 뢄석을 μˆ˜ν–‰ν•©λ‹ˆλ‹€.
result = sentiment_pipeline(text)
# 뢄석 κ²°κ³Όλ₯Ό λ°˜ν™˜ν•©λ‹ˆλ‹€.
return result[0]
# Gradio μΈν„°νŽ˜μ΄μŠ€λ₯Ό μƒμ„±ν•©λ‹ˆλ‹€.
interface = gr.Interface(fn=analyze_sentiment,
inputs=gr.Textbox(lines=2, placeholder="Enter Text Here..."),
outputs="json",
title="Text Sentiment Analysis",
description="Enter a piece of text to analyze its sentiment. The model will classify it as positive or negative.")
# 앱을 μ‹€ν–‰ν•©λ‹ˆλ‹€.
if __name__ == "__main__":
interface.launch()