Daniel Cerda Escobar commited on
Commit
7257ea0
·
1 Parent(s): bc4d2d3

Resize Image Dynamically

Browse files
Files changed (1) hide show
  1. app.py +34 -30
app.py CHANGED
@@ -157,36 +157,40 @@ if submit:
157
 
158
  st.write('##')
159
 
160
- col1, col2, col3 = st.columns([1, 10, 1], gap='small')
161
- with col2:
162
- st.subheader('Object Prediction Result')
163
- # Add custom CSS to make images responsive and add a border
164
- st.markdown(
165
- """
166
- <style>
167
- .stImageComparison > div {
168
- max-width: 100%;
169
- height: auto;
170
- border: 3px solid #000; /* Add a black border with 3px thickness */
171
- border-radius: 10px; /* Optional: Add rounded corners to the border */
172
- padding: 5px; /* Optional: Add padding around the images */
173
- }
174
- </style>
175
- """,
176
- unsafe_allow_html=True
177
- )
178
- # Display image comparison with custom width and labels
179
- image_comparison(
180
- st.session_state["output_1"],
181
- st.session_state["output_2"],
182
- label1="Raw Diagram",
183
- label2="Inference Prediction",
184
- starting_position=50,
185
- show_labels=True,
186
- make_responsive=True,
187
- in_memory=True
188
- )
189
-
 
 
 
 
190
  #st.markdown(f"#### Object Detection Result")
191
  #with st.container(border = True):
192
  # static_component = image_comparison(
 
157
 
158
  st.write('##')
159
 
160
+ # Optional: Add a subtitle for extra description
161
+ st.subheader("Compare the two images below:")
162
+
163
+ # Use custom CSS to make the image comparison widget responsive
164
+ st.markdown(
165
+ """
166
+ <style>
167
+ /* Target the container of the image comparison widget */
168
+ .stImageComparison > div {
169
+ width: 100%; /* Make the container responsive */
170
+ max-width: 90vw; /* Max width as 90% of the viewport width */
171
+ margin: 0 auto; /* Center the widget */
172
+ height: auto; /* Ensure aspect ratio is maintained */
173
+ }
174
+
175
+ /* Optional: Add additional styling, like border */
176
+ .stImageComparison > div img {
177
+ width: 100%; /* Images take 100% width of the container */
178
+ height: auto; /* Maintain the aspect ratio */
179
+ border-radius: 8px; /* Optional: Rounded corners */
180
+ }
181
+ </style>
182
+ """,
183
+ unsafe_allow_html=True
184
+ )
185
+
186
+ # Display the image comparison widget with the resized images
187
+ image_comparison(
188
+ st.session_state["output_1"],
189
+ st.session_state["output_2"]
190
+ )
191
+
192
+ #col1, col2, col3 = st.columns([1, 10, 1], gap='small')
193
+ #with col2:
194
  #st.markdown(f"#### Object Detection Result")
195
  #with st.container(border = True):
196
  # static_component = image_comparison(