fix: zero object detection error (#64)
* update dockerfile * fix: zero object detection error * fix: zero object detection error
This commit is contained in:
@@ -84,6 +84,25 @@ class MaskDictionaryModel:
|
||||
iou = intersection / union
|
||||
return iou
|
||||
|
||||
|
||||
def save_empty_mask_and_json(self, mask_data_dir, json_data_dir, image_name_list=None):
|
||||
mask_img = torch.zeros((self.mask_height, self.mask_width))
|
||||
if image_name_list:
|
||||
for image_base_name in image_name_list:
|
||||
image_base_name = image_base_name.split(".")[0]+".npy"
|
||||
mask_name = "mask_"+image_base_name
|
||||
np.save(os.path.join(mask_data_dir, mask_name), mask_img.numpy().astype(np.uint16))
|
||||
|
||||
json_data_path = os.path.join(json_data_dir, mask_name.replace(".npy", ".json"))
|
||||
print("save_empty_mask_and_json", json_data_path)
|
||||
self.to_json(json_data_path)
|
||||
else:
|
||||
np.save(os.path.join(mask_data_dir, self.mask_name), mask_img.numpy().astype(np.uint16))
|
||||
json_data_path = os.path.join(json_data_dir, self.mask_name.replace(".npy", ".json"))
|
||||
print("save_empty_mask_and_json", json_data_path)
|
||||
self.to_json(json_data_path)
|
||||
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
"mask_name": self.mask_name,
|
||||
|
Reference in New Issue
Block a user