Ameya729 commited on
Commit
412e9b8
Β·
verified Β·
1 Parent(s): 5ab3ef6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -16
app.py CHANGED
@@ -139,10 +139,10 @@ def main():
139
  threshold = st.slider(
140
  "Anomaly Threshold",
141
  min_value=0.0,
142
- max_value=2.0,
143
- value=0.5,
144
- step=0.05,
145
- help="Adjust sensitivity: lower = more sensitive to defects"
146
  )
147
 
148
  show_heatmap = st.checkbox("Show Anomaly Heatmap", value=True)
@@ -169,6 +169,9 @@ def main():
169
  - πŸ“ˆ Anomaly score quantification
170
  - πŸš€ CPU-friendly inference
171
  """)
 
 
 
172
 
173
 
174
  # Load model
@@ -191,12 +194,18 @@ def main():
191
  use_demo = st.button("🎲 Try Demo Image")
192
 
193
  if use_demo:
194
- # Load a random test image
195
- demo_dir = config.TEST_DIR / "good"
196
- demo_images = list(demo_dir.glob("*.png"))
197
- if demo_images:
198
- demo_path = np.random.choice(demo_images)
199
- uploaded_file = demo_path
 
 
 
 
 
 
200
 
201
  if uploaded_file is not None:
202
  # Load image
@@ -323,20 +332,18 @@ def main():
323
  st.divider()
324
  st.subheader("πŸ“š Example Defect Types")
325
 
326
- cols = st.columns(5)
327
  defect_examples = {
328
- "Normal": config.TEST_DIR / "good",
329
- "Crack": config.TEST_DIR / "crack",
330
  "Poke": config.TEST_DIR / "poke",
331
- "Scratch": config.TEST_DIR / "scratch",
332
- "Squeeze": config.TEST_DIR / "squeeze"
333
  }
334
 
335
  for idx, (defect_name, defect_dir) in enumerate(defect_examples.items()):
336
  if defect_dir.exists():
337
  images = list(defect_dir.glob("*.png"))
338
  if images:
339
- with cols[idx % 5]:
340
  example_img = Image.open(images[0])
341
  st.image(example_img, caption=defect_name, use_column_width=True)
342
 
 
139
  threshold = st.slider(
140
  "Anomaly Threshold",
141
  min_value=0.0,
142
+ max_value=30.0,
143
+ value=15.0,
144
+ step=0.5,
145
+ help="Adjust sensitivity: lower = more sensitive to defects (typical range: 10-20)"
146
  )
147
 
148
  show_heatmap = st.checkbox("Show Anomaly Heatmap", value=True)
 
169
  - πŸ“ˆ Anomaly score quantification
170
  - πŸš€ CPU-friendly inference
171
  """)
172
+
173
+ st.divider()
174
+ st.warning("⚠️ **Model Limitation:** This model is trained specifically on the Actavis 500mg capsule dataset. It will NOT work accurately on other tablet/capsule types, shapes, or colors.")
175
 
176
 
177
  # Load model
 
194
  use_demo = st.button("🎲 Try Demo Image")
195
 
196
  if use_demo:
197
+ # Load a random test image from specific defect types only
198
+ demo_categories = ["squeeze", "poke", "crack"]
199
+ demo_category = np.random.choice(demo_categories)
200
+ demo_dir = config.TEST_DIR / demo_category
201
+
202
+ if demo_dir.exists():
203
+ demo_images = list(demo_dir.glob("*.png"))
204
+ if demo_images:
205
+ demo_path = np.random.choice(demo_images)
206
+ uploaded_file = demo_path
207
+ else:
208
+ st.error(f"Demo category '{demo_category}' not found.")
209
 
210
  if uploaded_file is not None:
211
  # Load image
 
332
  st.divider()
333
  st.subheader("πŸ“š Example Defect Types")
334
 
335
+ cols = st.columns(3)
336
  defect_examples = {
337
+ "Squeeze": config.TEST_DIR / "squeeze",
 
338
  "Poke": config.TEST_DIR / "poke",
339
+ "Crack": config.TEST_DIR / "crack"
 
340
  }
341
 
342
  for idx, (defect_name, defect_dir) in enumerate(defect_examples.items()):
343
  if defect_dir.exists():
344
  images = list(defect_dir.glob("*.png"))
345
  if images:
346
+ with cols[idx % 3]:
347
  example_img = Image.open(images[0])
348
  st.image(example_img, caption=defect_name, use_column_width=True)
349