John6666 commited on
Commit
f088106
·
verified ·
1 Parent(s): 9c86d59

Upload 2 files

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. utils.py +6 -1
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🧩🖼️📦
4
  colorFrom: red
5
  colorTo: pink
6
  sdk: gradio
7
- sdk_version: 6.17.3
8
  python_version: "3.12"
9
  app_file: app.py
10
  pinned: true
 
4
  colorFrom: red
5
  colorTo: pink
6
  sdk: gradio
7
+ sdk_version: 6.10.0
8
  python_version: "3.12"
9
  app_file: app.py
10
  pinned: true
utils.py CHANGED
@@ -578,7 +578,12 @@ def create_mask_now(img, invert):
578
 
579
  time.sleep(0.5)
580
 
581
- transparent_image = img["layers"][0]
 
 
 
 
 
582
 
583
  # Extract the alpha channel
584
  alpha_channel = np.array(transparent_image)[:, :, 3]
 
578
 
579
  time.sleep(0.5)
580
 
581
+ layers = (img.get("layers") or []) if isinstance(img, dict) else []
582
+ if not layers:
583
+ background = img.get("background") if isinstance(img, dict) else None
584
+ return background, None
585
+
586
+ transparent_image = layers[0]
587
 
588
  # Extract the alpha channel
589
  alpha_channel = np.array(transparent_image)[:, :, 3]