Get started with object detection training in 5 minutes!
# Install dependencies
pip install -r torch_requirements.txtcd ../image-classification
./build.sh
./run_app.sh- Select "Object Detection" mode
- Open your images folder
- Create labels (e.g., "fireball", "meteor")
- Draw bounding boxes and assign labels
- Save annotations
Ensure your dataset follows this structure:
annotated_images/
├── images/ # Your images
├── labels/ # YOLO format .txt files
└── classes.txt # Class names (one per line)
cd fireball-detector
# Basic training (uses default settings)
python -m src.train_object_detection
# Custom settings
python -m src.train_object_detection \
--num_epochs 50 \
--batch_size 4 \
--learning_rate 0.001Training will:
- Create
checkpoints/directory - Save best model based on validation mAP
- Print progress and metrics
Expected output:
Loading dataset from annotated_images...
Loaded 150 images with 3 classes
Classes: ['fireball', 'meteor', 'satellite']
Train dataset: 120 images
Validation dataset: 30 images
Creating model...
Using device: cuda
Starting training for 50 epochs...
Batch size: 4, Learning rate: 0.001
--------------------------------------------------------------------------------
Epoch 1/50
...
Validation mAP: 0.4523
New best model saved: checkpoints/faster_rcnn_best_bs4_ne50.pth
python -m src.detect \
--model checkpoints/faster_rcnn_best_bs4_ne50.pth \
--image test_image.jpg \
--showpython -m src.detect \
--model checkpoints/faster_rcnn_best_bs4_ne50.pth \
--input_dir test_images/ \
--output_dir results/Detection output:
Detections for test_image.jpg:
Found 2 objects
1. fireball: 0.923 at [120.5, 85.3, 245.7, 198.2]
2. meteor: 0.856 at [350.1, 120.8, 420.3, 180.5]
Saved visualization to: results/detected_test_image.jpg
python -m src.detect \
--model checkpoints/faster_rcnn_best_bs4_ne50.pth \
--exportCreates:
exports/faster_rcnn_model.onnx(ONNX format)exports/faster_rcnn_model.pt(TorchScript format)
Current configuration is optimized for RTX 2070!
OD_BATCH_SIZE = 4 # 64.4% GPU utilization (5273 MB)
OD_MIN_SIZE = 800
OD_MAX_SIZE = 1333
OD_TRAINABLE_BACKBONE_LAYERS = 3
OD_NUM_WORKERS = 6See GPU_OPTIMIZATION_RTX2070.md for detailed profiling results.
Edit src/config.py:
OD_BATCH_SIZE = 2 # or even 1
OD_MIN_SIZE = 600 # reduce from 800
OD_MAX_SIZE = 1000 # reduce from 1333OD_NUM_EPOCHS = 20
OD_TRAINABLE_BACKBONE_LAYERS = 1OD_NUM_EPOCHS = 100
OD_TRAINABLE_BACKBONE_LAYERS = 5
OD_BACKBONE = 'resnet101'→ Reduce OD_BATCH_SIZE to 2 or 1
→ Check dataset path and structure
→ Train longer, add more data, or check annotations
→ Lower --score_threshold to 0.3 or 0.2
See OBJECT_DETECTION_README.md for:
- Detailed configuration options
- Evaluation metrics explanation
- Advanced training techniques
- Complete API reference
# 1. Annotate images
cd image-classification
./run_app.sh
# (Annotate in Object Detection mode)
# 2. Copy dataset
cp -r annotated_images ../fireball-detector/
# 3. Train
cd ../fireball-detector
python -m src.train_object_detection --num_epochs 50
# 4. Test
python -m src.detect \
--model checkpoints/faster_rcnn_best_bs4_ne50.pth \
--image test.jpg \
--show
# 5. Export
python -m src.detect \
--model checkpoints/faster_rcnn_best_bs4_ne50.pth \
--export- Total Loss: Should decrease over time (< 1.0 is good)
- mAP: Mean Average Precision (> 0.5 is good, > 0.7 is excellent)
- AP per class: Shows performance for each object type
- > 0.9: Very confident detection
- 0.7-0.9: Good detection
- 0.5-0.7: Moderate confidence
- < 0.5: Low confidence (may be false positive)
fireball-detector/
├── src/
│ ├── config.py # Configuration
│ ├── train_object_detection.py # Training script
│ ├── detect.py # Inference script
│ ├── object_detection_model.py # Model definition
│ ├── data/
│ │ └── object_detection_dataset.py # Dataset loader
│ └── utils/
│ └── metrics.py # Evaluation metrics
├── annotated_images/ # Your dataset
├── checkpoints/ # Saved models
├── detections/ # Detection results
└── exports/ # Exported models
- Start small: Train on 50-100 images first
- Check annotations: Verify bounding boxes are accurate
- Monitor mAP: Should improve each epoch
- Save checkpoints: Don't lose progress
- Test early: Run detection after 10-20 epochs
- Fine-tune hyperparameters in
src/config.py - Add more training data for better accuracy
- Experiment with different backbones
- Deploy model in production
Happy detecting! 🎯