Train a Vision Transformer (ViT) for custom image classification with data augmentation, transfer learning, and ONNX export.
You are a computer vision engineer. Build a ViT image classification training pipeline. ## Configuration - **Base Model**: [BASE e.g. google/vit-large-patch16-384 / DINOv2 / EVA-02] - **Dataset**: [DATASET e.g. custom image folder / HuggingFace dataset / COCO subset] - **Num Classes**: [CLASSES e.g. 10 / 50 / 200] - **Image Size**: [SIZE e.g. 224 / 384 / 512] - **Hardware**: [HARDWARE e.g. single V100 / 4x A100] ## Pipeline ### 1. Dataset Pipeline (`data/`) - Load images from [DATASET] with train/val/test splits - Augmentation pipeline: - RandomResizedCrop to [SIZE]x[SIZE] - RandomHorizontalFlip, RandomVerticalFlip - ColorJitter (brightness, contrast, saturation, hue) - RandAugment with magnitude [MAG e.g. 9] - CutMix and MixUp with probability [PROB e.g. 0.5] - Normalize with ImageNet mean/std - Efficient data loading with num_workers auto-tuning - Class balance analysis and weighted sampling - Dataset visualization with sample grid ### 2. Model Setup (`model/`) - Load [BASE] with pretrained weights - Replace classification head for [CLASSES] - Optional: freeze early layers for transfer learning - Enable gradient checkpointing for memory efficiency - Model size and FLOPS analysis ### 3. Training (`train.py`) - Optimizer: AdamW with weight decay [WD e.g. 0.05] - Learning rate: [LR e.g. 1e-4] with cosine schedule and warmup - Label smoothing: [SMOOTH e.g. 0.1] - EMA model with decay [EMA_DECAY e.g. 0.9999] - Gradient clipping: max norm [CLIP e.g. 1.0] - Mixed precision training (AMP) - Multi-GPU with DDP or FSDP - W&B logging: loss, accuracy, learning rate, sample predictions - Best checkpoint saving based on validation accuracy ### 4. Evaluation (`evaluate.py`) - Top-1 and Top-5 accuracy - Per-class precision, recall, F1 - Confusion matrix heatmap - GradCAM attention visualization - t-SNE visualization of learned features - Inference speed benchmark ### 5. Export (`export/`) - ONNX export with dynamic batching - TensorRT optimization - CoreML conversion for iOS - ONNX Runtime inference wrapper - Model quantization (INT8) comparison Provide all code, configs, and a training report template.
Free to copy and use. Compatible with Claude 4 Opus, GPT-5, Gemini 2.5 Pro, Llama 4 Maverick.
Organize your images in class-named folders. Select a pretrained ViT base model matching your compute budget. Start with frozen backbone, then unfreeze for full fine-tuning if needed.
Initial release
Sign in and download this prompt to leave a review.