Closed samhodge-aiml closed 2 years ago
Inserting
height, width = mask.shape[:2]
if height == 0:
return
if width == 0:
return
fiftyone/core/labels.py
at line 1223
fixes the issue.
Once the fix is applied there are ground truth labels that are not person
see images attached
Hi @samhodge-aiml 👋
Good catch on the error, looks like there needs to be some error handling inserted when an object has a mask
with zero pixels.
The second part is expected behavior. By default classes=["person"]
means to only load images that contain at least one person
, but to load all boxes that exist in those images. If you really only want the person
boxes, you can include the optional only_matching=True
parameter documented here.
Alternatively, you can use filter_labels() to export only the person
boxes from the full dataset.
import fiftyone as fo
import fiftyone.zoo as foz
from fiftyone import ViewField as F
#
# Option 1: only load `person` boxes initially
#
dataset = foz.load_zoo_dataset(
"coco-2017",
split="train",
classes=["person"],
label_types=["segmentations"],
only_matching=True,
shuffle=True,
max_samples=8000,
)
print(dataset.count_values("ground_truth.detections.label"))
# {'person': 33416}
dataset.export(...)
#
# Option 2: load all labels initially, but filter for the export
#
dataset = foz.load_zoo_dataset(
"coco-2017",
split="train",
classes=["person"],
label_types=["segmentations"],
shuffle=True,
max_samples=8000,
)
print(dataset.count_values("ground_truth.detections.label"))
# {'apple': 194, 'toaster': 6, ..., 'person': 33416, ...}
view = dataset.filter_labels("ground_truth", F("label") == "person")
print(view.count_values("ground_truth.detections.label"))
# {'person': 33416}
view.export(...)
Very cool, thanks for the tutorial. I have to switch context to another project but can get back to this in either 12 or 24 hours.
Thanks a million 🎉
This is fixed by https://github.com/voxel51/eta/pull/569 and will be resolved in fiftyone>=0.17
.
Thanks
Instructions
Thank you for submitting an issue. Please refer to our issue policy for information on what types of issues we address.
Please fill in this template to ensure a timely and thorough response.
System information
fiftyone --version
): FiftyOne v0.16.6, Voxel51, Inc.Commands to reproduce
As thoroughly as possible, please provide the Python and/or shell commands used to encounter the issue. Application steps can be described in the next section.
make_data.py
Describe the problem
OpenCV error occurs
Code to reproduce issue
As above
As thoroughly as possible, please provide the Python and/or shell commands used to encounter the issue. Application steps can be described in the next section.
make_data.py
Other info / logs
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached. Please do not use screenshots for sharing text. Code snippets should be used instead when providing tracebacks, logs, etc.
What areas of FiftyOne does this bug affect?
App
: FiftyOne application issueCore
: Corefiftyone
Python library issueServer
: Fiftyone server issueWillingness 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?
Fix seems easy enough, just test to see if
mask
has non zero sizes before making the call, else return a blank image.