import torch from transformers import AutoTokenizer, AutoModelForSequenceClassification import gradio as gr # 모델과 토크나이저 로드 tokenizer = AutoTokenizer.from_pretrained("matthewburke/korean_sentiment") model = AutoModelForSequenceClassification.from_pretrained("matthewburke/korean_sentiment") # 예측 함수 정의 def predict_sentiment(text): inputs = tokenizer(text, return_tensors="pt") outputs = model(**inputs) prediction = torch.argmax(outputs.logits, dim=-1) labels = ["Negative", "Neutral", "Positive"] return labels[prediction] # Gradio 인터페이스 정의 interface = gr.Interface(fn=predict_sentiment, inputs="text", outputs="text") interface.launch()