diff --git a/invokeai/app/invocations/controlnet_image_processors.py b/invokeai/app/invocations/controlnet_image_processors.py index 41344ede8d..c463286261 100644 --- a/invokeai/app/invocations/controlnet_image_processors.py +++ b/invokeai/app/invocations/controlnet_image_processors.py @@ -6,45 +6,30 @@ from typing import Dict, List, Literal, Union import cv2 import numpy as np -from controlnet_aux import ( - CannyDetector, - ContentShuffleDetector, - HEDdetector, - LeresDetector, - LineartAnimeDetector, - LineartDetector, - MediapipeFaceDetector, - MidasDetector, - MLSDdetector, - NormalBaeDetector, - OpenposeDetector, - PidiNetDetector, - SamDetector, - ZoeDetector, -) +from controlnet_aux import (CannyDetector, ContentShuffleDetector, HEDdetector, + LeresDetector, LineartAnimeDetector, + LineartDetector, MediapipeFaceDetector, + MidasDetector, MLSDdetector, NormalBaeDetector, + OpenposeDetector, PidiNetDetector, SamDetector, + ZoeDetector) from controlnet_aux.util import HWC3, ade_palette from PIL import Image -from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator +from pydantic import (BaseModel, ConfigDict, Field, field_validator, + model_validator) from invokeai.app.invocations.primitives import ImageField, ImageOutput -from invokeai.app.invocations.util import validate_begin_end_step, validate_weights -from invokeai.app.services.image_records.image_records_common import ImageCategory, ResourceOrigin +from invokeai.app.invocations.util import (validate_begin_end_step, + validate_weights) +from invokeai.app.services.image_records.image_records_common import ( + ImageCategory, ResourceOrigin) from invokeai.app.shared.fields import FieldDescriptions from invokeai.backend.image_util.depth_anything import DepthAnythingDetector from invokeai.backend.image_util.dwpose import DWPoseDetector from ...backend.model_management import BaseModelType -from .baseinvocation import ( - BaseInvocation, - BaseInvocationOutput, - Input, - InputField, - InvocationContext, - OutputField, - WithMetadata, - invocation, - invocation_output, -) +from .baseinvocation import (BaseInvocation, BaseInvocationOutput, Input, + InputField, InvocationContext, OutputField, + WithMetadata, invocation, invocation_output) CONTROLNET_MODE_VALUES = Literal["balanced", "more_prompt", "more_control", "unbalanced"] CONTROLNET_RESIZE_VALUES = Literal[ @@ -625,7 +610,7 @@ class DepthAnythingImageProcessorInvocation(ImageProcessorInvocation): resolution: int = InputField(default=512, ge=64, multiple_of=64, description=FieldDescriptions.image_res) offload: bool = InputField(default=False) - def run_processor(self, image): + def run_processor(self, image: Image.Image): depth_anything_detector = DepthAnythingDetector() depth_anything_detector.load_model(model_size=self.model_size) diff --git a/invokeai/backend/image_util/dwpose/__init__.py b/invokeai/backend/image_util/dwpose/__init__.py index f25a252a74..133bf05936 100644 --- a/invokeai/backend/image_util/dwpose/__init__.py +++ b/invokeai/backend/image_util/dwpose/__init__.py @@ -34,6 +34,11 @@ def draw_pose(pose, H, W, draw_face=True, draw_body=True, draw_hands=True, resol class DWPoseDetector: + """ + Code from the original implementation of the DWPose Detector. + Credits: https://github.com/IDEA-Research/DWPose + """ + def __init__(self) -> None: self.pose_estimation = Wholebody() diff --git a/invokeai/backend/image_util/dwpose/onnxdet.py b/invokeai/backend/image_util/dwpose/onnxdet.py index 44aca3aac8..3706bb8fa3 100644 --- a/invokeai/backend/image_util/dwpose/onnxdet.py +++ b/invokeai/backend/image_util/dwpose/onnxdet.py @@ -1,3 +1,5 @@ +# Code from the original DWPose Implementation: https://github.com/IDEA-Research/DWPose + import cv2 import numpy as np diff --git a/invokeai/backend/image_util/dwpose/onnxpose.py b/invokeai/backend/image_util/dwpose/onnxpose.py index 871c778ac7..d949f95801 100644 --- a/invokeai/backend/image_util/dwpose/onnxpose.py +++ b/invokeai/backend/image_util/dwpose/onnxpose.py @@ -1,3 +1,5 @@ +# Code from the original DWPose Implementation: https://github.com/IDEA-Research/DWPose + from typing import List, Tuple import cv2 diff --git a/invokeai/backend/image_util/dwpose/utils.py b/invokeai/backend/image_util/dwpose/utils.py index 409e4a9837..2e4d0e7eb9 100644 --- a/invokeai/backend/image_util/dwpose/utils.py +++ b/invokeai/backend/image_util/dwpose/utils.py @@ -1,3 +1,5 @@ +# Code from the original DWPose Implementation: https://github.com/IDEA-Research/DWPose + import math import cv2 diff --git a/invokeai/backend/image_util/dwpose/wholebody.py b/invokeai/backend/image_util/dwpose/wholebody.py index 09d992f9de..23174831c2 100644 --- a/invokeai/backend/image_util/dwpose/wholebody.py +++ b/invokeai/backend/image_util/dwpose/wholebody.py @@ -1,3 +1,6 @@ +# Code from the original DWPose Implementation: https://github.com/IDEA-Research/DWPose +# Modified pathing to suit Invoke + import pathlib import numpy as np