From 5e87062cf809a08242d3b006b66d3bbb834ddb16 Mon Sep 17 00:00:00 2001 From: spezialspezial <75758219+spezialspezial@users.noreply.github.com> Date: Wed, 2 Nov 2022 00:21:27 +0100 Subject: [PATCH] Option to directly invert the grayscale heatmap - fix --- ldm/invoke/txt2mask.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ldm/invoke/txt2mask.py b/ldm/invoke/txt2mask.py index a5deec277a..aedf4399d6 100644 --- a/ldm/invoke/txt2mask.py +++ b/ldm/invoke/txt2mask.py @@ -44,7 +44,7 @@ class SegmentedGrayscale(object): self.image = image def to_grayscale(self,invert:bool=False)->Image: - return self._rescale(Image.fromarray(np.uint8((255 if invert else 0) - self.heatmap * 255))) + return self._rescale(Image.fromarray(np.uint8(255 - self.heatmap * 255 if invert else self.heatmap * 255))) def to_mask(self,threshold:float=0.5)->Image: discrete_heatmap = self.heatmap.lt(threshold).int()