milwright commited on
Commit
6601c56
·
1 Parent(s): c5bb28e

Fix image preprocessing preview for Hugging Face compatibility

Browse files

- Reduced image width in preview from 600 to 300 for better compatibility
- Added additional CSS fixes for image display within Streamlit expanders
- Improved handling of image containers in the preview UI

Files changed (2) hide show
  1. app.py +4 -2
  2. ui/custom.css +11 -0
app.py CHANGED
@@ -935,13 +935,15 @@ with main_tab1:
935
 
936
  with preview_cols[0]:
937
  st.markdown("**Original Image**")
938
- st.image(uploaded_file, width=600)
 
939
 
940
  with preview_cols[1]:
941
  st.markdown("**Preprocessed Image**")
942
  try:
943
  processed_bytes = preprocess_image(uploaded_file.getvalue(), preprocessing_options)
944
- st.image(io.BytesIO(processed_bytes), width=600)
 
945
  except Exception as e:
946
  st.error(f"Error in preprocessing: {str(e)}")
947
  st.info("Try using grayscale preprocessing for PNG images with transparency")
 
935
 
936
  with preview_cols[0]:
937
  st.markdown("**Original Image**")
938
+ # Fixed width parameter to ensure compatibility
939
+ st.image(uploaded_file, width=300)
940
 
941
  with preview_cols[1]:
942
  st.markdown("**Preprocessed Image**")
943
  try:
944
  processed_bytes = preprocess_image(uploaded_file.getvalue(), preprocessing_options)
945
+ # Fixed width parameter to ensure compatibility
946
+ st.image(io.BytesIO(processed_bytes), width=300)
947
  except Exception as e:
948
  st.error(f"Error in preprocessing: {str(e)}")
949
  st.info("Try using grayscale preprocessing for PNG images with transparency")
ui/custom.css CHANGED
@@ -77,6 +77,17 @@
77
  object-fit: contain !important;
78
  }
79
 
 
 
 
 
 
 
 
 
 
 
 
80
  /* Additional image fixes for all containers */
81
  .document-content img,
82
  .markdown-text-container img,
 
77
  object-fit: contain !important;
78
  }
79
 
80
+ /* Additional fixes for image preprocessing preview in expanders */
81
+ .streamlit-expanderContent {
82
+ overflow: hidden !important;
83
+ }
84
+
85
+ .streamlit-expanderContent img {
86
+ max-width: 95% !important;
87
+ height: auto !important;
88
+ object-fit: contain !important;
89
+ }
90
+
91
  /* Additional image fixes for all containers */
92
  .document-content img,
93
  .markdown-text-container img,