Search before asking
Bug
Hi
I'm working with an object detection dataset in RoboFlow and getting segmentation masks to apply image segmentation. I'm trying to modify the dataset's annotations by applying SAM model and a custom function (most of the code has been written from RoboFlow notebook snippets). However, when I tried to save the coco annotations file using as_coco function, it isn't saving for me as expected. I tried testing it like this: after as_coco, use from_coco and compare the Detectiondataset objects before as_coco and after as_coco. It turned out to be False.
I went through supervision community posts but couldn't find any ones related to my issue.
Can you please verify if this is a bug? Or am I missing something here?
Attached code snippets and output result for reference.


Environment
- Supervision: 0.14.0
- VS Code
- Windows 11
- Python: 3.11.1
Minimal Reproducible Example
object_detection_dataset = sv.DetectionDataset.from_coco(
images_directory_path=IMAGES_DIRECTORY_PATH,
annotations_path=ANNOTATIONS_FILE_PATH
)
image_names = list(object_detection_dataset.images.keys())
for image_name in image_names:
time_img_start = time.time()
# Process the image and annotations here
# detection = detections[image_name]
object_detection_dataset.annotations[image_name].mask = segment(sam_predictor=sam_predictor, image=cv2.imread(image_name, cv2.COLOR_BGR2RGB),xyxy=object_detection_dataset.annotations[image_name].xyxy)
time_img_end = time.time()
image_name = image_name.replace(IMAGES_DIRECTORY_PATH + "\\", "")
print(image_name + " processing time: " + str(time_img_end - time_img_start) + " secs")
print(sys.getsizeof(object_detection_dataset))
times[DATA_SET_SUBDIRECTORY][image_name] = time_img_end - time_img_start
break
object_detection_dataset.as_coco(annotations_path=ANNOTATIONS_FILE_PATH, images_directory_path=None)
object_detection_dataset1 = sv.DetectionDataset.from_coco(
images_directory_path=IMAGES_DIRECTORY_PATH,
annotations_path=ANNOTATIONS_FILE_PATH
)
print("************************************************************")
print(object_detection_dataset == object_detection_dataset1)
Additional
No response
Are you willing to submit a PR?
Search before asking
Bug
Hi
I'm working with an object detection dataset in RoboFlow and getting segmentation masks to apply image segmentation. I'm trying to modify the dataset's annotations by applying SAM model and a custom function (most of the code has been written from RoboFlow notebook snippets). However, when I tried to save the coco annotations file using as_coco function, it isn't saving for me as expected. I tried testing it like this: after as_coco, use from_coco and compare the Detectiondataset objects before as_coco and after as_coco. It turned out to be False.
I went through supervision community posts but couldn't find any ones related to my issue.
Can you please verify if this is a bug? Or am I missing something here?
Attached code snippets and output result for reference.


Environment
Minimal Reproducible Example
Additional
No response
Are you willing to submit a PR?