ssh-AI commited on
Commit
d768bb2
·
verified ·
1 Parent(s): d10e2bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -18,10 +18,14 @@ def resize_image(img, max_height=500):
18
  img = img.resize((new_width, max_height), resample=Image.Resampling.LANCZOS)
19
  return img
20
 
21
- # --- Custom Cropper (with all fixes) ---
22
  def custom_cropper(image, key="canvas_crop"):
23
  st.markdown("🖍️ Draw a rectangle over the area you want to crop.")
24
- background_array = np.array(image) if image is not None else None
 
 
 
 
25
 
26
  canvas_result = st_canvas(
27
  fill_color="rgba(255, 165, 0, 0.3)",
 
18
  img = img.resize((new_width, max_height), resample=Image.Resampling.LANCZOS)
19
  return img
20
 
21
+ # --- Custom Cropper (No NumPy crash) ---
22
  def custom_cropper(image, key="canvas_crop"):
23
  st.markdown("🖍️ Draw a rectangle over the area you want to crop.")
24
+
25
+ try:
26
+ background_array = np.asarray(image)
27
+ except Exception:
28
+ background_array = None
29
 
30
  canvas_result = st_canvas(
31
  fill_color="rgba(255, 165, 0, 0.3)",