![]() |
![]() |
![]() |
Albumentations Integration for Anomaly Detection#
In this notebook, we will explore FiftyOne’s integration with Albumentations, a powerful image augmentation library. Augmentations can significantly enhance anomaly detection models by improving robustness and generalization.

Learning Objectives:#
Understand the importance of data augmentation for anomaly detection.
Use Albumentations to apply transformations to datasets in FiftyOne.
Explore different augmentation techniques for improving model performance.
Why Use Augmentations for Anomaly Detection?#
Anomaly detection models often struggle due to limited data availability and environmental variations. Data augmentation helps by:
Simulating real-world variations (e.g., lighting changes, noise, blur).
Increasing dataset diversity, reducing overfitting.
Improving model robustness to unseen conditions.
Albumentations allows us to apply realistic transformations, such as:
Brightness and contrast adjustments (simulate different lighting conditions).
Color jittering (alter hue, saturation, and intensity).
Gaussian noise, blur, and distortions (improve generalization).
Relevant Documentation:
[ ]:
!pip install -U albumentations==1.4.24
[ ]:
!fiftyone plugins download https://github.com/jacobmarks/fiftyone-albumentations-plugin
[ ]:
import fiftyone as fo
import fiftyone.utils.huggingface as fouh # Hugging Face integration
# Define the new dataset name
dataset_name = "MVTec_AD_Aug"
# Check if the dataset exists
if dataset_name in fo.list_datasets():
print(f"Dataset '{dataset_name}' exists. Loading...")
dataset = fo.load_dataset("MVTec_AD_Aug")
else:
print(f"Dataset '{dataset_name}' does not exist. Creating a new one...")
# Clone the dataset with a new name and make it persistent
dataset_ = fo.load_dataset("MVTec_AD")
dataset = dataset_.clone(dataset_name, persistent=True)
[ ]:
# Try this for already loaded dataset
# dataset = fo.load_dataset('mvtec-ad-staging')
OBJECTS_LIST = [
'pill',
'zipper',
'tile',
'bottle',
'transistor',
'wood',
'cable',
'capsule',
'carpet',
'grid',
'hazelnut',
'leather',
'metal_nut',
'screw',
'toothbrush'
]
OBJECT = "screw" ## object to select
[ ]:
from fiftyone import ViewField as F # helper for defining views
# Define the new dataset name for split set
dataset_name_split = "mvtec-screw"
if dataset_name_split in fo.list_datasets():
print(f"Dataset '{dataset_name_split}' exists. Loading...")
mvtec_screw = fo.load_dataset(dataset_name_split)
else:
print(f"Dataset '{dataset_name_split}' does not exist. Creating a new one...")
## get the test split of the dataset
test_split = dataset.match(F("category.label") == 'screw')
# Clone the dataset into a new one called "mvtec_bottle"
mvtec_screw = test_split.clone("mvtec-screw", persistent=True)
[ ]:
print(mvtec_screw)
[ ]:
session = fo.launch_app(mvtec_screw, port=5156, auto=False)
How to manipulate Plugins#
Here is a guide you can follow to check your plugins, enable, disable or delete those.