elegant patcher

This commit is contained in:
lllyasviel
2024-02-02 00:34:18 -08:00
parent b944aa9242
commit da6041dd93
2 changed files with 5 additions and 3 deletions

View File

@@ -62,9 +62,8 @@ class PreprocessorMarigold(Preprocessor):
)
with torch.no_grad():
img = numpy_to_pytorch(input_image).movedim(-1, 1).to(
device=self.diffusers_patcher.patcher.current_device,
dtype=self.diffusers_patcher.dtype)
img = numpy_to_pytorch(input_image).movedim(-1, 1)
img = self.diffusers_patcher.move_tensor_to_current_device(img)
img = img * 2.0 - 1.0
depth = self.diffusers_patcher.pipeline(img, num_inference_steps=20, show_pbar=False)

View File

@@ -46,3 +46,6 @@ class DiffusersModelPatcher:
models=[self.patcher],
memory_required=inference_memory
)
def move_tensor_to_current_device(self, x):
return x.to(device=self.patcher.current_device, dtype=self.dtype)