Skip to content

Commit

Permalink
Merge pull request #22 from gsurus/main
Browse files Browse the repository at this point in the history
fix: 🪲 issue where the image had too many channels and failed to be…
  • Loading branch information
KutsuyaYuki authored Apr 19, 2023
2 parents 8e37353 + 4125cde commit 01cd0ff
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion scripts/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,13 @@ def run(self, p, only_save_background_free_pictures, do_not_auto_save, custom_ba
# Separate the background from the foreground
nmask, nimg = rmbg_fn(np.array(proc.images[i]))

# Convert the image back to a format that can be saved
# Check the number of channels in the nimg array, select only the first 3 or 4 channels
num_channels = nimg.shape[2]
if num_channels > 4:
nimg = nimg[:, :, :4]

# Ensure the data type is uint8 and convert the image back to a format that can be saved
nimg = nimg.astype(np.uint8)
img = im.fromarray(nimg)

# If only_save_background_free_pictures is true, check if the image has a background
Expand Down

0 comments on commit 01cd0ff

Please sign in to comment.