Skip to content

FiftyOne Computer Vision Tips and Tricks – Aug 4, 2023

Welcome to our weekly FiftyOne tips and tricks blog where we recap interesting questions and answers that have recently popped up on Slack, GitHub, Stack Overflow, and Reddit.

As an open source community, the FiftyOne community is open to all. This means everyone is welcome to ask questions, and everyone is welcome to answer them. Continue reading to see the latest questions asked and answers provided!

Wait, what’s FiftyOne?

FiftyOne is an open source machine learning toolset that enables data science teams to improve the performance of their computer vision models by helping them curate high quality datasets, evaluate models, find mistakes, visualize embeddings, and get to production faster.

Ok, let’s dive into this week’s tips and tricks!

Adding new label fields and mapping them to super categories

Community Slack member Sabrina asked:

“I have a COCO dataset with super categories. Is there an easy way to add a new label field which will just remap the original label to the super category? For example, I have annotations labeled by species, but want to remap them all to genus level. I was thinking of duplicating the current label field then map_labels,  but I can’t figure out how to duplicate ground_truth. Do I have to iterate through every sample?”

An option is to use clone_sample_field(), which clones the given sample field into a new field of the dataset.

Choosing a dataset type for instance segmentation

Community Slack member Namrata asked:

“I’m trying out instance segmentation in FiftyOne and I have a dataset of images in jpg format along with their masks and labels. What dataset type would be appropriate for this? ImageSegmentationDirectory seems to be the most appropriate, but there doesn’t seem to be a way to upload the labels.”

Outside of the FiftyOneDataset format, COCODetectionDataset is a good option. The ImageSegmentationDirectory format is for segmentation labels only (with respect to the entire image).

It’s also worth checking out the instance segmentation with SAM part in the Jacob Marks’ article, “See What You Segment with SAM” for reference. You can also checkout this Football Player Segmentation notebook that steps of loading the dataset using COCODetectionDataset and doing instance segmentation.

Reducing the number of images returned

Community Slack member Kornelia asked:

“I’m trying to investigate what is wrong with keypoint annotations for some images. I want to restrict my view of images to those for which I kept annotations. Is that possible? Currently, I see all images regardless of them having annotations. I tried to look for something in the FiftyOne App to hide them, but with no success.”

You can try something like this:

ds = foz.load_zoo_dataset("quickstart", max_samples=10)
ds.match(F("ground_truth.detections").length() > 0)

Check out the FiftyOne Docs to learn more about how to load datasets and the available options.

Adding keypoint skeletons based on sample attributes

Community Slack member Kornelia asked:

“Is it possible to add different keypoint skeletons based on whether a picture was taken from a front or rear view?”

If you’re willing to store the keypoints with different skeletons in different label fields, then you can provide separate skeletons for each field like so:

dataset.skeletons["field1"] = skeleton1
dataset.skeletons["field2"] = skeleton2

Check out the FiftyOne Docs to learn more about storing kepoint skeletons.

Merging datasets and renaming labels

Community Slack member Aaditya asked:

“I’d like to merge two datasets and rename the label of one of those. How do I go about that?”

Depending on your exact use case, two approaches to consider:

First, you can use merge_samples() to merge the samples from one dataset into another.

Second, you could rename a field with rename_sample_field().

Join the FiftyOne community!

Join the thousands of engineers and data scientists already using FiftyOne to solve some of the most challenging problems in computer vision today!