Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RGBA images throwing error in txt2mask #35

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions shortcodes/stable_diffusion/txt2mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def run_block(self, pargs, kwargs, context, content):
from matplotlib import pyplot as plt
import cv2
import numpy
from modules.images import flatten
from modules.shared import opts

brush_mask_mode = self.Unprompted.parse_advanced(kwargs["mode"],context) if "mode" in kwargs else "add"
self.show = True if "show" in pargs else False
Expand Down Expand Up @@ -99,7 +101,8 @@ def get_mask():
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
transforms.Resize((512, 512)),
])
img = transform(self.Unprompted.shortcode_user_vars["init_images"][0]).unsqueeze(0)
flattened_input = flatten(self.Unprompted.shortcode_user_vars["init_images"][0], opts.img2img_background_color)
img = transform(flattened_input).unsqueeze(0)

# predict
with torch.no_grad():
Expand Down Expand Up @@ -162,4 +165,4 @@ def after(self,p=None,processed=None):
processed.images.append(self.image_mask)
self.image_mask = None
self.show = False
return processed
return processed