Sefat33 commited on
Commit
36d6227
Β·
verified Β·
1 Parent(s): b13f5bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -2
app.py CHANGED
@@ -9,6 +9,33 @@ from keras.layers import BatchNormalization, DepthwiseConv2D, TFSMLayer
9
  import os
10
  from io import BytesIO
11
  import base64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  # --- Fix deserialization issues ---
14
  original_bn = BatchNormalization.from_config
@@ -220,10 +247,13 @@ def show_lime(img, model, pred_idx, pred_label, all_probs):
220
  buf.seek(0)
221
  lime_data = buf.getvalue()
222
 
 
 
 
223
  col1, col2 = st.columns(2)
224
  with col1:
225
  st.markdown("### πŸ“ LIME Explanation")
226
- st.image(lime_data, width=224, output_format="PNG") # πŸ‘ˆ Small LIME image
227
  st.download_button(
228
  "πŸ“₯ Download LIME Image",
229
  lime_data,
@@ -232,10 +262,13 @@ def show_lime(img, model, pred_idx, pred_label, all_probs):
232
  )
233
  with col2:
234
  st.markdown(
235
- f"<div class='overlay'>{explanation_text.get(pred_label, 'No explanation available.')}</div>",
236
  unsafe_allow_html=True
237
  )
238
 
 
 
 
239
  # --- Streamlit App UI ---
240
  st.set_page_config(page_title="πŸ‘ Retina Classifier with LIME", layout="wide")
241
  st.title("πŸ‘ Retina Disease Classifier with LIME Explanation")
 
9
  import os
10
  from io import BytesIO
11
  import base64
12
+ st.markdown(
13
+ """
14
+ <style>
15
+ .flex-row {
16
+ display: flex;
17
+ gap: 2rem;
18
+ align-items: stretch; /* ensures equal height */
19
+ }
20
+ .flex-row > div {
21
+ flex: 1;
22
+ display: flex;
23
+ flex-direction: column;
24
+ }
25
+ .overlay {
26
+ background-color: rgba(255, 255, 255, 0.85);
27
+ padding: 1rem;
28
+ border-radius: 10px;
29
+ overflow-y: auto;
30
+ color: #333;
31
+ font-size: 16px;
32
+ line-height: 1.5;
33
+ flex-grow: 1; /* fills the column height */
34
+ }
35
+ </style>
36
+ """,
37
+ unsafe_allow_html=True,
38
+ )
39
 
40
  # --- Fix deserialization issues ---
41
  original_bn = BatchNormalization.from_config
 
247
  buf.seek(0)
248
  lime_data = buf.getvalue()
249
 
250
+ # Wrap columns inside a flex container for equal height
251
+ st.markdown('<div class="flex-row">', unsafe_allow_html=True)
252
+
253
  col1, col2 = st.columns(2)
254
  with col1:
255
  st.markdown("### πŸ“ LIME Explanation")
256
+ st.image(lime_data, width=224, output_format="PNG")
257
  st.download_button(
258
  "πŸ“₯ Download LIME Image",
259
  lime_data,
 
262
  )
263
  with col2:
264
  st.markdown(
265
+ f'<div class="overlay">{explanation_text.get(pred_label, "No explanation available.")}</div>',
266
  unsafe_allow_html=True
267
  )
268
 
269
+ st.markdown('</div>', unsafe_allow_html=True)
270
+
271
+
272
  # --- Streamlit App UI ---
273
  st.set_page_config(page_title="πŸ‘ Retina Classifier with LIME", layout="wide")
274
  st.title("πŸ‘ Retina Disease Classifier with LIME Explanation")