Spaces:
Paused
Paused
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from keras.models import load_model
|
3 |
+
import pickle
|
4 |
+
import torch
|
5 |
+
import numpy as np
|
6 |
+
import pandas as pd
|
7 |
+
from utils import test_sentences
|
8 |
+
|
9 |
+
model = torch.load('bert_classification(0.87).pt')
|
10 |
+
|
11 |
+
# Gradio ์ธํฐํ์ด์ค์์ ์ฌ์ฉํ ํจ์ ์ ์
|
12 |
+
def predict_sentiment(text):
|
13 |
+
logit = test_sentences([text], model)
|
14 |
+
sent = np.argmax(logit)
|
15 |
+
|
16 |
+
classes = {0: "์ค๋ฆฝ", 1:"๊ธ์ ", 2:"๋ถ์ "}
|
17 |
+
sentiment = classes[sent]
|
18 |
+
|
19 |
+
return sentiment
|
20 |
+
|
21 |
+
title = "๐คทโโ๏ธ๐คทโโ๏ธWhat is the EMOTION of TWEETโ"
|
22 |
+
description = "โถํธ์ํฐ ๊ฐ์ ์์๋ณด๊ธฐ"
|
23 |
+
|
24 |
+
|
25 |
+
tweet = gr.Interface(
|
26 |
+
fn=predict_sentiment,
|
27 |
+
inputs=gr.inputs.Textbox(placeholder="Enter tweet here..."),
|
28 |
+
outputs=gr.outputs.Textbox(label="Sentiment Prediction"),
|
29 |
+
title=title,
|
30 |
+
theme="finlaymacklon/boxy_violet",
|
31 |
+
description=description
|
32 |
+
)
|
33 |
+
tweet.launch(share=True)
|