gamza commited on
Commit
8fe0112
โ€ข
1 Parent(s): 28b8b64

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
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)