controlnet files: revert the refactoring done in #77
This commit is contained in:
parent
6201a93d4a
commit
1160d4e8b2
@ -17,6 +17,13 @@ class ControlnetUtil:
|
||||
image_to_canny = np.concatenate([image_to_canny, image_to_canny, image_to_canny], axis=2)
|
||||
return PIL.Image.fromarray(image_to_canny)
|
||||
|
||||
@staticmethod
|
||||
def scale_image(height: int, width: int, img: PIL.Image) -> PIL.Image:
|
||||
if height != img.height or width != img.width:
|
||||
log.warning(f"Control image has different dimensions than the model. Resizing to {width}x{height}")
|
||||
img = img.resize((width, height), PIL.Image.LANCZOS)
|
||||
return img
|
||||
|
||||
@staticmethod
|
||||
def save_canny_image(control_image: PIL.Image, path: str):
|
||||
from mflux import ImageUtil
|
||||
|
||||
@ -131,7 +131,7 @@ class Flux1Controlnet:
|
||||
|
||||
# Embed the controlnet reference image
|
||||
control_image = ImageUtil.load_image(controlnet_image_path)
|
||||
control_image = ImageUtil.scale_to_dimensions(control_image, config.height, config.width)
|
||||
control_image = ControlnetUtil.scale_image(config.height, config.width, control_image)
|
||||
control_image = ControlnetUtil.preprocess_canny(control_image)
|
||||
if controlnet_save_canny:
|
||||
ControlnetUtil.save_canny_image(control_image, output)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user