Senior Computer Vision Engineer
Computer vision engineering skill for object detection, image segmentation, and visual AI systems.
How to use it
Claude Code
- Run the line below. It pulls the whole folder into
~/.claude/skills/senior-computer-vision, including the files SKILL.md points to. - Describe your job in plain words. Claude Code follows the skill from there.
npx degit alirezarezvani/claude-skills/engineering-team/skills/senior-computer-vision#main ~/.claude/skills/senior-computer-visionFor one project only, change the path to .claude/skills/senior-computer-vision. This skill also uses data.yaml, train_net.py, detectron2_config.py — copying SKILL.md alone won't be enough. See the folder on GitHub.
Claude (web or desktop app)
- On this page open ⋯ → Download .md.
- Save it as SKILL.md in a folder, zip the folder, then Customize → Skills → + → Create skill → Upload a skill.
- Pick the file and Save. Claude shows the name and description and runs a security scan.
- Check the skill is switched on.
- Start a new chat and describe your job in plain words. The AI follows the skill from there.
ChatGPT or another app
- ChatGPT: make a Project and paste it into Instructions.
- Neither? Paste it at the top of a new chat — it works for that chat.
Not working?
- Check which app you pasted it into — the steps above name the right one.
- Some skills need the paid tier of Claude or ChatGPT.
Paste into Claude, ChatGPT or Cursor.
Source of Senior Computer Vision Engineer
Show the full text439 lines
| name | description |
|---|---|
| senior-computer-vision | Computer vision engineering skill for object detection, image segmentation, and visual AI systems. Covers CNN and Vision Transformer architectures, YOLO/Faster R-CNN/DETR detection, Mask R-CNN/SAM segmentation, and production deployment with ONNX/TensorRT. Includes PyTorch, torchvision, Ultralytics, Detectron2, and MMDetection frameworks. Use when building detection pipelines, training custom models, optimizing inference, or deploying vision systems. |
Senior Computer Vision Engineer
Production computer vision engineering skill for object detection, image segmentation, and visual AI system deployment.
Table of Contents
- Quick Start
- Core Expertise
- Tech Stack
- Workflow 1: Object Detection Pipeline
- Workflow 2: Model Optimization and Deployment
- Workflow 3: Custom Dataset Preparation
- Architecture Selection Guide
- Reference Documentation
Quick Start
# Generate training configuration for YOLO or Faster R-CNN
python scripts/vision_model_trainer.py models/ --task detection --arch yolov8
# Analyze model for optimization opportunities (quantization, pruning)
python scripts/inference_optimizer.py model.pt --target onnx --benchmark
# Build dataset pipeline with augmentations
python scripts/dataset_pipeline_builder.py images/ --format coco --augment
Core Expertise
This skill provides guidance on:
- Object Detection: YOLO family (v5-v11), Faster R-CNN, DETR, RT-DETR
- Instance Segmentation: Mask R-CNN, YOLACT, SOLOv2
- Semantic Segmentation: DeepLabV3+, SegFormer, SAM (Segment Anything)
- Image Classification: ResNet, EfficientNet, Vision Transformers (ViT, DeiT)
- Video Analysis: Object tracking (ByteTrack, SORT), action recognition
- 3D Vision: Depth estimation, point cloud processing, NeRF
- Production Deployment: ONNX, TensorRT, OpenVINO, CoreML
Tech Stack
| Category | Technologies |
|---|---|
| Frameworks | PyTorch, torchvision, timm |
| Detection | Ultralytics (YOLO), Detectron2, MMDetection |
| Segmentation | segment-anything, mmsegmentation |
| Optimization | ONNX, TensorRT, OpenVINO, torch.compile |
| Image Processing | OpenCV, Pillow, albumentations |
| Annotation | CVAT, Label Studio, Roboflow |
| Experiment Tracking | MLflow, Weights & Biases |
| Serving | Triton Inference Server, TorchServe |
Workflow 1: Object Detection Pipeline
Use this workflow when building an object detection system from scratch.
Step 1: Define Detection Requirements
Analyze the detection task requirements:
Detection Requirements Analysis:
- Target objects: [list specific classes to detect]
- Real-time requirement: [yes/no, target FPS]
- Accuracy priority: [speed vs accuracy trade-off]
- Deployment target: [cloud GPU, edge device, mobile]
- Dataset size: [number of images, annotations per class]
Step 2: Select Detection Architecture
Choose architecture based on requirements:
| Requirement | Recommended Architecture | Why |
|---|---|---|
| Real-time (>30 FPS) | YOLOv8/v11, RT-DETR | Single-stage, optimized for speed |
| High accuracy | Faster R-CNN, DINO | Two-stage, better localization |
| Small objects | YOLO + SAHI, Faster R-CNN + FPN | Multi-scale detection |
| Edge deployment | YOLOv8n, MobileNetV3-SSD | Lightweight architectures |
| Transformer-based | DETR, DINO, RT-DETR | End-to-end, no NMS required |
Step 3: Prepare Dataset
Convert annotations to required format:
# COCO format (recommended)
python scripts/dataset_pipeline_builder.py data/images/ \
--annotations data/labels/ \
--format coco \
--split 0.8 0.1 0.1 \
--output data/coco/
# Verify dataset
python -c "from pycocotools.coco import COCO; coco = COCO('data/coco/train.json'); print(f'Images: {len(coco.imgs)}, Categories: {len(coco.cats)}')"
Step 4: Configure Training
Generate training configuration:
# For Ultralytics YOLO
python scripts/vision_model_trainer.py data/coco/ \
--task detection \
--arch yolov8m \
--epochs 100 \
--batch 16 \
--imgsz 640 \
--output configs/
# For Detectron2
python scripts/vision_model_trainer.py data/coco/ \
--task detection \
--arch faster_rcnn_R_50_FPN \
--framework detectron2 \
--output configs/
Step 5: Train and Validate
# Ultralytics training
yolo detect train data=data.yaml model=yolov8m.pt epochs=100 imgsz=640
# Detectron2 training
python train_net.py --config-file configs/faster_rcnn.yaml --num-gpus 1
# Validate on test set
yolo detect val model=runs/detect/train/weights/best.pt data=data.yaml
Step 6: Evaluate Results
Key metrics to analyze:
| Metric | Target | Description |
|---|---|---|
| mAP@50 | >0.7 | Mean Average Precision at IoU 0.5 |
| mAP@50:95 | >0.5 | COCO primary metric |
| Precision | >0.8 | Low false positives |
| Recall | >0.8 | Low missed detections |
| Inference time | <33ms | For 30 FPS real-time |
Workflow 2: Model Optimization and Deployment
Use this workflow when preparing a trained model for production deployment.
Step 1: Benchmark Baseline Performance
# Measure current model performance
python scripts/inference_optimizer.py model.pt \
--benchmark \
--input-size 640 640 \
--batch-sizes 1 4 8 16 \
--warmup 10 \
--iterations 100
Expected output:
Baseline Performance (PyTorch FP32):
- Batch 1: 45.2ms (22.1 FPS)
- Batch 4: 89.4ms (44.7 FPS)
- Batch 8: 165.3ms (48.4 FPS)
- Memory: 2.1 GB
- Parameters: 25.9M
Step 2: Select Optimization Strategy
| Deployment Target | Optimization Path |
|---|---|
| NVIDIA GPU (cloud) | PyTorch → ONNX → TensorRT FP16 |
| NVIDIA GPU (edge) | PyTorch → TensorRT INT8 |
| Intel CPU | PyTorch → ONNX → OpenVINO |
| Apple Silicon | PyTorch → CoreML |
| Generic CPU | PyTorch → ONNX Runtime |
| Mobile | PyTorch → TFLite or ONNX Mobile |
Step 3: Export to ONNX
# Export with dynamic batch size
python scripts/inference_optimizer.py model.pt \
--export onnx \
--input-size 640 640 \
--dynamic-batch \
--simplify \
--output model.onnx
# Verify ONNX model
python -c "import onnx; model = onnx.load('model.onnx'); onnx.checker.check_model(model); print('ONNX model valid')"
Step 4: Apply Quantization (Optional)
For INT8 quantization with calibration:
# Generate calibration dataset
python scripts/inference_optimizer.py model.onnx \
--quantize int8 \
--calibration-data data/calibration/ \
--calibration-samples 500 \
--output model_int8.onnx
Quantization impact analysis:
| Precision | Size | Speed | Accuracy Drop |
|---|---|---|---|
| FP32 | 100% | 1x | 0% |
| FP16 | 50% | 1.5-2x | <0.5% |
| INT8 | 25% | 2-4x | 1-3% |
Step 5: Convert to Target Runtime
# TensorRT (NVIDIA GPU)
trtexec --onnx=model.onnx --saveEngine=model.engine --fp16
# OpenVINO (Intel)
mo --input_model model.onnx --output_dir openvino/
# CoreML (Apple)
python -c "import coremltools as ct; model = ct.convert('model.onnx'); model.save('model.mlpackage')"
Step 6: Benchmark Optimized Model
python scripts/inference_optimizer.py model.engine \
--benchmark \
--runtime tensorrt \
--compare model.pt
Expected speedup:
Optimization Results:
- Original (PyTorch FP32): 45.2ms
- Optimized (TensorRT FP16): 12.8ms
- Speedup: 3.5x
- Accuracy change: -0.3% mAP
Workflow 3: Custom Dataset Preparation
Use this workflow when preparing a computer vision dataset for training.
Step 1: Audit Raw Data
# Analyze image dataset
python scripts/dataset_pipeline_builder.py data/raw/ \
--analyze \
--output analysis/
Analysis report includes:
Dataset Analysis:
- Total images: 5,234
- Image sizes: 640x480 to 4096x3072 (variable)
- Formats: JPEG (4,891), PNG (343)
- Corrupted: 12 files
- Duplicates: 45 pairs
Annotation Analysis:
- Format detected: Pascal VOC XML
- Total annotations: 28,456
- Classes: 5 (car, person, bicycle, dog, cat)
- Distribution: car (12,340), person (8,234), bicycle (3,456), dog (2,890), cat (1,536)
- Empty images: 234
Step 2: Clean and Validate
# Remove corrupted and duplicate images
python scripts/dataset_pipeline_builder.py data/raw/ \
--clean \
--remove-corrupted \
--remove-duplicates \
--output data/cleaned/
Step 3: Convert Annotation Format
# Convert VOC to COCO format
python scripts/dataset_pipeline_builder.py data/cleaned/ \
--annotations data/annotations/ \
--input-format voc \
--output-format coco \
--output data/coco/
Supported format conversions:
| From | To |
|---|---|
| Pascal VOC XML | COCO JSON |
| YOLO TXT | COCO JSON |
| COCO JSON | YOLO TXT |
| LabelMe JSON | COCO JSON |
| CVAT XML | COCO JSON |
Step 4: Apply Augmentations
# Generate augmentation config
python scripts/dataset_pipeline_builder.py data/coco/ \
--augment \
--aug-config configs/augmentation.yaml \
--output data/augmented/
Recommended augmentations for detection:
# configs/augmentation.yaml
augmentations:
geometric:
- horizontal_flip: { p: 0.5 }
- vertical_flip: { p: 0.1 } # Only if orientation invariant
- rotate: { limit: 15, p: 0.3 }
- scale: { scale_limit: 0.2, p: 0.5 }
color:
- brightness_contrast: { brightness_limit: 0.2, contrast_limit: 0.2, p: 0.5 }
- hue_saturation: { hue_shift_limit: 20, sat_shift_limit: 30, p: 0.3 }
- blur: { blur_limit: 3, p: 0.1 }
advanced:
- mosaic: { p: 0.5 } # YOLO-style mosaic
- mixup: { p: 0.1 } # Image mixing
- cutout: { num_holes: 8, max_h_size: 32, max_w_size: 32, p: 0.3 }
Step 5: Create Train/Val/Test Splits
python scripts/dataset_pipeline_builder.py data/augmented/ \
--split 0.8 0.1 0.1 \
--stratify \
--seed 42 \
--output data/final/
Split strategy guidelines:
| Dataset Size | Train | Val | Test |
|---|---|---|---|
| <1,000 images | 70% | 15% | 15% |
| 1,000-10,000 | 80% | 10% | 10% |
| >10,000 | 90% | 5% | 5% |
Step 6: Generate Dataset Configuration
# For Ultralytics YOLO
python scripts/dataset_pipeline_builder.py data/final/ \
--generate-config yolo \
--output data.yaml
# For Detectron2
python scripts/dataset_pipeline_builder.py data/final/ \
--generate-config detectron2 \
--output detectron2_config.py
Architecture Selection Guide
Object Detection Architectures
| Architecture | Speed | Accuracy | Best For |
|---|---|---|---|
| YOLOv8n | 1.2ms | 37.3 mAP | Edge, mobile, real-time |
| YOLOv8s | 2.1ms | 44.9 mAP | Balanced speed/accuracy |
| YOLOv8m | 4.2ms | 50.2 mAP | General purpose |
| YOLOv8l | 6.8ms | 52.9 mAP | High accuracy |
| YOLOv8x | 10.1ms | 53.9 mAP | Maximum accuracy |
| RT-DETR-L | 5.3ms | 53.0 mAP | Transformer, no NMS |
| Faster R-CNN R50 | 46ms | 40.2 mAP | Two-stage, high quality |
| DINO-4scale | 85ms | 49.0 mAP | SOTA transformer |
Segmentation Architectures
| Architecture | Type | Speed | Best For |
|---|---|---|---|
| YOLOv8-seg | Instance | 4.5ms | Real-time instance seg |
| Mask R-CNN | Instance | 67ms | High-quality masks |
| SAM | Promptable | 50ms | Zero-shot segmentation |
| DeepLabV3+ | Semantic | 25ms | Scene parsing |
| SegFormer | Semantic | 15ms | Efficient semantic seg |
CNN vs Vision Transformer Trade-offs
| Aspect | CNN (YOLO, R-CNN) | ViT (DETR, DINO) |
|---|---|---|
| Training data needed | 1K-10K images | 10K-100K+ images |
| Training time | Fast | Slow (needs more epochs) |
| Inference speed | Faster | Slower |
| Small objects | Good with FPN | Needs multi-scale |
| Global context | Limited | Excellent |
| Positional encoding | Implicit | Explicit |
Reference Documentation
→ See references/reference-docs-and-commands.md for details
Performance Targets
| Metric | Real-time | High Accuracy | Edge |
|---|---|---|---|
| FPS | >30 | >10 | >15 |
| mAP@50 | >0.6 | >0.8 | >0.5 |
| Latency P99 | <50ms | <150ms | <100ms |
| GPU Memory | <4GB | <8GB | <2GB |
| Model Size | <50MB | <200MB | <20MB |
Resources
- Architecture Guide:
references/computer_vision_architectures.md - Optimization Guide:
references/object_detection_optimization.md - Deployment Guide:
references/production_vision_systems.md - Scripts:
scripts/directory for automation tools
| 1 | |
| 2 | name "senior-computer-vision" |
| 3 | description Computer vision engineering skill for object detection, image segmentation, and visual AI systems. Covers CNN and Vision Transformer architectures, YOLO/Faster R-CNN/DETR detection, Mask R-CNN/SAM segmentation, and production deployment with ONNX/TensorRT. Includes PyTorch, torchvision, Ultralytics, Detectron2, and MMDetection frameworks. Use when building detection pipelines, training custom models, optimizing inference, or deploying vision systems. |
| 4 | |
| 5 | |
| 6 | # Senior Computer Vision Engineer |
| 7 | |
| 8 | Production computer vision engineering skill for object detection, image segmentation, and visual AI system deployment. |
| 9 | |
| 10 | ## Table of Contents |
| 11 | |
| 12 | [Quick Start] |
| 13 | [Core Expertise] |
| 14 | [Tech Stack] |
| 15 | [Workflow 1: Object Detection Pipeline] |
| 16 | [Workflow 2: Model Optimization and Deployment] |
| 17 | [Workflow 3: Custom Dataset Preparation] |
| 18 | [Architecture Selection Guide] |
| 19 | [Reference Documentation] |
| 20 | |
| 21 | ## Quick Start |
| 22 | |
| 23 | |
| 24 | # Generate training configuration for YOLO or Faster R-CNN |
| 25 | python scripts/vision_model_trainer.py models/ --task detection --arch yolov8 |
| 26 | |
| 27 | # Analyze model for optimization opportunities (quantization, pruning) |
| 28 | python scripts/inference_optimizer.py model.pt --target onnx --benchmark |
| 29 | |
| 30 | # Build dataset pipeline with augmentations |
| 31 | python scripts/dataset_pipeline_builder.py images/ --format coco --augment |
| 32 | |
| 33 | |
| 34 | ## Core Expertise |
| 35 | |
| 36 | This skill provides guidance on: |
| 37 | |
| 38 | **Object Detection**: YOLO family (v5-v11), Faster R-CNN, DETR, RT-DETR |
| 39 | **Instance Segmentation**: Mask R-CNN, YOLACT, SOLOv2 |
| 40 | **Semantic Segmentation**: DeepLabV3+, SegFormer, SAM (Segment Anything) |
| 41 | **Image Classification**: ResNet, EfficientNet, Vision Transformers (ViT, DeiT) |
| 42 | **Video Analysis**: Object tracking (ByteTrack, SORT), action recognition |
| 43 | **3D Vision**: Depth estimation, point cloud processing, NeRF |
| 44 | **Production Deployment**: ONNX, TensorRT, OpenVINO, CoreML |
| 45 | |
| 46 | ## Tech Stack |
| 47 | |
| 48 | | Category | Technologies | |
| 49 | |----------|--------------| |
| 50 | | Frameworks | PyTorch, torchvision, timm | |
| 51 | | Detection | Ultralytics (YOLO), Detectron2, MMDetection | |
| 52 | | Segmentation | segment-anything, mmsegmentation | |
| 53 | | Optimization | ONNX, TensorRT, OpenVINO, torch.compile | |
| 54 | | Image Processing | OpenCV, Pillow, albumentations | |
| 55 | | Annotation | CVAT, Label Studio, Roboflow | |
| 56 | | Experiment Tracking | MLflow, Weights & Biases | |
| 57 | | Serving | Triton Inference Server, TorchServe | |
| 58 | |
| 59 | ## Workflow 1: Object Detection Pipeline |
| 60 | |
| 61 | Use this workflow when building an object detection system from scratch. |
| 62 | |
| 63 | ### Step 1: Define Detection Requirements |
| 64 | |
| 65 | Analyze the detection task requirements: |
| 66 | |
| 67 | |
| 68 | Detection Requirements Analysis: |
| 69 | - Target objects: [list specific classes to detect] |
| 70 | - Real-time requirement: [yes/no, target FPS] |
| 71 | - Accuracy priority: [speed vs accuracy trade-off] |
| 72 | - Deployment target: [cloud GPU, edge device, mobile] |
| 73 | - Dataset size: [number of images, annotations per class] |
| 74 | |
| 75 | |
| 76 | ### Step 2: Select Detection Architecture |
| 77 | |
| 78 | Choose architecture based on requirements: |
| 79 | |
| 80 | | Requirement | Recommended Architecture | Why | |
| 81 | |-------------|-------------------------|-----| |
| 82 | | Real-time (>30 FPS) | YOLOv8/v11, RT-DETR | Single-stage, optimized for speed | |
| 83 | | High accuracy | Faster R-CNN, DINO | Two-stage, better localization | |
| 84 | | Small objects | YOLO + SAHI, Faster R-CNN + FPN | Multi-scale detection | |
| 85 | | Edge deployment | YOLOv8n, MobileNetV3-SSD | Lightweight architectures | |
| 86 | | Transformer-based | DETR, DINO, RT-DETR | End-to-end, no NMS required | |
| 87 | |
| 88 | ### Step 3: Prepare Dataset |
| 89 | |
| 90 | Convert annotations to required format: |
| 91 | |
| 92 | |
| 93 | # COCO format (recommended) |
| 94 | python scripts/dataset_pipeline_builder.py data/images/ \ |
| 95 | --annotations data/labels/ \ |
| 96 | --format coco \ |
| 97 | --split 0.8 0.1 0.1 \ |
| 98 | --output data/coco/ |
| 99 | |
| 100 | # Verify dataset |
| 101 | python -c "from pycocotools.coco import COCO; coco = COCO('data/coco/train.json'); print(f'Images: {len(coco.imgs)}, Categories: {len(coco.cats)}')" |
| 102 | |
| 103 | |
| 104 | ### Step 4: Configure Training |
| 105 | |
| 106 | Generate training configuration: |
| 107 | |
| 108 | |
| 109 | # For Ultralytics YOLO |
| 110 | python scripts/vision_model_trainer.py data/coco/ \ |
| 111 | --task detection \ |
| 112 | --arch yolov8m \ |
| 113 | --epochs 100 \ |
| 114 | --batch 16 \ |
| 115 | --imgsz 640 \ |
| 116 | --output configs/ |
| 117 | |
| 118 | # For Detectron2 |
| 119 | python scripts/vision_model_trainer.py data/coco/ \ |
| 120 | --task detection \ |
| 121 | --arch faster_rcnn_R_50_FPN \ |
| 122 | --framework detectron2 \ |
| 123 | --output configs/ |
| 124 | |
| 125 | |
| 126 | ### Step 5: Train and Validate |
| 127 | |
| 128 | |
| 129 | # Ultralytics training |
| 130 | yolo detect train data=data.yaml model=yolov8m.pt epochs=100 imgsz=640 |
| 131 | |
| 132 | # Detectron2 training |
| 133 | python train_net.py --config-file configs/faster_rcnn.yaml --num-gpus 1 |
| 134 | |
| 135 | # Validate on test set |
| 136 | yolo detect val model=runs/detect/train/weights/best.pt data=data.yaml |
| 137 | |
| 138 | |
| 139 | ### Step 6: Evaluate Results |
| 140 | |
| 141 | Key metrics to analyze: |
| 142 | |
| 143 | | Metric | Target | Description | |
| 144 | |--------|--------|-------------| |
| 145 | | mAP@50 | >0.7 | Mean Average Precision at IoU 0.5 | |
| 146 | | mAP@50:95 | >0.5 | COCO primary metric | |
| 147 | | Precision | >0.8 | Low false positives | |
| 148 | | Recall | >0.8 | Low missed detections | |
| 149 | | Inference time | <33ms | For 30 FPS real-time | |
| 150 | |
| 151 | ## Workflow 2: Model Optimization and Deployment |
| 152 | |
| 153 | Use this workflow when preparing a trained model for production deployment. |
| 154 | |
| 155 | ### Step 1: Benchmark Baseline Performance |
| 156 | |
| 157 | |
| 158 | # Measure current model performance |
| 159 | python scripts/inference_optimizer.py model.pt \ |
| 160 | --benchmark \ |
| 161 | --input-size 640 640 \ |
| 162 | --batch-sizes 1 4 8 16 \ |
| 163 | --warmup 10 \ |
| 164 | --iterations 100 |
| 165 | |
| 166 | |
| 167 | Expected output: |
| 168 | |
| 169 | |
| 170 | Baseline Performance (PyTorch FP32): |
| 171 | - Batch 1: 45.2ms (22.1 FPS) |
| 172 | - Batch 4: 89.4ms (44.7 FPS) |
| 173 | - Batch 8: 165.3ms (48.4 FPS) |
| 174 | - Memory: 2.1 GB |
| 175 | - Parameters: 25.9M |
| 176 | |
| 177 | |
| 178 | ### Step 2: Select Optimization Strategy |
| 179 | |
| 180 | | Deployment Target | Optimization Path | |
| 181 | |-------------------|-------------------| |
| 182 | | NVIDIA GPU (cloud) | PyTorch → ONNX → TensorRT FP16 | |
| 183 | | NVIDIA GPU (edge) | PyTorch → TensorRT INT8 | |
| 184 | | Intel CPU | PyTorch → ONNX → OpenVINO | |
| 185 | | Apple Silicon | PyTorch → CoreML | |
| 186 | | Generic CPU | PyTorch → ONNX Runtime | |
| 187 | | Mobile | PyTorch → TFLite or ONNX Mobile | |
| 188 | |
| 189 | ### Step 3: Export to ONNX |
| 190 | |
| 191 | |
| 192 | # Export with dynamic batch size |
| 193 | python scripts/inference_optimizer.py model.pt \ |
| 194 | --export onnx \ |
| 195 | --input-size 640 640 \ |
| 196 | --dynamic-batch \ |
| 197 | --simplify \ |
| 198 | --output model.onnx |
| 199 | |
| 200 | # Verify ONNX model |
| 201 | python -c "import onnx; model = onnx.load('model.onnx'); onnx.checker.check_model(model); print('ONNX model valid')" |
| 202 | |
| 203 | |
| 204 | ### Step 4: Apply Quantization (Optional) |
| 205 | |
| 206 | For INT8 quantization with calibration: |
| 207 | |
| 208 | |
| 209 | # Generate calibration dataset |
| 210 | python scripts/inference_optimizer.py model.onnx \ |
| 211 | --quantize int8 \ |
| 212 | --calibration-data data/calibration/ \ |
| 213 | --calibration-samples 500 \ |
| 214 | --output model_int8.onnx |
| 215 | |
| 216 | |
| 217 | Quantization impact analysis: |
| 218 | |
| 219 | | Precision | Size | Speed | Accuracy Drop | |
| 220 | |-----------|------|-------|---------------| |
| 221 | | FP32 | 100% | 1x | 0% | |
| 222 | | FP16 | 50% | 1.5-2x | <0.5% | |
| 223 | | INT8 | 25% | 2-4x | 1-3% | |
| 224 | |
| 225 | ### Step 5: Convert to Target Runtime |
| 226 | |
| 227 | |
| 228 | # TensorRT (NVIDIA GPU) |
| 229 | trtexec --onnx=model.onnx --saveEngine=model.engine --fp16 |
| 230 | |
| 231 | # OpenVINO (Intel) |
| 232 | mo --input_model model.onnx --output_dir openvino/ |
| 233 | |
| 234 | # CoreML (Apple) |
| 235 | python -c "import coremltools as ct; model = ct.convert('model.onnx'); model.save('model.mlpackage')" |
| 236 | |
| 237 | |
| 238 | ### Step 6: Benchmark Optimized Model |
| 239 | |
| 240 | |
| 241 | python scripts/inference_optimizer.py model.engine \ |
| 242 | --benchmark \ |
| 243 | --runtime tensorrt \ |
| 244 | --compare model.pt |
| 245 | |
| 246 | |
| 247 | Expected speedup: |
| 248 | |
| 249 | |
| 250 | Optimization Results: |
| 251 | - Original (PyTorch FP32): 45.2ms |
| 252 | - Optimized (TensorRT FP16): 12.8ms |
| 253 | - Speedup: 3.5x |
| 254 | - Accuracy change: -0.3% mAP |
| 255 | |
| 256 | |
| 257 | ## Workflow 3: Custom Dataset Preparation |
| 258 | |
| 259 | Use this workflow when preparing a computer vision dataset for training. |
| 260 | |
| 261 | ### Step 1: Audit Raw Data |
| 262 | |
| 263 | |
| 264 | # Analyze image dataset |
| 265 | python scripts/dataset_pipeline_builder.py data/raw/ \ |
| 266 | --analyze \ |
| 267 | --output analysis/ |
| 268 | |
| 269 | |
| 270 | Analysis report includes: |
| 271 | |
| 272 | |
| 273 | Dataset Analysis: |
| 274 | - Total images: 5,234 |
| 275 | - Image sizes: 640x480 to 4096x3072 (variable) |
| 276 | - Formats: JPEG (4,891), PNG (343) |
| 277 | - Corrupted: 12 files |
| 278 | - Duplicates: 45 pairs |
| 279 | |
| 280 | Annotation Analysis: |
| 281 | - Format detected: Pascal VOC XML |
| 282 | - Total annotations: 28,456 |
| 283 | - Classes: 5 (car, person, bicycle, dog, cat) |
| 284 | - Distribution: car (12,340), person (8,234), bicycle (3,456), dog (2,890), cat (1,536) |
| 285 | - Empty images: 234 |
| 286 | |
| 287 | |
| 288 | ### Step 2: Clean and Validate |
| 289 | |
| 290 | |
| 291 | # Remove corrupted and duplicate images |
| 292 | python scripts/dataset_pipeline_builder.py data/raw/ \ |
| 293 | --clean \ |
| 294 | --remove-corrupted \ |
| 295 | --remove-duplicates \ |
| 296 | --output data/cleaned/ |
| 297 | |
| 298 | |
| 299 | ### Step 3: Convert Annotation Format |
| 300 | |
| 301 | |
| 302 | # Convert VOC to COCO format |
| 303 | python scripts/dataset_pipeline_builder.py data/cleaned/ \ |
| 304 | --annotations data/annotations/ \ |
| 305 | --input-format voc \ |
| 306 | --output-format coco \ |
| 307 | --output data/coco/ |
| 308 | |
| 309 | |
| 310 | Supported format conversions: |
| 311 | |
| 312 | | From | To | |
| 313 | |------|-----| |
| 314 | | Pascal VOC XML | COCO JSON | |
| 315 | | YOLO TXT | COCO JSON | |
| 316 | | COCO JSON | YOLO TXT | |
| 317 | | LabelMe JSON | COCO JSON | |
| 318 | | CVAT XML | COCO JSON | |
| 319 | |
| 320 | ### Step 4: Apply Augmentations |
| 321 | |
| 322 | |
| 323 | # Generate augmentation config |
| 324 | python scripts/dataset_pipeline_builder.py data/coco/ \ |
| 325 | --augment \ |
| 326 | --aug-config configs/augmentation.yaml \ |
| 327 | --output data/augmented/ |
| 328 | |
| 329 | |
| 330 | Recommended augmentations for detection: |
| 331 | |
| 332 | |
| 333 | # configs/augmentation.yaml |
| 334 | augmentations: |
| 335 | geometric: |
| 336 | - horizontal_flip: { p: 0.5 } |
| 337 | - vertical_flip: { p: 0.1 } # Only if orientation invariant |
| 338 | - rotate: { limit: 15, p: 0.3 } |
| 339 | - scale: { scale_limit: 0.2, p: 0.5 } |
| 340 | |
| 341 | color: |
| 342 | - brightness_contrast: { brightness_limit: 0.2, contrast_limit: 0.2, p: 0.5 } |
| 343 | - hue_saturation: { hue_shift_limit: 20, sat_shift_limit: 30, p: 0.3 } |
| 344 | - blur: { blur_limit: 3, p: 0.1 } |
| 345 | |
| 346 | advanced: |
| 347 | - mosaic: { p: 0.5 } # YOLO-style mosaic |
| 348 | - mixup: { p: 0.1 } # Image mixing |
| 349 | - cutout: { num_holes: 8, max_h_size: 32, max_w_size: 32, p: 0.3 } |
| 350 | |
| 351 | |
| 352 | ### Step 5: Create Train/Val/Test Splits |
| 353 | |
| 354 | |
| 355 | python scripts/dataset_pipeline_builder.py data/augmented/ \ |
| 356 | --split 0.8 0.1 0.1 \ |
| 357 | --stratify \ |
| 358 | --seed 42 \ |
| 359 | --output data/final/ |
| 360 | |
| 361 | |
| 362 | Split strategy guidelines: |
| 363 | |
| 364 | | Dataset Size | Train | Val | Test | |
| 365 | |--------------|-------|-----|------| |
| 366 | | <1,000 images | 70% | 15% | 15% | |
| 367 | | 1,000-10,000 | 80% | 10% | 10% | |
| 368 | | >10,000 | 90% | 5% | 5% | |
| 369 | |
| 370 | ### Step 6: Generate Dataset Configuration |
| 371 | |
| 372 | |
| 373 | # For Ultralytics YOLO |
| 374 | python scripts/dataset_pipeline_builder.py data/final/ \ |
| 375 | --generate-config yolo \ |
| 376 | --output data.yaml |
| 377 | |
| 378 | # For Detectron2 |
| 379 | python scripts/dataset_pipeline_builder.py data/final/ \ |
| 380 | --generate-config detectron2 \ |
| 381 | --output detectron2_config.py |
| 382 | |
| 383 | |
| 384 | ## Architecture Selection Guide |
| 385 | |
| 386 | ### Object Detection Architectures |
| 387 | |
| 388 | | Architecture | Speed | Accuracy | Best For | |
| 389 | |--------------|-------|----------|----------| |
| 390 | | YOLOv8n | 1.2ms | 37.3 mAP | Edge, mobile, real-time | |
| 391 | | YOLOv8s | 2.1ms | 44.9 mAP | Balanced speed/accuracy | |
| 392 | | YOLOv8m | 4.2ms | 50.2 mAP | General purpose | |
| 393 | | YOLOv8l | 6.8ms | 52.9 mAP | High accuracy | |
| 394 | | YOLOv8x | 10.1ms | 53.9 mAP | Maximum accuracy | |
| 395 | | RT-DETR-L | 5.3ms | 53.0 mAP | Transformer, no NMS | |
| 396 | | Faster R-CNN R50 | 46ms | 40.2 mAP | Two-stage, high quality | |
| 397 | | DINO-4scale | 85ms | 49.0 mAP | SOTA transformer | |
| 398 | |
| 399 | ### Segmentation Architectures |
| 400 | |
| 401 | | Architecture | Type | Speed | Best For | |
| 402 | |--------------|------|-------|----------| |
| 403 | | YOLOv8-seg | Instance | 4.5ms | Real-time instance seg | |
| 404 | | Mask R-CNN | Instance | 67ms | High-quality masks | |
| 405 | | SAM | Promptable | 50ms | Zero-shot segmentation | |
| 406 | | DeepLabV3+ | Semantic | 25ms | Scene parsing | |
| 407 | | SegFormer | Semantic | 15ms | Efficient semantic seg | |
| 408 | |
| 409 | ### CNN vs Vision Transformer Trade-offs |
| 410 | |
| 411 | | Aspect | CNN (YOLO, R-CNN) | ViT (DETR, DINO) | |
| 412 | |--------|-------------------|------------------| |
| 413 | | Training data needed | 1K-10K images | 10K-100K+ images | |
| 414 | | Training time | Fast | Slow (needs more epochs) | |
| 415 | | Inference speed | Faster | Slower | |
| 416 | | Small objects | Good with FPN | Needs multi-scale | |
| 417 | | Global context | Limited | Excellent | |
| 418 | | Positional encoding | Implicit | Explicit | |
| 419 | |
| 420 | ## Reference Documentation |
| 421 | → See references/reference-docs-and-commands.md for details |
| 422 | |
| 423 | ## Performance Targets |
| 424 | |
| 425 | | Metric | Real-time | High Accuracy | Edge | |
| 426 | |--------|-----------|---------------|------| |
| 427 | | FPS | >30 | >10 | >15 | |
| 428 | | mAP@50 | >0.6 | >0.8 | >0.5 | |
| 429 | | Latency P99 | <50ms | <150ms | <100ms | |
| 430 | | GPU Memory | <4GB | <8GB | <2GB | |
| 431 | | Model Size | <50MB | <200MB | <20MB | |
| 432 | |
| 433 | ## Resources |
| 434 | |
| 435 | **Architecture Guide**: `references/computer_vision_architectures.md` |
| 436 | **Optimization Guide**: `references/object_detection_optimization.md` |
| 437 | **Deployment Guide**: `references/production_vision_systems.md` |
| 438 | **Scripts**: `scripts/` directory for automation tools |
| 439 |
Discussion
Browse more free Claude skills or everything in Data & analytics.