|
from utils import navigate_to |
|
from pages import manual_input_page, image_input_page, model_inference_page |
|
|
|
import streamlit as st |
|
from streamlit import session_state as sst |
|
import asyncio |
|
|
|
|
|
|
|
if "page" not in sst: |
|
sst["page"] = "Home" |
|
|
|
|
|
def reset_sst(): |
|
for key in list(sst.keys()): |
|
if key != "page": |
|
sst.pop(key, None) |
|
|
|
|
|
async def landing_page(): |
|
|
|
st.title("We will explain your menu like never before!") |
|
st.write("\n") |
|
st.write("\n") |
|
st.write("\n") |
|
|
|
c1, c2= st.columns(2) |
|
|
|
with c1: |
|
|
|
st.button("Enter Items Manually", on_click=navigate_to, args=("ManualInput",)) |
|
|
|
with c2: |
|
|
|
st.button("Upload Items from Image", on_click=navigate_to, args=("ImageInput",)) |
|
|
|
|
|
|
|
|
|
async def main(): |
|
""" |
|
Main function that handles the navigation logic based on the current page. |
|
|
|
Returns: |
|
None |
|
""" |
|
|
|
|
|
if sst["page"] == "Home": |
|
reset_sst() |
|
await landing_page() |
|
|
|
elif sst["page"] == "ManualInput": |
|
reset_sst() |
|
await manual_input_page() |
|
|
|
elif sst["page"] == "ImageInput": |
|
reset_sst() |
|
await image_input_page() |
|
|
|
elif sst["page"] == "Inference": |
|
await model_inference_page() |
|
|
|
asyncio.run(main()) |
|
|