File size: 3,919 Bytes
41cef72 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
import streamlit as st
from PIL import Image
import utils.llm_helper as helper
import utils.BMI_graph as plot
def main():
# Page icon
icon = Image.open('Resource/td-logo.png')
# Page config
st.set_page_config(page_title="GYM",
page_icon=icon,
layout="wide"
)
company_logo_path = 'Resource/td-logo.png'
st.sidebar.image(company_logo_path, width=50)
name = st.sidebar.text_input("Name")
# Non-negative Integer Field for Age
age = st.sidebar.number_input("Age", min_value=0, step=1)
# Non-negative Float Field for Weight
weight = st.sidebar.number_input("Weight (kg)", min_value=0.0, step=0.1)
# Non-negative Float Field for Height
height = st.sidebar.number_input("Height (cm)", min_value=0.0, step=0.1)
# Long Text Field for Medical Conditions
medical_conditions = st.sidebar.text_area("Medical Conditions")
# Radio Button for Gender
gender_options = ["Male", "Female"]
gender = st.sidebar.radio("Gender", gender_options,horizontal=True)
# Checkbox for Fitness Goals
st.sidebar.write("Accessability")
access_options = ["Gym", "Home"]
accessability = st.sidebar.multiselect("Select options:", access_options)
if accessability == [] or len(accessability) == 1:
flexibility = ''
gym = 0
home = 0
gym_home = gym + home
else:
flexibility_option = ["Gym & Home everyday", "Gym & Home on alternate day","Specify a day"]
flexibility = st.sidebar.radio("Flexibility", flexibility_option,horizontal=True)
if flexibility_option == 'Gym & Home everyday':
flexibility_option = 'Provide a workout plane each day Gym workout and home workout so same day both workout plane should be there (e.g. Day 1 : Monday Gym,Home Day 2 : Tuesday Gym,Home till Day 7 : Sunday Gym,Home)'
elif flexibility == 'Specify a day':
gym = st.sidebar.number_input("Gym day", min_value=1, step=1)
home = st.sidebar.number_input("Home day", min_value=1, step=1)
gym_home = gym + home
else:
gym = 0
home = 0
gym_home = gym + home
# Checkbox for Fitness Goals
st.sidebar.write("Fitness Goals")
fitness_goals_options = ["Weight Loss", "Stay Fit", "Muscle Building"]
selected_options = st.sidebar.multiselect("Select options:", fitness_goals_options)
if st.sidebar.button("Submit"):
if age == 0:
st.error("Age is a mandatory field.")
elif weight == 0:
st.error("weight is a mandatory field.")
elif height == 0:
st.error("height is a mandatory field.")
elif len(access_options) == 0:
st.error("Select atleast one option.")
elif gym_home >=8:
st.error("Gym day and Home day as per week please check value addition of both values should be 7 or less")
elif len(selected_options) == 0:
st.error("Select atleast one fitness goal.")
else:
with st.spinner('Generating Workout Plan...'):
#with st.container(border=True):
if name != '':
st.title(f"***Hello {name}***")
else:
st.title(f"***Hello There***")
fig = plot.BMI_Value(height=height, weight=weight)
#fig.update_traces(x=[value], selector=dict(name="Value"))
#fig.update_traces(x=[max_value], selector=dict(name="Forward Arrow"))
st.plotly_chart(fig)
#st.write(name,age,weight,height,gender,accessability,flexibility,gym,home,selected_options)
response = helper.main(name,age,weight,height,gender,accessability,flexibility,gym,home,selected_options)
st.write(response)
if __name__ == '__main__':
main() |