inpaint ini

This commit is contained in:
lllyasviel
2024-01-30 13:15:57 -08:00
parent 7b0a202f89
commit 01dfe3ac49
4 changed files with 18 additions and 14 deletions
@@ -6,7 +6,7 @@ from typing import List, Optional, Union, Callable, Dict, Tuple, Literal
from dataclasses import dataclass
import numpy as np
from lib_controlnet.utils import svg_preprocess, read_image
from lib_controlnet.utils import svg_preprocess, read_image, judge_image_type
from lib_controlnet import (
global_state,
external_code,
@@ -935,9 +935,9 @@ class ControlNetUiGroup(object):
else None,
)
is_image = isinstance(result, np.ndarray) and result.ndim == 3 and result.shape[2] < 5
is_hwc, is_png = judge_image_type(result)
if not is_image:
if not is_hwc:
result = img
result = external_code.visualize_inpaint_mask(result)
@@ -408,3 +408,9 @@ def crop_and_resize_image(detected_map, resize_mode, h, w):
detected_map = detected_map[pad_h:pad_h+h, pad_w:pad_w+w]
detected_map = safe_numpy(detected_map)
return detected_map
def judge_image_type(img):
is_image_hw3or4 = isinstance(img, np.ndarray) and img.ndim == 3 and int(img.shape[2]) in [3, 4]
is_png = is_image_hw3or4 and int(img.shape[2]) == 4
return is_image_hw3or4, is_png