Spaces:
Runtime error
Runtime error
File size: 987 Bytes
f2dbf59 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
from ..utils import common_annotator_call, create_node_input_types
import comfy.model_management as model_management
import numpy as np
class MIDAS_Depth_Map_Preprocessor:
@classmethod
def INPUT_TYPES(s):
return create_node_input_types(
a = ("FLOAT", {"default": np.pi * 2.0, "min": 0.0, "max": np.pi * 5.0, "step": 0.05}),
bg_threshold = ("FLOAT", {"default": 0.1, "min": 0, "max": 1, "step": 0.05})
)
RETURN_TYPES = ("IMAGE",)
FUNCTION = "execute"
CATEGORY = "tbox/ControlNet Preprocessors"
def execute(self, image, a, bg_threshold, resolution=512, **kwargs):
from midas import MidasDetector
# Ref: https://github.com/lllyasviel/ControlNet/blob/main/gradio_depth2image.py
model = MidasDetector.from_pretrained().to(model_management.get_torch_device())
out = common_annotator_call(model, image, resolution=resolution, a=a, bg_th=bg_threshold)
del model
return (out, )
|