import gradio as gr from transformers import pipeline # 'sentiment-analysis' 파이프라인 초기화 sentiment = pipeline('sentiment-analysis') # 감성 분석을 수행하는 함수 정의 def get_sentiment(text): result = sentiment(text) return result[0] # Gradio 인터페이스 정의 interface = gr.Interface(fn=get_sentiment, inputs=gr.inputs.Textbox(lines=2, placeholder="Type your text here..."), outputs='json', title="Sentiment Analysis", description="Enter text to analyze sentiment.") # Gradio 앱 실행 if __name__ == "__main__": interface.launch()