Lachin commited on
Commit
3c9b7c5
·
1 Parent(s): a1c90cd

application

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import json
3
+ import streamlit as st
4
+
5
+
6
+
7
+ def get_prediction(data={"sentence":"Hello"}):
8
+ #copy paste your aiservice link here
9
+ url = 'https://askai.aiclub.world/8bf323d4-5fbc-49b4-9473-3ab341888363'
10
+ r = requests.post(url, data=json.dumps(data))
11
+ response = getattr(r,'_content').decode("utf-8")
12
+ return response
13
+
14
+ #creating the web app
15
+ #setting the title
16
+ st.title("Mood Classifier")#change the title as your web app
17
+
18
+ #setting up the sub title
19
+ st.subheader("Check Your Mood")#change the subheader as your web app
20
+
21
+ #text input
22
+ text = st.text_input("Explain what you feel...")
23
+
24
+ #settin the data
25
+ input_data = {"sentence":text}
26
+ #getting the respoense
27
+ prediction = get_prediction(input_data)
28
+ mood = json.loads(json.loads(prediction)['body'])['predicted_label']
29
+
30
+ #subheading
31
+ if text:
32
+ st.subheader("Your Mood is : {}".format(mood))