Spaces:
Paused
Paused
File size: 863 Bytes
8fe0112 |
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 27 28 29 30 31 32 33 34 |
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=gr.inputs.Textbox(placeholder="Enter tweet here..."),
outputs=gr.outputs.Textbox(label="Sentiment Prediction"),
title=title,
theme="finlaymacklon/boxy_violet",
description=description
)
tweet.launch(share=True)
|