From 750d4f7ea823497e5ca584fef0f578c8e2642203 Mon Sep 17 00:00:00 2001 From: Bryce Date: Thu, 4 May 2023 20:36:49 -0700 Subject: [PATCH] docs: cleanup --- README.md | 2 ++ imaginairy/img_processors/control_modes.py | 35 ---------------------- 2 files changed, 2 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 7ac9c7f..5cfbe95 100644 --- a/README.md +++ b/README.md @@ -399,6 +399,8 @@ docker run -it --gpus all -v $HOME/.cache/huggingface:/root/.cache/huggingface - ## ChangeLog +- feature: upgrade to [controlnet 1.1](https://github.com/lllyasviel/ControlNet-v1-1-nightly) +- fix: controlnet now works with all sd1.5 based models - fix: raw control images are now properly loaded. fixes #296 - fix: filenames start numbers after latest image, even if some previous images were deleted diff --git a/imaginairy/img_processors/control_modes.py b/imaginairy/img_processors/control_modes.py index c427dea..84d12f0 100644 --- a/imaginairy/img_processors/control_modes.py +++ b/imaginairy/img_processors/control_modes.py @@ -83,46 +83,11 @@ def _create_depth_map_raw(img): return depth_pt -def create_normal_map_old(img): - import cv2 - import numpy as np - import torch - - depth = _create_depth_map_raw(img) - depth = depth[0] - - depth_pt = depth.clone() - depth_pt -= torch.min(depth_pt) - depth_pt /= torch.max(depth_pt) - depth_pt = depth_pt.cpu().numpy() - - bg_th = 0.1 - a = np.pi * 2.0 - depth_np = depth.cpu().float().numpy() - x = cv2.Sobel(depth_np, cv2.CV_32F, 1, 0, ksize=3) - y = cv2.Sobel(depth_np, cv2.CV_32F, 0, 1, ksize=3) - z = np.ones_like(x) * a - x[depth_pt < bg_th] = 0 - y[depth_pt < bg_th] = 0 - normal = np.stack([x, y, z], axis=2) - normal /= np.sum(normal**2.0, axis=2, keepdims=True) ** 0.5 - normal_image = (normal * 127.5 + 127.5).clip(0, 255).astype(np.uint8) - - normal_image = torch.from_numpy(normal_image[:, :, ::-1].copy()).float() / 255.0 - normal_image = normal_image.permute(2, 0, 1) - normal_image = normal_image.unsqueeze(0) - # for use with Controlnet 1.1? - # normal_image = normal_image[:, [1, 0, 2], :, :] - - return normal_image - - def create_normal_map(img): import torch from imaginairy_normal_map.model import create_normal_map_torch_img normal_img_t = create_normal_map_torch_img(img) - # normal_img_t = normal_img_t[:, [1, 2, 0], :, :] normal_img_t -= torch.min(normal_img_t) normal_img_t /= torch.max(normal_img_t)