Upload config.yaml with huggingface_hub
Browse files- config.yaml +145 -0
config.yaml
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Food Image Classifier Configuration
|
| 2 |
+
project:
|
| 3 |
+
name: "food_image_classifier"
|
| 4 |
+
version: "1.0.0"
|
| 5 |
+
description: "World-Class Food Image Classifier with Hybrid CNN-ViT Architecture"
|
| 6 |
+
|
| 7 |
+
# Hardware Configuration
|
| 8 |
+
hardware:
|
| 9 |
+
device: "cuda" # RTX 5060 Laptop GPU
|
| 10 |
+
mixed_precision: true
|
| 11 |
+
compile_model: true
|
| 12 |
+
num_workers: 4
|
| 13 |
+
pin_memory: true
|
| 14 |
+
|
| 15 |
+
# Data Configuration
|
| 16 |
+
data:
|
| 17 |
+
image_size: 224
|
| 18 |
+
batch_size: 32 # Reduced to avoid memory issues
|
| 19 |
+
num_classes: 101 # Food101 dataset: 101 classes, 1000 images per class
|
| 20 |
+
datasets:
|
| 21 |
+
- name: "food101"
|
| 22 |
+
source: "kaggle"
|
| 23 |
+
path: "data/raw/food101"
|
| 24 |
+
# Temporarily disabled HuggingFace dataset to use only Food101
|
| 25 |
+
# - name: "food_images_hf"
|
| 26 |
+
# source: "huggingface"
|
| 27 |
+
# path: "data/raw/food_images_hf"
|
| 28 |
+
|
| 29 |
+
# Data splits
|
| 30 |
+
train_ratio: 0.8
|
| 31 |
+
val_ratio: 0.15
|
| 32 |
+
test_ratio: 0.05
|
| 33 |
+
|
| 34 |
+
# Augmentation
|
| 35 |
+
augmentation:
|
| 36 |
+
horizontal_flip: 0.5
|
| 37 |
+
rotation: 15
|
| 38 |
+
color_jitter:
|
| 39 |
+
brightness: 0.2
|
| 40 |
+
contrast: 0.2
|
| 41 |
+
saturation: 0.2
|
| 42 |
+
hue: 0.1
|
| 43 |
+
normalize:
|
| 44 |
+
mean: [0.485, 0.456, 0.406]
|
| 45 |
+
std: [0.229, 0.224, 0.225]
|
| 46 |
+
|
| 47 |
+
# Model Configuration
|
| 48 |
+
model:
|
| 49 |
+
architecture: "hybrid_cnn_vit"
|
| 50 |
+
|
| 51 |
+
# CNN Branch (ResNet50)
|
| 52 |
+
cnn:
|
| 53 |
+
backbone: "resnet50"
|
| 54 |
+
pretrained: true
|
| 55 |
+
freeze_early_layers: true
|
| 56 |
+
dropout: 0.3
|
| 57 |
+
|
| 58 |
+
# ViT Branch (DeiT-Base)
|
| 59 |
+
vit:
|
| 60 |
+
model_name: "facebook/deit-base-distilled-patch16-224"
|
| 61 |
+
pretrained: true
|
| 62 |
+
freeze_early_layers: true
|
| 63 |
+
dropout: 0.1
|
| 64 |
+
|
| 65 |
+
# Fusion Module
|
| 66 |
+
fusion:
|
| 67 |
+
hidden_dim: 512
|
| 68 |
+
num_heads: 8
|
| 69 |
+
dropout: 0.2
|
| 70 |
+
|
| 71 |
+
# Classification Head
|
| 72 |
+
head:
|
| 73 |
+
hidden_dims: [1024, 512]
|
| 74 |
+
dropout: 0.4
|
| 75 |
+
|
| 76 |
+
# Training Configuration
|
| 77 |
+
training:
|
| 78 |
+
epochs: 100 # Increased for comprehensive training with 101k images
|
| 79 |
+
learning_rate: 1e-4
|
| 80 |
+
weight_decay: 1e-5
|
| 81 |
+
|
| 82 |
+
# Optimizer
|
| 83 |
+
optimizer:
|
| 84 |
+
type: "adamw"
|
| 85 |
+
betas: [0.9, 0.999]
|
| 86 |
+
eps: 1e-8
|
| 87 |
+
|
| 88 |
+
# Learning Rate Scheduler
|
| 89 |
+
scheduler:
|
| 90 |
+
type: "cosine_annealing_warm_restarts"
|
| 91 |
+
T_0: 10
|
| 92 |
+
T_mult: 2
|
| 93 |
+
eta_min: 1e-6
|
| 94 |
+
|
| 95 |
+
# Loss Function
|
| 96 |
+
loss:
|
| 97 |
+
type: "label_smoothing_cross_entropy"
|
| 98 |
+
smoothing: 0.1
|
| 99 |
+
|
| 100 |
+
# Advanced Training Techniques
|
| 101 |
+
ema:
|
| 102 |
+
enabled: true
|
| 103 |
+
decay: 0.9999
|
| 104 |
+
|
| 105 |
+
gradient_clipping:
|
| 106 |
+
enabled: true
|
| 107 |
+
max_norm: 1.0
|
| 108 |
+
|
| 109 |
+
early_stopping:
|
| 110 |
+
enabled: true
|
| 111 |
+
patience: 10
|
| 112 |
+
min_delta: 0.001
|
| 113 |
+
|
| 114 |
+
# Evaluation Configuration
|
| 115 |
+
evaluation:
|
| 116 |
+
metrics:
|
| 117 |
+
- "accuracy"
|
| 118 |
+
- "top5_accuracy"
|
| 119 |
+
- "f1_score"
|
| 120 |
+
- "precision"
|
| 121 |
+
- "recall"
|
| 122 |
+
|
| 123 |
+
save_confusion_matrix: true
|
| 124 |
+
save_classification_report: true
|
| 125 |
+
|
| 126 |
+
# Logging Configuration
|
| 127 |
+
logging:
|
| 128 |
+
tensorboard:
|
| 129 |
+
enabled: true
|
| 130 |
+
log_dir: "runs"
|
| 131 |
+
|
| 132 |
+
wandb:
|
| 133 |
+
enabled: false # Set to true if you want to use wandb
|
| 134 |
+
project: "food_classifier"
|
| 135 |
+
|
| 136 |
+
checkpoint:
|
| 137 |
+
save_best: true
|
| 138 |
+
save_last: true
|
| 139 |
+
save_every_n_epochs: 10
|
| 140 |
+
|
| 141 |
+
# API Keys (will be loaded from environment)
|
| 142 |
+
api_keys:
|
| 143 |
+
kaggle_username: "${KAGGLE_USERNAME}"
|
| 144 |
+
kaggle_key: "${KAGGLE_KEY}"
|
| 145 |
+
huggingface_token: "${HF_TOKEN}"
|