change controlnet depth preprocessor
This commit is contained in:
parent
dfcb9017f1
commit
a869982d13
@ -93,8 +93,9 @@ class ControlNet(DiffusionInpaintModel):
|
|||||||
model_info.path,
|
model_info.path,
|
||||||
controlnet=controlnet,
|
controlnet=controlnet,
|
||||||
load_safety_checker=not disable_nsfw_checker,
|
load_safety_checker=not disable_nsfw_checker,
|
||||||
|
torch_dtype=torch_dtype,
|
||||||
**model_kwargs,
|
**model_kwargs,
|
||||||
).to(torch_dtype)
|
)
|
||||||
else:
|
else:
|
||||||
self.model = handle_from_pretrained_exceptions(
|
self.model = handle_from_pretrained_exceptions(
|
||||||
PipeClass.from_pretrained,
|
PipeClass.from_pretrained,
|
||||||
|
@ -23,11 +23,9 @@ def make_openpose_control_image(image: np.ndarray) -> Image:
|
|||||||
|
|
||||||
|
|
||||||
def make_depth_control_image(image: np.ndarray) -> Image:
|
def make_depth_control_image(image: np.ndarray) -> Image:
|
||||||
from transformers import pipeline
|
from controlnet_aux import MidasDetector
|
||||||
|
midas = MidasDetector.from_pretrained("lllyasviel/Annotators")
|
||||||
depth_estimator = pipeline("depth-estimation")
|
depth_image = midas(image)
|
||||||
depth_image = depth_estimator(PIL.Image.fromarray(image))["depth"]
|
|
||||||
depth_image = np.array(depth_image)
|
|
||||||
depth_image = depth_image[:, :, None]
|
depth_image = depth_image[:, :, None]
|
||||||
depth_image = np.concatenate([depth_image, depth_image, depth_image], axis=2)
|
depth_image = np.concatenate([depth_image, depth_image, depth_image], axis=2)
|
||||||
control_image = PIL.Image.fromarray(depth_image)
|
control_image = PIL.Image.fromarray(depth_image)
|
||||||
|
Loading…
Reference in New Issue
Block a user