The 3-Tier API Architecture
Release Notes v2.0.0
🚀 Major Release: The 3-Tier API Architecture
Version 2.0.0 represents a complete paradigm shift for torchvision-customizer. We have moved away from the monolithic CustomCNN class to a flexible, component-based 3-tier architecture that offers unprecedented control over model design.
✨ Key Features
1. Tier 1: Component Registry 🗂️
The new registry system serves as the single source of truth for all building blocks.
- Unified Discovery:
registry.list('block')to find all available components. - Easy Access:
registry.get('residual')returns the class directly. - Extensible: Easily register your own components with
@registry.register.
2. Tier 2: Architecture Recipes 📜
A declarative way to define models using human-readable strings. Perfect for config-driven experiments.
- String Definitions:
"residual(64) x 2 | downsample" - Serialization: Recipes can be saved/loaded from YAML/JSON.
- Safety: Automated parsing ensures valid arguments.
3. Tier 3: Model Composer 🎼
A fluent, pythonic API for building models programmatically.
- Operator Overloading: Use
>>for sequential connection,|for branching, and*for repetition. - Context Awareness:
StageandHeadautomatically infer input channels. - Mix & Match: Combine different patterns (e.g.,
'residual+se') in a single stage.
4. Parametric Templates 🏗️
We have re-implemented standard architectures from scratch to be fully parametric and customizable. No pre-trained weights, just pure architectural flexibility.
- ResNet: 18, 34, 50, 101, 152 (Basic & Bottleneck)
- VGG: 11, 13, 16, 19
- MobileNet: V1, V2, V3 (Small/Large)
- DenseNet: 121, 169, 201, 264
- EfficientNet: B0-B7
💥 Breaking Changes
- Removed
CustomCNN: The legacyCustomCNNclass and the oldtorchvision_customizer.modelsmodule have been removed. Please migrate toRecipeorCompose. - Python Version: Minimum Python version lowered to 3.9 (previously 3.13) for better compatibility.
🛠️ Improvements
- Model Introspection: Added
model.explain()for a beautiful, ASCII-art summary of your custom architecture. - Windows Support: Fixed character encoding issues in model visualization.
- Strict Typing: Comprehensive type hints across the entire codebase.
- Documentation: Completely rewritten documentation to reflect the new API tiers.
📦 Quick Example
Before (v1.x):
model = CustomCNN(layers=50, architecture='resnet') # Limited customizationAfter (v2.0):
# Declarative
recipe = Recipe(stem="conv(64)", stages=["residual(64) x 3"], head="linear(10)")
model = build_recipe(recipe)
# OR Fluent
model = Stem(64) >> Stage(64, blocks=3, pattern='residual') >> Head(10)🔗 Contributors
- @codewithdark-git (Architecture & Implementation)