Lachin commited on
Commit
35619d3
·
1 Parent(s): c6ae0df

Web app added

Browse files
Files changed (2) hide show
  1. app.py +45 -0
  2. requirements.txt +0 -0
app.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import json
3
+ import streamlit as st
4
+ import pandas as pd
5
+
6
+
7
+
8
+ def get_prediction(data={"num_countries":0,"years_school":9.5,"height":4.165}):
9
+ url = 'https://askai.aiclub.world/2bd98a94-4b74-42d4-be2b-0d25c7acc91b'
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
+
16
+ #title
17
+ st.title("Age Project")
18
+
19
+ #dashboard
20
+ st.subheader("User Dashboard")
21
+
22
+ num_countries = st.slider("Num_countries",0,9,5)
23
+ years_in_school = st.slider("Number of years in the school", 0,20,5)
24
+ height = st.slider("Your Height",2.00,7.00,4.00)
25
+
26
+ input_data = {
27
+ "num_countries": num_countries,
28
+ "years_school": years_in_school,
29
+ "height": height
30
+
31
+ }
32
+
33
+ #user data
34
+ st.subheader("User Data")
35
+ st.dataframe(pd.DataFrame(input_data, index = [0]))
36
+
37
+ #predicting
38
+ prediction = get_prediction(input_data)
39
+ who_am_i = json.loads(json.loads(prediction)['body'])['predicted_label']
40
+
41
+ st.subheader("Predictions")
42
+ if who_am_i == 'child':
43
+ st.write("you are a **Child**")
44
+ else:
45
+ st.write("You are an **Adult**")
requirements.txt ADDED
Binary file (3.56 kB). View file