CoolFace
Apppublic

Lachin/age_classifier

sourceHugging Faceupdated 4y agoView on Hugging Face
0likes
app.py48 linesDownload Raw Back to root
1import requests2import json3import streamlit as st4import pandas as pd5 6 7 8def 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 response13 14#creating the web app15 16#title17st.title("Age Project")#change the title according to your project18 19#dashboard20st.subheader("User Dashboard")21 22#change the input variables as your training data23num_countries = st.slider("Num_countries",0,9,5)24years_in_school = st.slider("Number of years in the school", 0,20,5)25height = st.slider("Your Height",2.00,7.00,4.00)26 27#input_data dictionary keys must be exactly same as the column_names of the dataframe28input_data = {29    "num_countries": num_countries,30    "years_school": years_in_school,31    "height": height32 33}34 35#user data36st.subheader("User Data")37st.dataframe(pd.DataFrame(input_data, index = [0]))38 39#predicting40prediction = get_prediction(input_data)41who_am_i = json.loads(json.loads(prediction)['body'])['predicted_label']42 43st.subheader("Predictions")44if who_am_i == 'child':45    st.write("you are a **Child**")46else:47    st.write("You are an **Adult**")48