Skip to content

Commit

Permalink
Add str check for image for API compatibility, Mikubill#567
Browse files Browse the repository at this point in the history
  • Loading branch information
PhoenixCreation committed Mar 12, 2023
1 parent 5bf7e54 commit d7ee999
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions scripts/controlnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,8 +748,15 @@ def process(self, p, is_img2img=False, is_ui=False, *args):
elif input_image is not None:
input_image = HWC3(np.asarray(input_image))
elif image is not None:
input_image = HWC3(image['image'])
if not ((image['mask'][:, :, 0]==0).all() or (image['mask'][:, :, 0]==255).all()):
# Need to check the image for API compatibility
if isinstance(image['image'], str):
from modules.api.api import decode_base64_to_image
input_image = HWC3(np.asarray(decode_base64_to_image(image['image'])))
else:
input_image = HWC3(image['image'])

# Adding 'mask' check for API compatibility
if 'mask' in image and not ((image['mask'][:, :, 0]==0).all() or (image['mask'][:, :, 0]==255).all()):
print("using mask as input")
input_image = HWC3(image['mask'][:, :, 0])
scribble_mode = True
Expand Down

0 comments on commit d7ee999

Please sign in to comment.