This directory contains sample datasets for training defect detection models with the Defect Detection Application (DDA).
This guide covers setup for both Cookie and Alien datasets, including uploading to S3 and generating manifests.
Each dataset includes helper scripts:
upload_dataset.py- Uploads dataset images/masks to S3generate_manifest.py- Generates manifest files locally (classification and segmentation)
The typical workflow for each dataset is:
- Upload Dataset - Use
upload_dataset.pyto upload images/masks to S3 - Generate Manifests - Use
generate_manifest.pyto create manifest files locally - Upload Manifests - Manually upload generated manifests to S3
- Register in Portal - Register the dataset in DDA Portal using the S3 manifest URI
- Transform Manifest (if needed) - Portal automatically detects Ground Truth format and offers transformation
- Train Model - Use the registered dataset to train a model
The generate_manifest.py script supports two manifest formats:
- Use Case: Testing the transformation workflow in the portal
- Attributes: Job-specific names like
cookie-classification,cookie-segmentation-ref - Transformation: Portal will detect Ground Truth format and offer "Transform Manifest Now" button
- Command:
python3 generate_manifest.py s3://bucket/path/ --task both(default format)
- Use Case: Ready for training without transformation
- Attributes: Standardized names like
anomaly-label,anomaly-mask-ref - Transformation: Not needed - manifests are production-ready
- Command:
python3 generate_manifest.py s3://bucket/path/ --task both --format dda
When you register a Ground Truth format manifest in the portal:
- Portal detects the Ground Truth format (job-specific attribute names)
- A warning alert appears with "Transform Manifest Now" button
- Click the button to transform the manifest to DDA format
- Transformed manifest is automatically used for training
Transformation Details:
- Renames
{job-name}→anomaly-label - Renames
{job-name}-metadata→anomaly-label-metadata - Renames
{job-name}-ref→anomaly-mask-ref(for segmentation) - Renames
{job-name}-ref-metadata→anomaly-mask-ref-metadata(for segmentation) - Updates
job-namefields in metadata to match new attribute names
The Cookie Dataset is organized as follows:
cookie-dataset/
├── dataset-files/
│ ├── training-images/ # Training images (JPG)
│ │ ├── normal-1.jpg
│ │ ├── normal-2.jpg
│ │ ├── anomaly-1.jpg
│ │ └── anomaly-2.jpg
│ └── mask-images/ # Segmentation masks (PNG) - same filenames as images
│ ├── normal-1.png
│ ├── normal-2.png
│ ├── anomaly-1.png
│ └── anomaly-2.png
├── upload_dataset.py
└── generate_manifest.py
cd datasets/cookie-dataset
# Create bucket
ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
BUCKET="dda-cookie-dataset-${ACCOUNT_ID}"
aws s3 mb s3://${BUCKET}
# Step 1: Upload dataset images AND masks to S3
# This uploads both training-images/ and mask-images/ directories
python3 upload_dataset.py s3://${BUCKET}/cookies/
# Verify upload
aws s3 ls s3://${BUCKET}/cookies/ --recursive
# Step 2: Generate manifests locally in Ground Truth format (default - for testing transformation)
python3 generate_manifest.py s3://${BUCKET}/cookies/ --task both
# Step 3: Upload manifests to S3
aws s3 cp dataset-files/manifests/train_class.manifest s3://${BUCKET}/cookies/dataset-files/manifests/
aws s3 cp dataset-files/manifests/train_segmentation.manifest s3://${BUCKET}/cookies/dataset-files/manifests/Manifest Format Options:
--format ground-truth(default) - Ground Truth format with job-specific attribute names (for testing transformation in portal)--format dda- DDA format with standardized attribute names (ready for training without transformation)
Example Commands:
# Generate Ground Truth format (default - for testing transformation)
python3 generate_manifest.py s3://${BUCKET}/cookies/ --task both
# Generate DDA format (ready for training without transformation)
python3 generate_manifest.py s3://${BUCKET}/cookies/ --task both --format dda
# Classification only
python3 generate_manifest.py s3://${BUCKET}/cookies/ --task classification
# Segmentation only
python3 generate_manifest.py s3://${BUCKET}/cookies/ --task segmentationOutput Locations:
- Classification:
dataset-files/manifests/train_class.manifest - Segmentation:
dataset-files/manifests/train_segmentation.manifest
S3 Structure After Upload:
s3://dda-cookie-dataset-ACCOUNT_ID/
└── cookies/
├── training-images/
│ ├── normal-1.jpg
│ ├── anomaly-1.jpg
│ └── ...
├── mask-images/
│ ├── normal-1.png
│ ├── anomaly-1.png
│ └── ...
├── train_class.manifest
└── train_segmentation.manifest
The Alien Dataset is organized as follows:
alien-dataset/
├── dataset-files/
│ ├── training-images/ # Training images (JPG)
│ │ ├── normal-1.jpg
│ │ ├── anomaly-1.jpg
│ │ └── ...
│ └── mask-images/ # Segmentation masks (PNG) - optional for normal images
│ ├── anomaly-1.png
│ └── ...
├── upload_dataset.py
└── generate_manifest.py
cd datasets/alien-dataset
# Create bucket
ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
BUCKET="dda-alien-dataset-${ACCOUNT_ID}"
aws s3 mb s3://${BUCKET}
# Step 1: Upload dataset images AND masks to S3
# This uploads both training-images/ and mask-images/ directories
python3 upload_dataset.py s3://${BUCKET}/aliens/
# Verify upload
aws s3 ls s3://${BUCKET}/aliens/ --recursive
# Step 2: Generate manifests locally (creates manifest files with mask references)
python3 generate_manifest.py s3://${BUCKET}/aliens/ --task both
# Step 3: Upload manifests to S3
aws s3 cp train_class.manifest s3://${BUCKET}/aliens/
aws s3 cp train_segmentation.manifest s3://${BUCKET}/aliens/Manifest Options:
--task classification- Classification manifest (images only)--task segmentation- Segmentation manifest (images with mask references; uses dummy masks for normal images)--task both- Both classification and segmentation manifests
Output Locations:
- Classification:
train_class.manifest - Segmentation:
train_segmentation.manifest
S3 Structure After Upload:
s3://dda-alien-dataset-ACCOUNT_ID/
└── aliens/
├── training-images/
│ ├── normal-1.jpg
│ ├── anomaly-1.jpg
│ └── ...
├── mask-images/
│ ├── anomaly-1.png
│ └── ...
├── train_class.manifest
└── train_segmentation.manifest
upload_dataset.pyuploads BOTH images and masks - The script automatically uploads bothtraining-images/andmask-images/directories to S3generate_manifest.pydoes NOT upload to S3 - It only generates manifest files locally. You must manually upload them usingaws s3 cp- Manifest URIs - Use the S3 path to the manifest file when registering in the portal (e.g.,
s3://bucket/cookies/train_segmentation.manifest) - AWS Credentials - Both scripts use default AWS credentials. Configure with
aws configureor setAWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEYenvironment variables
For segmentation tasks, masks are PNG files with pixel colors representing different classes:
- Mask Filenames - Must match image filenames (e.g.,
anomaly-1.jpg→anomaly-1.png) - Pixel Colors - Each color represents a class:
#23A436(green) - Defect/anomaly region#FFFFFF(white) - Background/normal region
- Color Map - Defined in manifest metadata for Ground Truth interpretation
IMPORTANT: For segmentation training, normal images need a background-only mask so the model learns what "no defect" looks like.
Setup Steps:
-
Create background mask (run once):
cd datasets/cookie-dataset python3 create_background_mask.pyThis creates
dataset-files/mask-images/background_mask.png- a single mask file used by all normal images. -
Upload to S3:
aws s3 cp dataset-files/mask-images/background_mask.png \ s3://${BUCKET}/cookies/dataset-files/mask-images/ -
Generate manifest (will reference background_mask.png for normal images):
python3 generate_manifest.py s3://${BUCKET}/cookies/ --task segmentation
Why This Is Needed:
- Anomaly images: Have real defect masks (teaches WHERE defects are)
- Normal images: Need background-only masks (teaches what "no defect" looks like)
- Without normal images, the model won't learn to distinguish defective from non-defective areas
Example Manifest Entry with Mask:
{
"source-ref": "s3://bucket/cookies/training-images/anomaly-1.jpg",
"anomaly-label": 1,
"anomaly-label-metadata": {
"job-name": "anomaly-label",
"class-name": "anomaly",
"human-annotated": "yes",
"type": "groundtruth/image-classification"
},
"anomaly-mask-ref": "s3://bucket/cookies/mask-images/anomaly-1.png",
"anomaly-mask-ref-metadata": {
"internal-color-map": {
"0": {
"class-name": "BACKGROUND",
"hex-color": "#ffffff"
},
"1": {
"class-name": "DEFECT",
"hex-color": "#23A436"
}
},
"job-name": "anomaly-mask-ref",
"human-annotated": "yes",
"type": "groundtruth/semantic-segmentation"
}
}For complete instructions on registering datasets in the portal and training models, see QUICK_START_DATASET.md.
The Cookie Dataset is a pre-labeled dataset containing images of cookies with normal and defective examples, along with pixel-level segmentation masks for defect localization.
- training-images/ - 63 training images (32 anomalies, 31 normal)
- mask-images/ - Pixel-level segmentation masks for anomalies
- manifests/template.manifest - Template manifest file with S3 path placeholders
- test-images/ - Test images for validation
- dummy_anomaly_mask.png - Example mask for normal images
For Classification tasks:
- Go to Data Management → Pre-Labeled Datasets
- Click Register Dataset
- Fill in:
- Dataset Name: "Cookie Defect Detection"
- S3 Manifest URI:
s3://dda-cookie-dataset-ACCOUNT_ID/cookies/train_class.manifest - Description: "Cookie dataset for classification"
- Click Register
For Segmentation tasks:
- Go to Data Management → Pre-Labeled Datasets
- Click Register Dataset
- Fill in:
- Dataset Name: "Cookie Defect Detection (Segmentation)"
- S3 Manifest URI:
s3://dda-cookie-dataset-ACCOUNT_ID/cookies/train_segmentation.manifest - Description: "Cookie dataset with pixel-level segmentation masks"
- Click Register
- Go to Training → Create Training Job
- Select Pre-Labeled Dataset as source
- Choose your registered dataset from dropdown
- Configure training parameters
- Click Start Training
# Standard upload
python3 upload_dataset.py s3://my-bucket/cookies/
# Dry run (shows what would be uploaded)
python3 upload_dataset.py s3://my-bucket/cookies/ --dry-runError: "AWS credentials not found"
- Configure AWS credentials:
aws configure - Or set environment variables:
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEY
Error: "S3 bucket not found"
- Verify bucket exists:
aws s3 ls s3://your-bucket-name - Create bucket if needed:
aws s3 mb s3://your-bucket-name
Error: "Access Denied"
- Verify your AWS credentials have S3 permissions
- Check bucket policy allows your IAM user/role
| Metric | Value |
|---|---|
| Total Images | 63 |
| Anomalies | 32 |
| Normal | 31 |
| Image Format | JPG |
| Mask Format | PNG |
| Segmentation | Yes (pixel-level masks) |
This dataset is based on the Cookie Dataset from the amazon-lookout-for-vision repository.
This dataset is provided under the Apache License 2.0. See the LICENSE file in the root directory.