Official implementation of the paper "From Object Instability to Image Uncertainty: A Strategy for Active Learning in Object Detection"
🎯 TL;DR: A comprehensive active learning framework for object detection that intelligently selects the most informative samples to annotate, reducing labeling costs while maintaining high model performance.
FDAL (Feature Difficulty in Active Learning) introduces a novel uncertainty estimation approach based on feature instability for active learning in object detection. This repository provides the complete implementation along with support for multiple established active learning strategies and datasets.
- 🚀 State-of-the-art FDAL Strategy: Our novel feature instability-based approach
- 📊 Multiple AL Strategies: Uncertainty-based, diversity-based, and hybrid methods
- 🎯 Multi-Dataset Support: COCO, VOC, Cityscapes, KITTI
- ⚡ YOLO Integration: Built on ultralytics YOLO models
- 🔧 Easy Configuration: YAML-based experiment setup
- 📈 Comprehensive Evaluation: Built-in metrics and visualization tools
- Python 3.9 or higher (as specified in
.python-version) - CUDA-compatible GPU (recommended)
- uv package manager
- Clone the repository:
git clone https://github.com/TaiDuc1001/FDAL.git
cd FDAL- Install with uv (recommended):
# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh
# Create virtual environment and install dependencies
uv sync- Set up environment variables:
cp .env.example .env
# Edit .env with your API keys (Kaggle, Weights & Biases)# Download COCO dataset
uv run python scripts/down_data.py --dataset coco
# Or download VOC dataset
uv run python scripts/down_data.py --dataset VOC# Run FDAL strategy on VOC dataset
uv run python scripts/run_experiment.py --config configs/voc/config_fdal.yaml
# Run baseline random sampling for comparison
uv run python scripts/run_experiment.py --config configs/voc/config_random.yaml- FDAL 🌟: Feature Difficulty in Active Learning (our paper's contribution)
- Entropy: Prediction entropy-based selection
- BADGE: Batch Active learning by Diverse Gradient Embeddings
- CDAL: Contextual Diversity Active Learning
- DCUS: Difficulty Calibrated Uncertainty Sampling
- CoreSet: Core-set based active learning
- DivProto: Diversity Prototype
- CCMS: Category Conditioned Matching Similarity
- Random: Random sample selection baseline
- PPAL: Plug and Play Active Learning (DCUS + CCMS)
FDAL/
├── configs/ # Experiment configurations
│ ├── coco/ # COCO dataset configs
│ ├── voc/ # VOC dataset configs
│ ├── cityscapes/ # Cityscapes configs
│ └── kitti/ # KITTI configs
├── scripts/ # Main execution scripts
│ ├── run_experiment.py # 🎯 Main experiment runner
│ ├── train.py # Model training
│ ├── strategy.py # Strategy execution
│ ├── down_data.py # Dataset downloader
│ ├── setup_data.py # Data setup
│ ├── simulate_labeling.py # Labeling simulation
│ └── utils.py # Utility functions
├── src/ # Source code
│ ├── data/ # Data loading and management
│ ├── models/ # YOLO model implementations
│ └── strategies/ # Active learning strategies
│ ├── uncertainty/ # Uncertainty-based methods
│ ├── diversity/ # Diversity-based methods
│ ├── intrinsic/ # Intrinsic methods
│ └── random/ # Random baseline
└── pyproject.toml # uv/pip dependencies
# Run an experiment with default settings
uv run python scripts/run_experiment.py --config configs/voc/config_fdal.yaml# Override specific parameters
uv run python scripts/run_experiment.py \
--config configs/voc/config_fdal.yaml \
--epochs 50 \
--batch_size 32 \
--max_rounds 5 \
--device 0# Run multiple strategies for comparison
uv run python scripts/run_experiment.py --config configs/voc/config_fdal.yaml
uv run python scripts/run_experiment.py --config configs/voc/config_entropy.yaml
uv run python scripts/run_experiment.py --config configs/voc/config_random.yaml
# Generate comparison plots
uv run python scripts/utils.py compare \
experiments/fdal_exp experiments/entropy_exp experiments/random_exp \
--names FDAL Entropy Random# Train a model
uv run python scripts/train.py \
--dataset_yaml datasets/VOC/data.yaml \
--model yolo11s.pt \
--epochs 26
# Run strategy selection only
uv run python scripts/strategy.py \
--dataset_yaml datasets/VOC/data.yaml \
--strategy fdal \
--model path/to/model.pt \
--num_samples 414Each strategy has its own configuration file in configs/. Here's an example from the actual codebase:
# configs/voc/config_fdal.yaml
dataset_yaml: "datasets/VOC/data.yaml"
epochs: 26
batch_size: 16
val_batch_size: 256
imgsz: 640
device: ['0']
strategy: "fdal"
model_name: "yolo11s.pt"
initial_labeled_count: 828
max_rounds: 7
samples_per_round: 414
num_inference: 6000
strategy_args:
fdal:
supporter: "resnet18"
supporter_epochs: 5
supporter_batch_size: 1000000
learn_alpha: true
alpha_cap: 0.03125
alpha_learning_rate: 0.1
lambda_hyp: 0.99
supporter_embedding_size: 32
supporter_imgsz: 320
one_alpha_cap: falseinitial_labeled_count: Number of initially labeled samplessamples_per_round: Samples to select in each active learning roundmax_rounds: Maximum number of active learning roundsstrategy: Active learning strategy to usestrategy_args: Strategy-specific hyperparameters
- mAP@0.5: Mean Average Precision at IoU 0.5
- mAP@0.5-0.95: Mean Average Precision averaged over IoU thresholds
- Learning Curves: Performance vs. annotation budget
# Plot learning curves
uv run python scripts/utils.py plot experiments/your_exp/results.json
# Generate experiment report
uv run python scripts/utils.py report experiments/your_expOur FDAL strategy leverages feature instability to identify the most informative samples:
- Feature Extraction: Extract features from multiple layers of the trained model
- Instability Measurement: Compute feature instability using supporter networks
- Uncertainty Quantification: Convert instability to uncertainty scores
- Sample Selection: Select samples with highest uncertainty for annotation
Key advantages:
- ✅ Better correlation with true uncertainty than entropy-based methods
- ✅ Captures model's confusion about both classification and localization
- ✅ Robust across different datasets and model architectures
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
- Built on top of Ultralytics YOLO
- Inspired by recent advances in active learning research
- Special thanks to the open-source computer vision community
⭐ Star this repository if you find it useful!