mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-02-09 09:29:57 +00:00
bugfix: controlnet works in API - image no longer a dictionary (#1425)
Generating from browser works with controlnet. Generating via API wasn't. This is because from_dict() was making 'image' and 'mask_image' a dictionary. In 'controlnet.py' function 'get_input_data' this would cause the following check to throw exception because used to be an incorrect type: elif (unit_image < 5).all() and (unit_image_fg > 5).any(): Now, they are never a dictionary and check is fine
This commit is contained in:
@@ -211,25 +211,9 @@ class ControlNetUnit:
|
||||
**{k: v for k, v in d.items() if k in vars(ControlNetUnit)}
|
||||
)
|
||||
if isinstance(unit.image, str):
|
||||
img = np.array(api.decode_base64_to_image(unit.image)).astype('uint8')
|
||||
unit.image = {
|
||||
"image": img,
|
||||
"mask": np.zeros_like(img),
|
||||
}
|
||||
unit.image = np.array(api.decode_base64_to_image(unit.image)).astype('uint8')
|
||||
if isinstance(unit.mask_image, str):
|
||||
mask = np.array(api.decode_base64_to_image(unit.mask_image)).astype('uint8')
|
||||
if unit.image is not None:
|
||||
# Attach mask on image if ControlNet has input image.
|
||||
assert isinstance(unit.image, dict)
|
||||
unit.image["mask"] = mask
|
||||
unit.mask_image = None
|
||||
else:
|
||||
# Otherwise, wire to standalone mask.
|
||||
# This happens in img2img when using A1111 img2img input.
|
||||
unit.mask_image = {
|
||||
"image": mask,
|
||||
"mask": np.zeros_like(mask),
|
||||
}
|
||||
unit.mask_image = np.array(api.decode_base64_to_image(unit.mask_image)).astype('uint8')
|
||||
return unit
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user