Closed Loerbri closed 5 years ago
--input_json_file "panoptic_train2017.json" --segmentations_folder "stuff_train2017_pixelmaps" --output_json_file "my_folder" --categories_json_file "~/panopticapi/panoptic_coco_categories.json" --things_only
Your argument is things only but your segmentation PNG's are for stuff. Perhaps this is the issue?
If so set your segmentations_folder to the results of unzipping the panoptic_train2017.zip file.
Another guess would be to adjust the popping of the color category attribute here:
for category in d_coco['categories']:
if things_only and category['isthing'] != 1:
continue
category.pop('isthing')
try:
category.pop('color')
except:
pass
categories_coco_detection.append(category)
d_coco['categories'] = categories_coco_detection
The key error at this point in time indicates to me there is no need to remove the 'color' key of the current category dictionary. Thus I wrapped it in a try / except block.
Thank you very much. I was indeed reading from the wrong segmentation folder.
i meet another problem int panoptic2detection_coco_format.py funtion : convert_panoptic_to_detection_coco_format()
as follow:
with open(output_json_file, 'w') as f:
json.dump(d_coco, f)
display error:
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: b'0b7i51O001O1O1O2N4L2N00000000000000N2N2M3N200O100
i use python3.5 ; i have looked up some information and didn't solve it ; can you help ? thanks!
I'm not sure about this but try json.dumps(dcoco). dumps is for strings I believe: https://realpython.com/python-json/
i meet another problem int
panoptic2detection_coco_format.py funtion : convert_panoptic_to_detection_coco_format()
as follow:with open(output_json_file, 'w') as f: json.dump(d_coco, f)
display error:
raise TypeError(repr(o) + " is not JSON serializable") TypeError: b'0b7i51O001O1O1O2N4L2N00000000000000N2N2M3N200O100
i use python3.5 ; i have looked up some information and didn't solve it ; can you help ? thanks!
'counts' is returned as binary in Python 3, decode it into a UTF8 string
for segm_info in annotation['segments_info']:
if things_only and categories[segm_info['category_id']]['isthing'] != 1:
continue
mask = (pan == segm_info['id']).astype(np.uint8)
mask = np.expand_dims(mask, axis=2)
mask=COCOmask.encode(np.asfortranarray(mask))[0]
# 'counts' is returned as binary in Python 3, decode it into a UTF8 string
mask['counts'] = mask['counts'].decode('utf8')
segm_info.pop('id')
segm_info['image_id'] = annotation['image_id']
segm_info['segmentation'] = mask
annotations_detection.append(segm_info)
When running the script with the following arguments:
I get the following error:
I tried to remove the [0] in the line
segm_info['segmentation'] = COCOmask.encode(np.asfortranarray(mask))[0]
which resulted inlater on. Any help would be much appreciated.