|
import streamlit as st |
|
from PIL import Image |
|
import utils.llm_helper as helper |
|
import utils.BMI_graph as plot |
|
|
|
def main(): |
|
|
|
icon = Image.open('Resource/td-logo.png') |
|
|
|
|
|
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") |
|
|
|
|
|
age = st.sidebar.number_input("Age", min_value=0, step=1) |
|
|
|
|
|
weight = st.sidebar.number_input("Weight (kg)", min_value=0.0, step=0.1) |
|
|
|
|
|
height = st.sidebar.number_input("Height (cm)", min_value=0.0, step=0.1) |
|
|
|
|
|
medical_conditions = st.sidebar.text_area("Medical Conditions") |
|
|
|
|
|
gender_options = ["Male", "Female"] |
|
gender = st.sidebar.radio("Gender", gender_options,horizontal=True) |
|
|
|
|
|
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 |
|
|
|
|
|
|
|
|
|
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...'): |
|
|
|
if name != '': |
|
st.title(f"***Hello {name}***") |
|
else: |
|
st.title(f"***Hello There***") |
|
|
|
fig = plot.BMI_Value(height=height, weight=weight) |
|
|
|
|
|
st.plotly_chart(fig) |
|
|
|
response = helper.main(name,age,weight,height,gender,accessability,flexibility,gym,home,selected_options) |
|
st.write(response) |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
main() |