kodetr commited on
Commit
d018564
Β·
verified Β·
1 Parent(s): 5bc80d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -19
app.py CHANGED
@@ -67,7 +67,7 @@ def ensure_probability(x):
67
  return x
68
 
69
  # ============================================================
70
- # 6. PREDICTION (TEXT + MAIN RESULT)
71
  # ============================================================
72
  def predict_and_format_text(image_path):
73
  img_tensor = preprocess_image(image_path)
@@ -111,7 +111,7 @@ def predict_and_format_text(image_path):
111
  dme_conf = dme_pred[dme_idx] * 100
112
 
113
  # ======================================================
114
- # πŸ”₯ HASIL UTAMA (BESAR, BOLD, DI ATAS)
115
  # ======================================================
116
  main_result = f"""
117
  <div style="text-align:center; font-size:30px; font-weight:800; margin-bottom:20px;">
@@ -121,26 +121,33 @@ def predict_and_format_text(image_path):
121
  """
122
 
123
  # ======================================================
124
- # DETAIL HASIL
125
  # ======================================================
126
- detail = f"""
127
- <b>πŸ” Diabetic Retinopathy (DR)</b><br/>
128
- Confidence: <b>{dr_conf:.2f}%</b><br/><br/>
129
-
130
- <b>πŸ‘οΈ Diabetic Macular Edema (DME)</b><br/>
131
- Confidence: <b>{dme_conf:.2f}%</b><br/><br/>
132
-
133
- <b>πŸ“Š DR Probabilities:</b><br/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  """
135
 
136
- for c, p in zip(DR_CLASSES, dr_pred):
137
- detail += f"{c}: {p*100:.2f}%<br/>"
138
-
139
- detail += "<br/><b>πŸ“‰ DME Probabilities:</b><br/>"
140
- for c, p in zip(DME_CLASSES, dme_pred):
141
- detail += f"{c}: {p*100:.2f}%<br/>"
142
-
143
- return main_result + detail
144
 
145
  # ============================================================
146
  # 7. MULTI TEST IMAGES
 
67
  return x
68
 
69
  # ============================================================
70
+ # 6. PREDICTION β†’ TABLE ONLY
71
  # ============================================================
72
  def predict_and_format_text(image_path):
73
  img_tensor = preprocess_image(image_path)
 
111
  dme_conf = dme_pred[dme_idx] * 100
112
 
113
  # ======================================================
114
+ # πŸ”₯ HASIL UTAMA (BESAR, DI ATAS)
115
  # ======================================================
116
  main_result = f"""
117
  <div style="text-align:center; font-size:30px; font-weight:800; margin-bottom:20px;">
 
121
  """
122
 
123
  # ======================================================
124
+ # πŸ“Š TABEL HASIL (TANPA DETAIL)
125
  # ======================================================
126
+ table_result = f"""
127
+ <table style="width:100%; border-collapse:collapse; font-size:16px;">
128
+ <thead>
129
+ <tr style="background-color:#f2f2f2;">
130
+ <th style="border:1px solid #ccc; padding:8px;">Aspek</th>
131
+ <th style="border:1px solid #ccc; padding:8px;">Klasifikasi</th>
132
+ <th style="border:1px solid #ccc; padding:8px;">Confidence (%)</th>
133
+ </tr>
134
+ </thead>
135
+ <tbody>
136
+ <tr>
137
+ <td style="border:1px solid #ccc; padding:8px;">Diabetic Retinopathy (DR)</td>
138
+ <td style="border:1px solid #ccc; padding:8px;"><b>{dr_name}</b></td>
139
+ <td style="border:1px solid #ccc; padding:8px;">{dr_conf:.2f}%</td>
140
+ </tr>
141
+ <tr>
142
+ <td style="border:1px solid #ccc; padding:8px;">Diabetic Macular Edema (DME)</td>
143
+ <td style="border:1px solid #ccc; padding:8px;"><b>{dme_name}</b></td>
144
+ <td style="border:1px solid #ccc; padding:8px;">{dme_conf:.2f}%</td>
145
+ </tr>
146
+ </tbody>
147
+ </table>
148
  """
149
 
150
+ return main_result + table_result
 
 
 
 
 
 
 
151
 
152
  # ============================================================
153
  # 7. MULTI TEST IMAGES