voxel51 / fiftyone

The open-source tool for building high-quality datasets and computer vision models
https://fiftyone.ai
Apache License 2.0
7.89k stars 518 forks source link

[BUG]The bbox pixel coordinate is less than 0, causing the mask to not be displayed. #4421

Open ailihong opened 1 month ago

ailihong commented 1 month ago

Describe the problem

The bbox pixel coordinate is less than 0, causing the mask to not be displayed.

Code to reproduce issue

dataset = fo.Dataset.from_dir( dataset_type=fo.types.COCODetectionDataset, data_path=args.image_path, labels_path=args.coco_json_gt, label_field="ground_truth", label_types=["segmentations"] ) session = fo.launch_app(dataset, port=args.port, remote=True) session.wait()

# commands and/or screenshots here

The local visualization effect of the segmentation results is as follows 2024-05-24 19-13-31屏幕截图

The segmentation results are visualized on the web as follows. Note that the leftmost object is missing. 2024-05-24 19-13-54屏幕截图

System information

Other info/logs

Suggestion: The _coco_segmentation_to_mask function in python3.8/site-packages/fiftyone/utils/coco.py should check the validity of the coordinate value of the bbox as below:

x = max(0, min(x, width-1)) y = max(0, min(y, height-1))

Willingness to contribute

The FiftyOne Community encourages bug fix contributions. Would you or another member of your organization be willing to contribute a fix for this bug to the FiftyOne codebase?