Skip to content

Repeated initialization for "binay_masks" in inference.py #48

@ghost-ttt5

Description

@ghost-ttt5

In inference.py, "binay_masks" should be a list used to store binary masks.
It is firstly initialized when reading the binary masks from the json file.

binay_masks = []
# class_names = []
instance_captions = []
points_list = []
scribbles_list = []
prompt = data['caption']
crop_mask_image = False
for inst_idx in range(len(data['annos'])):
if "mask" not in data['annos'][inst_idx] or data['annos'][inst_idx]['mask'] == []:
instance_mask = np.zeros((512,512,1))
else:
instance_mask = decodeToBinaryMask(data['annos'][inst_idx]['mask'])
if crop_mask_image:
# crop the instance_mask to 512x512, centered at the center of the instance_mask image
# get the center of the instance_mask
center = np.array([instance_mask.shape[0]//2, instance_mask.shape[1]//2])
# get the top left corner of the crop
top_left = center - np.array([256, 256])
# get the bottom right corner of the crop
bottom_right = center + np.array([256, 256])
# crop the instance_mask
instance_mask = instance_mask[top_left[0]:bottom_right[0], top_left[1]:bottom_right[1]]
binay_masks.append(instance_mask)
data['width'] = 512
data['height'] = 512
else:
binay_masks.append(instance_mask)

But in the process of handling the missing binary masks, the "binay_masks" is initialized again. This would appear to cause previously read masks to be discarded, and subsequent steps that rely on binay_masks will use zero masks.

# get binary masks for each instance, if not provided, use all zeros
binay_masks = []
for i in range(len(locations) - len(binay_masks)):
binay_masks.append(np.zeros((512,512,1)))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions