From db0493a34b0615f8e2b269dabc88b3d09fcf819f Mon Sep 17 00:00:00 2001 From: Jedrzej Kosinski Date: Fri, 22 Dec 2023 11:44:57 -0600 Subject: [PATCH] Make it clear Sparse RGB preproc output cannot be used for anything but Apply ControlNet nodes --- control/control_sparsectrl.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/control/control_sparsectrl.py b/control/control_sparsectrl.py index 41698b4..d423872 100644 --- a/control/control_sparsectrl.py +++ b/control/control_sparsectrl.py @@ -80,14 +80,35 @@ class SparseControlNet(ControlNetCLDM): class PreprocSparseRGBWrapper: + error_msg = "Invalid use of RGB SparseCtrl output. The output of RGB SparseCtrl preprocessor is NOT a usual image, but a latent pretending to be an image - you must connect the output directly to an Apply ControlNet node (advanced or otherwise). It cannot be used for anything else that accepts IMAGE input." def __init__(self, condhint: Tensor): self.condhint = condhint def movedim(self, *args, **kwargs): return self - def __getattr__(self, name): - raise AttributeError("Invalid use of RGB SparseCtrl output. The output of RGB SparseCtrl preprocessor is NOT a usual image, but a latent pretending to be an image - you must connect the output directly to an Apply ControlNet node (advanced or otherwise).") + def __getattr__(self, *args, **kwargs): + raise AttributeError(self.error_msg) + + def __setattr__(self, name, value): + if name != "condhint": + raise AttributeError(self.error_msg) + super().__setattr__(name, value) + + def __iter__(self, *args, **kwargs): + raise AttributeError(self.error_msg) + + def __next__(self, *args, **kwargs): + raise AttributeError(self.error_msg) + + def __len__(self, *args, **kwargs): + raise AttributeError(self.error_msg) + + def __getitem__(self, *args, **kwargs): + raise AttributeError(self.error_msg) + + def __setitem__(self, *args, **kwargs): + raise AttributeError(self.error_msg) class SparseSettings: