Skip to main content

Setting Up

You can follow along this tutorial by running this notebook on Google Colab. First, install fastdup with:
bash
And verify the installation.
Python
This tutorial runs on version 0.906.

Download Dataset

We will be analyzing the Imagenette dataset - A 10-class ImageNet subset from fast.ai. Imagenette consists of 10 classes from the original ImageNet dataset. It contains 13k images in total. Download and extract dataset:
shell
Once done you should have a folder with the following structure.
📘 Naming
  • noisy_imagenette.csv - A .csv files with labels.
  • train/ - Train images.
  • val/ - validation images.

Load & Format Annotations

We’ll use pandas to load and format the annotations.
As ImageNet uses codes for classes, we’ll map them to their human readable values for ease of analysis (source):
Let’s load the annotations.
pathnoisy_labels_0noisy_labels_1noisy_labels_5noisy_labels_25noisy_labels_50is_valid
0train/n02979186/n02979186_9036.JPEGn02979186n02979186n02979186n02979186n02979186False
1train/n02979186/n02979186_11957.JPEGn02979186n02979186n02979186n02979186n03000684False
2train/n02979186/n02979186_9715.JPEGn02979186n02979186n02979186n03417042n03000684False
Transform the annotation into a format expected by fastdup.
img_filenamelabelsplit
0train/n02979186/n02979186_9036.JPEGcassette_playertrain
1train/n02979186/n02979186_11957.JPEGcassette_playertrain
2train/n02979186/n02979186_9715.JPEGcassette_playertrain
3train/n02979186/n02979186_21736.JPEGcassette_playertrain
4train/n02979186/ILSVRC2012_val_00046953.JPEGcassette_playertrain

Run fastdup

With the annotations and folders in the right format, let’s run fastdup and analyze the dataset.
📘 Info
  • ccthreshold - Threshold to use for the graph connected component. Default is 0.96.
  • threshold - Threshold to use for the graph generation. Default is 0.9.
Get a summary of the run.
🚧 830 possible outliers From the summary there are 830 possible outliers found. Let’s inspect them further!

Outliers

Let’s visualize the outliers in the dataset.
📘 Label information Note the label information in the outliers report.
👍 Anomalies? Can you spot any anomalies from the report? Hint - parachute and golf ball.
To get more details on the outliers, run:
indexoutliernearestdistanceimg_filename_outlierlabel_outliersplit_outliererror_code_outlieris_valid_outlierimg_filename_nearestlabel_nearestsplit_nearesterror_code_nearestis_valid_nearest
013381200917570.469904val/n03417042/n03417042_29412.JPEGgarbage_truckvalVALIDTruetrain/n02102040/n02102040_7256.JPEGEnglish_springertrainVALIDTrue
11336266497630.476124train/n02979186/n02979186_3967.JPEGcassette_playertrainVALIDTrueval/n01440764/n01440764_710.JPEGtenchvalVALIDTrue
21335272715710.476313train/n02979186/n02979186_5424.JPEGcassette_playertrainVALIDTruetrain/n02102040/n02102040_536.JPEGEnglish_springertrainVALIDTrue
313331217218170.479290val/n03417042/n03417042_91.JPEGgarbage_truckvalVALIDTruetrain/n02102040/n02102040_7868.JPEGEnglish_springertrainVALIDTrue
413321981100980.479516train/n02979186/n02979186_10387.JPEGcassette_playertrainVALIDTrueval/n02102040/n02102040_5272.JPEGEnglish_springervalVALIDTrue

Similarity Gallery

Other than the outliers, we can find possible mislabels by comparing a query image to other images in the dataset. This can be done with:
To get a detailed information
fromtodistanceimg_filename_fromlabel_fromsplit_fromerror_code_fromis_valid_fromimg_filename_tolabel_tosplit_toerror_code_tois_valid_to
01152153900.968786val/n03394916/n03394916_30631.JPEGFrench_hornvalVALIDTruetrain/n03394916/n03394916_44127.JPEGFrench_horntrainVALIDTrue
15390115210.968786train/n03394916/n03394916_44127.JPEGFrench_horntrainVALIDTrueval/n03394916/n03394916_30631.JPEGFrench_hornvalVALIDTrue
21291477150.962458val/n03445777/n03445777_6882.JPEGgolf_ballvalVALIDTruetrain/n03445777/n03445777_13918.JPEGgolf_balltrainVALIDTrue
37715129140.962458train/n03445777/n03445777_13918.JPEGgolf_balltrainVALIDTrueval/n03445777/n03445777_6882.JPEGgolf_ballvalVALIDTrue
4111714040.953837train/n02102040/n02102040_1564.JPEGEnglish_springertrainVALIDTruetrain/n02102040/n02102040_3837.JPEGEnglish_springertrainVALIDTrue

Duplicates

Let’s also check for duplicate pairs.

Image Clusters

You can also visualize clusters with specific labels using the slice parameter. For example let’s visualize clusters with the chain_saw label.

Summary

👍 We now added several important label-specific features to run on top of the raw dataset Building over the image dataset analysis conducted without labels in the Cleaning and preparing a dataset tutorial, we’ve seen how to further slice the data and visualize specific classes of interest.