fixed visualizer, fixed mask width/height
parent
5930ba5056
commit
fd7d2ca826
|
|
@ -205,7 +205,7 @@ def findFaces(facecfg, image, width, height, divider, onlyHorizontal, onlyVertic
|
|||
# except cv2.error:
|
||||
# mask = dilated
|
||||
|
||||
if singleMaskPerImage:
|
||||
if singleMaskPerImage and len(binary_masks) > 0:
|
||||
result = []
|
||||
h, w = binary_masks[0].shape
|
||||
result = np.full((h,w), 0, dtype=np.uint8)
|
||||
|
|
@ -587,14 +587,17 @@ class Script(scripts.Script):
|
|||
# if len(masks)==0 and path != '':
|
||||
masks, totalNumberOfFaces, faces_info, skip = findFaces(facecfg, image, width, height, divider, onlyHorizontal, onlyVertical, file=None, totalNumberOfFaces=totalNumberOfFaces, singleMaskPerImage=True, countFaces=False, maskWidth=maskWidth, maskHeight=maskHeight, skip=0)
|
||||
|
||||
mask = masks[0]
|
||||
if len(masks) > 0:
|
||||
mask = masks[0]
|
||||
else:
|
||||
mask = np.zeros((image.height, image.width, 3), dtype=np.uint8)
|
||||
|
||||
# mask = maskResize(mask, maskSize, height)
|
||||
|
||||
mask = Image.fromarray(mask)
|
||||
redImage = Image.new("RGB", (width, height), (255, 0, 0))
|
||||
|
||||
mask.convert("L")
|
||||
mask = mask.convert("L")
|
||||
draw = ImageDraw.Draw(mask, "L")
|
||||
|
||||
if divider > 1:
|
||||
|
|
@ -622,14 +625,17 @@ class Script(scripts.Script):
|
|||
# if len(masks)==0 and path != '':
|
||||
masks, totalNumberOfFaces, faces_info, skip = findFaces(facecfg, image, width, height, divider, onlyHorizontal, onlyVertical, file=None, totalNumberOfFaces=totalNumberOfFaces, singleMaskPerImage=True, countFaces=False, maskWidth=maskWidth, maskHeight=maskHeight, skip=0)
|
||||
|
||||
mask = masks[0]
|
||||
if len(masks) > 0:
|
||||
mask = masks[0]
|
||||
else:
|
||||
mask = np.zeros((image.height, image.width, 3), dtype=np.uint8)
|
||||
|
||||
# mask = maskResize(mask, maskSize, height)
|
||||
|
||||
mask = Image.fromarray(mask)
|
||||
redImage = Image.new("RGB", (width, height), (255, 0, 0))
|
||||
|
||||
mask.convert("L")
|
||||
mask = mask.convert("L")
|
||||
draw = ImageDraw.Draw(mask, "L")
|
||||
|
||||
if divider > 1:
|
||||
|
|
@ -650,14 +656,17 @@ class Script(scripts.Script):
|
|||
# if len(masks)==0 and path != '':
|
||||
masks, totalNumberOfFaces, faces_info, skip = findFaces(facecfg, image, width, height, divider, onlyHorizontal, onlyVertical, file=None, totalNumberOfFaces=totalNumberOfFaces, singleMaskPerImage=True, countFaces=False, maskWidth=maskWidth, maskHeight=maskHeight, skip=0)
|
||||
|
||||
mask = masks[0]
|
||||
if len(masks) > 0:
|
||||
mask = masks[0]
|
||||
else:
|
||||
mask = np.zeros((image.height, image.width, 3), dtype=np.uint8)
|
||||
|
||||
# mask = maskResize(mask, maskSize, height)
|
||||
|
||||
mask = Image.fromarray(mask)
|
||||
redImage = Image.new("RGB", (width, height), (255, 0, 0))
|
||||
|
||||
mask.convert("L")
|
||||
mask = mask.convert("L")
|
||||
draw = ImageDraw.Draw(mask, "L")
|
||||
|
||||
if divider > 1:
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@ def maskResize(mask, maskWidth, maskHeight):
|
|||
|
||||
# Resize the cropped image by percentage
|
||||
height, width = cropped.shape[:2]
|
||||
new_height = max(int(height * maskWidth / 100), 1)
|
||||
new_width = max(int(width * maskHeight / 100), 1)
|
||||
new_height = max(int(height * maskHeight / 100), 1)
|
||||
new_width = max(int(width * maskWidth / 100), 1)
|
||||
resized = cv2.resize(cropped, (new_width, new_height))
|
||||
|
||||
# Create black image with same resolution as original image
|
||||
|
|
|
|||
Loading…
Reference in New Issue