|
| 1 | +import importlib |
1 | 2 | import streamlit as st
|
2 |
| -from _shared import add_sidebar_logo |
3 | 3 | from _shared import data_directory
|
| 4 | +from streamlit_option_menu import option_menu |
4 | 5 |
|
5 | 6 | st.set_page_config(page_title="Dianna's dashboard",
|
6 | 7 | page_icon='📊',
|
7 |
| - layout='centered', |
| 8 | + layout='wide', |
8 | 9 | initial_sidebar_state='auto',
|
9 | 10 | menu_items={
|
10 | 11 | 'Get help':
|
|
16 | 17 | 'https://github.com/dianna-ai/dianna')
|
17 | 18 | })
|
18 | 19 |
|
19 |
| -add_sidebar_logo() |
| 20 | +# Define dictionary of dashboard pages |
| 21 | +pages = { |
| 22 | + "Home": "home", |
| 23 | + "Images": "pages.Images", |
| 24 | + "Tabular": "pages.Tabular", |
| 25 | + "Text": "pages.Text", |
| 26 | + "Time series": "pages.Time_series" |
| 27 | +} |
20 | 28 |
|
21 |
| -st.image(str(data_directory / 'logo.png')) |
| 29 | +# Set up the top menu |
| 30 | +selected = option_menu( |
| 31 | + menu_title=None, |
| 32 | + options=list(pages.keys()), |
| 33 | + icons=["house", "camera", "table", "alphabet", "clock"], |
| 34 | + menu_icon="cast", |
| 35 | + default_index=0, |
| 36 | + orientation="horizontal" |
| 37 | +) |
22 | 38 |
|
23 |
| -st.markdown(""" |
24 |
| -DIANNA is a Python package that brings explainable AI (XAI) to your research project. |
25 |
| -It wraps carefully selected XAI methods in a simple, uniform interface. It's built by, |
26 |
| -with and for (academic) researchers and research software engineers working on machine |
27 |
| -learning projects. |
| 39 | +# Display the content of the selected page |
| 40 | +if selected == "Home": |
| 41 | + st.image(str(data_directory / 'logo.png')) |
28 | 42 |
|
29 |
| -### Pages |
| 43 | + st.markdown(""" |
| 44 | + DIANNA is a Python package that brings explainable AI (XAI) to your research project. |
| 45 | + It wraps carefully selected XAI methods in a simple, uniform interface. It's built by, |
| 46 | + with and for (academic) researchers and research software engineers working on machine |
| 47 | + learning projects. |
30 | 48 |
|
31 |
| -- <a href="/Images" target="_parent">Images</a> |
32 |
| -- <a href="/Text" target="_parent">Text</a> |
33 |
| -- <a href="/Time_series" target="_parent">Time series</a> |
| 49 | + ### Pages |
34 | 50 |
|
| 51 | + - <a href="/Images" target="_parent">Image data</a> |
| 52 | + - <a href="/Tabular" target="_parent">Tabular data</a> |
| 53 | + - <a href="/Text" target="_parent">Text data</a> |
| 54 | + - <a href="/Time_series" target="_parent">Time series data</a> |
35 | 55 |
|
36 |
| -### More information |
37 | 56 |
|
38 |
| -- [Source code](https://github.com/dianna-ai/dianna) |
39 |
| -- [Documentation](https://dianna.readthedocs.io/) |
40 |
| -""", |
41 |
| - unsafe_allow_html=True) |
| 57 | + ### More information |
| 58 | +
|
| 59 | + - [Source code](https://github.com/dianna-ai/dianna) |
| 60 | + - [Documentation](https://dianna.readthedocs.io/) |
| 61 | + """, |
| 62 | + unsafe_allow_html=True) |
| 63 | + |
| 64 | +else: |
| 65 | + # Dynamically import and execute the page |
| 66 | + page_module = pages[selected] |
| 67 | + # Make sure that all variables are reset when switching page |
| 68 | + if selected != 'Images': |
| 69 | + for k in st.session_state.keys(): |
| 70 | + if 'Image' in k: |
| 71 | + st.session_state.pop(k, None) |
| 72 | + if selected != 'Tabular': |
| 73 | + for k in st.session_state.keys(): |
| 74 | + if 'Tabular' in k: |
| 75 | + st.session_state.pop(k, None) |
| 76 | + if selected != 'Text': |
| 77 | + for k in st.session_state.keys(): |
| 78 | + if 'Text' in k: |
| 79 | + st.session_state.pop(k, None) |
| 80 | + if selected != 'Time series': |
| 81 | + for k in st.session_state.keys(): |
| 82 | + if 'TS' in k: |
| 83 | + st.session_state.pop(k, None) |
| 84 | + page = importlib.import_module(page_module) |
0 commit comments