import gradio as gr from keras.models import load_model import pickle import torch import numpy as np import pandas as pd from utils import test_sentences model = torch.load('bert_classification(0.87).pt') # Gradio 인터페이스에서 사용할 함수 정의 def predict_sentiment(text): logit = test_sentences([text], model) sent = np.argmax(logit) classes = {0: "중립", 1:"긍정", 2:"부정"} sentiment = classes[sent] return sentiment title = "🤷‍♀️🤷‍♂️What is the EMOTION of TWEET❔" description = "▶트위터 감정 알아보기" tweet = gr.Interface( fn=predict_sentiment, inputs="text", outputs="text", title=title, theme="finlaymacklon/boxy_violet", description=description ) tweet.launch(share=True)