Update app.py
Browse files
app.py
CHANGED
@@ -55,14 +55,14 @@ st.set_page_config(
|
|
55 |
# Initialize st.session_state
|
56 |
if 'captured_files' not in st.session_state:
|
57 |
st.session_state['captured_files'] = {'cam0': None, 'cam1': None} # One file per camera
|
|
|
|
|
58 |
if 'builder' not in st.session_state:
|
59 |
st.session_state['builder'] = None
|
60 |
if 'model_loaded' not in st.session_state:
|
61 |
st.session_state['model_loaded'] = False
|
62 |
if 'processing' not in st.session_state:
|
63 |
st.session_state['processing'] = {}
|
64 |
-
if 'history' not in st.session_state:
|
65 |
-
st.session_state['history'] = {'cam0': None, 'cam1': None} # One history entry per camera
|
66 |
|
67 |
# Model Configuration Classes
|
68 |
@dataclass
|
@@ -311,7 +311,7 @@ class DiffusionBuilder:
|
|
311 |
# Utility Functions
|
312 |
def generate_filename(sequence, ext="png"):
|
313 |
timestamp = time.strftime("%d%m%Y%H%M%S")
|
314 |
-
return f"{sequence}{timestamp}.{ext}"
|
315 |
|
316 |
def get_download_link(file_path, mime_type="text/plain", label="Download"):
|
317 |
with open(file_path, 'rb') as f:
|
@@ -512,9 +512,12 @@ def update_gallery():
|
|
512 |
valid_files = [f for f in media_files if f and os.path.exists(f)] # Only valid files
|
513 |
if valid_files:
|
514 |
cols = st.sidebar.columns(2)
|
515 |
-
|
516 |
-
with cols[
|
517 |
-
st.image(Image.open(
|
|
|
|
|
|
|
518 |
update_gallery()
|
519 |
|
520 |
st.sidebar.subheader("Model Management 🗂️")
|
@@ -539,7 +542,7 @@ st.sidebar.subheader("History 📜")
|
|
539 |
history_container = st.sidebar.empty()
|
540 |
with history_container:
|
541 |
valid_history = [st.session_state['history']['cam0'], st.session_state['history']['cam1']]
|
542 |
-
for entry in [e for e in valid_history if e]
|
543 |
st.write(entry)
|
544 |
|
545 |
# Tabs
|
|
|
55 |
# Initialize st.session_state
|
56 |
if 'captured_files' not in st.session_state:
|
57 |
st.session_state['captured_files'] = {'cam0': None, 'cam1': None} # One file per camera
|
58 |
+
if 'history' not in st.session_state:
|
59 |
+
st.session_state['history'] = {'cam0': None, 'cam1': None} # One history entry per camera
|
60 |
if 'builder' not in st.session_state:
|
61 |
st.session_state['builder'] = None
|
62 |
if 'model_loaded' not in st.session_state:
|
63 |
st.session_state['model_loaded'] = False
|
64 |
if 'processing' not in st.session_state:
|
65 |
st.session_state['processing'] = {}
|
|
|
|
|
66 |
|
67 |
# Model Configuration Classes
|
68 |
@dataclass
|
|
|
311 |
# Utility Functions
|
312 |
def generate_filename(sequence, ext="png"):
|
313 |
timestamp = time.strftime("%d%m%Y%H%M%S")
|
314 |
+
return f"{sequence}_{timestamp}.{ext}"
|
315 |
|
316 |
def get_download_link(file_path, mime_type="text/plain", label="Download"):
|
317 |
with open(file_path, 'rb') as f:
|
|
|
512 |
valid_files = [f for f in media_files if f and os.path.exists(f)] # Only valid files
|
513 |
if valid_files:
|
514 |
cols = st.sidebar.columns(2)
|
515 |
+
if st.session_state['captured_files']['cam0'] in valid_files:
|
516 |
+
with cols[0]:
|
517 |
+
st.image(Image.open(st.session_state['captured_files']['cam0']), caption="Camera 0", use_container_width=True)
|
518 |
+
if st.session_state['captured_files']['cam1'] in valid_files:
|
519 |
+
with cols[1]:
|
520 |
+
st.image(Image.open(st.session_state['captured_files']['cam1']), caption="Camera 1", use_container_width=True)
|
521 |
update_gallery()
|
522 |
|
523 |
st.sidebar.subheader("Model Management 🗂️")
|
|
|
542 |
history_container = st.sidebar.empty()
|
543 |
with history_container:
|
544 |
valid_history = [st.session_state['history']['cam0'], st.session_state['history']['cam1']]
|
545 |
+
for entry in [e for e in valid_history if e]: # Show only non-None entries
|
546 |
st.write(entry)
|
547 |
|
548 |
# Tabs
|