cleanup: remove manual offload from depth anything

This commit is contained in:
blessedcoolant 2024-02-27 20:29:43 +05:30
parent 7cfbe5a62a
commit 6f77477a1c
2 changed files with 3 additions and 7 deletions

View File

@ -576,7 +576,7 @@ DEPTH_ANYTHING_MODEL_SIZES = Literal["large", "base", "small"]
title="Depth Anything Processor",
tags=["controlnet", "depth", "depth anything"],
category="controlnet",
version="1.0.0",
version="1.0.1",
)
class DepthAnythingImageProcessorInvocation(ImageProcessorInvocation):
"""Generates a depth map based on the Depth Anything algorithm"""
@ -585,13 +585,12 @@ class DepthAnythingImageProcessorInvocation(ImageProcessorInvocation):
default="small", description="The size of the depth model to use"
)
resolution: int = InputField(default=512, ge=64, multiple_of=64, description=FieldDescriptions.image_res)
offload: bool = InputField(default=False)
def run_processor(self, image: Image.Image):
depth_anything_detector = DepthAnythingDetector()
depth_anything_detector.load_model(model_size=self.model_size)
processed_image = depth_anything_detector(image=image, resolution=self.resolution, offload=self.offload)
processed_image = depth_anything_detector(image=image, resolution=self.resolution)
return processed_image

View File

@ -84,7 +84,7 @@ class DepthAnythingDetector:
self.model.to(device)
return self
def __call__(self, image, resolution=512, offload=False):
def __call__(self, image, resolution=512):
image = np.array(image, dtype=np.uint8)
image = image[:, :, ::-1] / 255.0
@ -103,7 +103,4 @@ class DepthAnythingDetector:
new_height = int(image_height * (resolution / image_width))
depth_map = depth_map.resize((resolution, new_height))
if offload:
del self.model
return depth_map