diff --git a/.streamlit/config.toml b/.streamlit/config.toml index 54bad9eb6d873cc0f57103c4112a03be75af0a58..9b3d160d8bd8c8b1eb5980e18e5e3170f3ccfd85 100644 --- a/.streamlit/config.toml +++ b/.streamlit/config.toml @@ -1,15 +1,6 @@ [theme] -#primaryColor="#E0A505" -#backgroundColor="#b7e4f3" -#secondaryBackgroundColor="#b5f5cb" -#textColor="#0a23bf" +#base="dark" font="sans serif" - -#primaryColor="#E91E63" -#backgroundColor="#FFE082" -#secondaryBackgroundColor="#E6EE9C" -#textColor="#0a23bf" - primaryColor="#EF8354" backgroundColor="#FFFFFF" secondaryBackgroundColor="#7E8987" diff --git a/Packages.py b/Packages.py index 554f28d1d6b4060fb1a5e8e2216f60f62386f6a0..217daba0c5d087c3a3ce21f778bb724931bd7fc9 100644 --- a/Packages.py +++ b/Packages.py @@ -43,6 +43,7 @@ from sklearn.metrics import pairwise_distances_argmin_min, adjusted_rand_score, ## Web app construction import streamlit as st +from st_pages import Page, Section, show_pages, add_page_title, hide_pages from tempfile import NamedTemporaryFile # help on streamlit input https://docs.streamlit.io/library/api-reference/widgets diff --git a/app.py b/app.py index 8baa0d0724465c6e6101c90bafa42dba54c44a00..027393b8079257a75cae2893f29cd52e15db1c8a 100644 --- a/app.py +++ b/app.py @@ -1,24 +1,39 @@ -#from Modules_manager.PCA_ import pca_maker - from Packages import * -st.set_page_config(page_title="NIRS Utils", page_icon=":goat:", layout="wide") +st.set_page_config(page_title="NIRS Utils", page_icon=":goat:", layout="wide",) +if 'interface' not in st.session_state: + st.session_state['interface'] = 'simple' from Modules import * from Class_Mod.DATA_HANDLING import * -# graphical delimiter -# st.write("---") - -# load images for web interface -# img_sselect = Image.open("images\sselect.JPG") -# img_general = Image.open("images\general.JPG") -# img_predict = Image.open("images\predict.JPG") -# TOC menu on the left -# with st.sidebar: -# st.markdown("[Sample Selection](#sample-selection)") -# st.markdown("[Model Development](#create-a-model)") -# st.markdown("[Predictions Making](#predict)") +# # TOC menu on the left +show_pages( + [Page("app.py", "Home"), + Page("pages\\1-samples_selection.py", "Samples Selection"), + Page("pages\\2-model_creation.py", "Models Creation"), + Page("pages\\3-prediction.py", "Predictions"), + ] +) +hide_pages("Samples Selection") +hide_pages("Models Creation") +hide_pages("Predictions") +with st.sidebar: + interface = st.selectbox(label="Interface", options=['simple', 'advanced'], key='interface') + st.page_link('pages\\1-samples_selection.py') + if st.session_state['interface'] == 'simple': + st.page_link('pages\\2-model_creation.py') + # if advanced interface, split Models Creation and Predictions + elif st.session_state['interface'] == 'advanced': + show_pages( + [Page("app.py", "Home"), + Page("pages\\1-samples_selection.py", "Samples Selection"), + Page("pages\\2-model_creation.py", "Models Creation"), + Page("pages\\3-prediction.py", "Predictions"), + ] + ) + st.page_link('pages\\2-model_creation.py') + st.page_link('pages\\3-prediction.py') # Page header with st.container(): diff --git a/pages/1-samples_selection.py b/pages/1-samples_selection.py index 6ca45f1c1a943b6866571b832ce9a36b84c42914..b8a8f245685b50c344d22e53755ffa8196da6575 100644 --- a/pages/1-samples_selection.py +++ b/pages/1-samples_selection.py @@ -3,6 +3,10 @@ st.set_page_config(page_title="NIRS Utils", page_icon=":goat:", layout="wide") from Modules import * from Class_Mod.DATA_HANDLING import * +st.session_state["interface"] = st.session_state.get('interface') +if st.session_state["interface"] == 'simple': + hide_pages("Predictions") + ################################### Data Loading and Visualization ######################################## container1 = st.container(border=True) col2, col1 = st.columns([3, 1]) @@ -90,7 +94,7 @@ cluster_methods = ['', 'Kmeans','HDBSCAN', 'AP'] with container2: if sselectx_csv is not None: plot_type=['', 'PCA','UMAP', 'NMF'] - cluster_methods = ['', 'Kmeans','UMAP', 'AP'] + cluster_methods = ['', 'Kmeans','HDBSCAN', 'AP'] with pc: type_plot = st.selectbox("Dimensionality reduction techniques: ", options=plot_type, key=37) diff --git a/pages/2-model_creation.py b/pages/2-model_creation.py index b66ac470edbcd7355c71d0d3fdf9e03f8be4a24f..3fadcb45393c71242b4876ccf32912c616a59ec4 100644 --- a/pages/2-model_creation.py +++ b/pages/2-model_creation.py @@ -3,7 +3,9 @@ st.set_page_config(page_title="NIRS Utils", page_icon=":goat:", layout="wide") from Modules import * from Class_Mod.DATA_HANDLING import * - +st.session_state["interface"] = st.session_state.get('interface') +if st.session_state["interface"] == 'simple': + hide_pages("Predictions") def nn(x): return x is not None ######################################################################################## @@ -107,4 +109,8 @@ if xcal_csv is not None and ycal_csv is not None: # create a report with information on the model ## see https://stackoverflow.com/a/59578663 - #M4.pyplot(reg_plot(meas==(ycal_csv,ycal_csv,ycal_csv], pred=[ycal_csv,ycal_csv,ycal_csv])) \ No newline at end of file + #M4.pyplot(reg_plot(meas==(ycal_csv,ycal_csv,ycal_csv], pred=[ycal_csv,ycal_csv,ycal_csv])) + + + if st.session_state['interface'] == 'simple': + st.page_link('pages\\3-prediction.py', label = 'Keep on keepin\' on to predict your values !') diff --git a/pages/3-prediction.py b/pages/3-prediction.py index 6fba85144e3d85863dd387de395e755954e6869f..4ac4e5832e6d4bfce0d6c96ac0ffe748ffec7a97 100644 --- a/pages/3-prediction.py +++ b/pages/3-prediction.py @@ -3,6 +3,7 @@ st.set_page_config(page_title="NIRS Utils", page_icon=":goat:", layout="wide") from Modules import * from Class_Mod.DATA_HANDLING import * +st.session_state["interface"] = st.session_state.get('interface') st.header("Predictions making", divider='blue') diff --git a/requirements.txt b/requirements.txt index de7027c587917f3f6fcd947ce5ab4b58af12de24..60c8fc3ba7f50429005b8d19db952fc27902ca47 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ streamlit>=1.3.0 +st_pages-0.4.5>=0.4.5 requests>=2.24.0 Pillow>=8.4.0 protobuf>=3.19.0