inpaint ini
This commit is contained in:
+3
-3
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user