milwright commited on
Commit
7397882
·
1 Parent(s): 6436c45

Fix sidebar position, fullscreen button styling, and preprocessing preview

Browse files
Files changed (2) hide show
  1. app.py +22 -23
  2. ui/custom.css +19 -2
app.py CHANGED
@@ -476,7 +476,8 @@ with main_tab1:
476
 
477
  # Sidebar with options
478
  with st.sidebar:
479
- st.header("Options")
 
480
 
481
  # Model options
482
  st.subheader("Model Settings")
@@ -949,28 +950,26 @@ with main_tab1:
949
  st.markdown("**Preprocessed Preview**")
950
  try:
951
  processed_bytes = preprocess_image(uploaded_file.getvalue(), preprocessing_options)
952
- # Using a container for better layout control
953
- with st.container():
954
- # Fixed width parameter to ensure compatibility
955
- st.image(io.BytesIO(processed_bytes), width=300, use_column_width=False)
956
-
957
- # Show preprocessing metadata next to the image
958
- meta_items = []
959
- if preprocessing_options.get("document_type", "standard") != "standard":
960
- meta_items.append(f"Document type ({preprocessing_options['document_type']})")
961
- if preprocessing_options.get("grayscale", False):
962
- meta_items.append("Grayscale")
963
- if preprocessing_options.get("denoise", False):
964
- meta_items.append("Denoise")
965
- if preprocessing_options.get("contrast", 0) != 0:
966
- meta_items.append(f"Contrast ({preprocessing_options['contrast']})")
967
- if preprocessing_options.get("rotation", 0) != 0:
968
- meta_items.append(f"Rotation ({preprocessing_options['rotation']}°)")
969
-
970
- # Only show "Applied:" if there are actual preprocessing steps
971
- if meta_items:
972
- meta_text = "Applied: " + ", ".join(meta_items)
973
- st.caption(meta_text)
974
  except Exception as e:
975
  st.error(f"Error in preprocessing: {str(e)}")
976
  st.info("Try using grayscale preprocessing for PNG images with transparency")
 
476
 
477
  # Sidebar with options
478
  with st.sidebar:
479
+ # Move Options header to very top of sidebar
480
+ st.markdown("<h2 style='margin-top:-12px; padding-top:0;'>Options</h2>", unsafe_allow_html=True)
481
 
482
  # Model options
483
  st.subheader("Model Settings")
 
950
  st.markdown("**Preprocessed Preview**")
951
  try:
952
  processed_bytes = preprocess_image(uploaded_file.getvalue(), preprocessing_options)
953
+ # Display the image with a fixed width to prevent layout issues
954
+ st.image(io.BytesIO(processed_bytes), width=400)
955
+
956
+ # Show preprocessing metadata next to the image
957
+ meta_items = []
958
+ if preprocessing_options.get("document_type", "standard") != "standard":
959
+ meta_items.append(f"Document type ({preprocessing_options['document_type']})")
960
+ if preprocessing_options.get("grayscale", False):
961
+ meta_items.append("Grayscale")
962
+ if preprocessing_options.get("denoise", False):
963
+ meta_items.append("Denoise")
964
+ if preprocessing_options.get("contrast", 0) != 0:
965
+ meta_items.append(f"Contrast ({preprocessing_options['contrast']})")
966
+ if preprocessing_options.get("rotation", 0) != 0:
967
+ meta_items.append(f"Rotation ({preprocessing_options['rotation']}°)")
968
+
969
+ # Only show "Applied:" if there are actual preprocessing steps
970
+ if meta_items:
971
+ meta_text = "Applied: " + ", ".join(meta_items)
972
+ st.caption(meta_text)
 
 
973
  except Exception as e:
974
  st.error(f"Error in preprocessing: {str(e)}")
975
  st.info("Try using grayscale preprocessing for PNG images with transparency")
ui/custom.css CHANGED
@@ -152,7 +152,7 @@
152
  overflow: visible !important;
153
  }
154
 
155
- /* Fix for fullscreen and expander buttons in image containers */
156
  .stImage button[title="View fullscreen"] {
157
  position: absolute !important;
158
  top: 5px !important;
@@ -160,6 +160,15 @@
160
  z-index: 1000 !important;
161
  visibility: visible !important;
162
  opacity: 1 !important;
 
 
 
 
 
 
 
 
 
163
  }
164
 
165
  /* Fix fullscreen button styling */
@@ -167,11 +176,19 @@ button[title="View fullscreen"],
167
  button.streamlit-expanderHeader {
168
  z-index: 999 !important;
169
  visibility: visible !important;
170
- opacity: 1 !important;
171
  border-radius: 4px !important;
172
  position: absolute !important;
173
  top: 5px !important;
174
  right: 5px !important;
 
 
 
 
 
 
 
 
175
  }
176
 
177
  /* Make text visible in Previous Results tab - ensure high contrast */
 
152
  overflow: visible !important;
153
  }
154
 
155
+ /* Fix positioning for fullscreen buttons in image containers */
156
  .stImage button[title="View fullscreen"] {
157
  position: absolute !important;
158
  top: 5px !important;
 
160
  z-index: 1000 !important;
161
  visibility: visible !important;
162
  opacity: 1 !important;
163
+ width: 28px !important;
164
+ height: 28px !important;
165
+ padding: 0 !important;
166
+ margin: 0 !important;
167
+ background-color: rgba(255, 255, 255, 0.7) !important;
168
+ border-radius: 4px !important;
169
+ display: flex !important;
170
+ align-items: center !important;
171
+ justify-content: center !important;
172
  }
173
 
174
  /* Fix fullscreen button styling */
 
176
  button.streamlit-expanderHeader {
177
  z-index: 999 !important;
178
  visibility: visible !important;
179
+ opacity: 1 !important;
180
  border-radius: 4px !important;
181
  position: absolute !important;
182
  top: 5px !important;
183
  right: 5px !important;
184
+ width: 28px !important;
185
+ height: 28px !important;
186
+ padding: 0 !important;
187
+ margin: 0 !important;
188
+ background-color: rgba(255, 255, 255, 0.7) !important;
189
+ display: flex !important;
190
+ align-items: center !important;
191
+ justify-content: center !important;
192
  }
193
 
194
  /* Make text visible in Previous Results tab - ensure high contrast */