| # LiteCNNPro Model - Pure C++ Inference |
|
|
| **Ultra-lightweight CNN model for dog breed classification** |
|
|
| ## Model Details |
|
|
| - **Model**: LiteCNNPro (Pure C++ implementation) |
| - **Parameters**: 600K |
| - **Classes**: 120 (Stanford Dogs dataset) |
| - **Input**: 224Γ224 RGB images |
| - **Framework**: PyTorch (training) β Pure C++ (inference) |
| - **Memory**: 26MB total (4MB weights + 22MB runtime) |
|
|
| ## Architecture |
|
|
| ``` |
| Stem: Conv2D(3β32) + BatchNorm + ReLU6 |
| Features: 7Γ Depthwise Separable Conv blocks |
| - Block 0: 32β64 (stride 2) |
| - Block 1: 64β128 (stride 2) |
| - Block 2-3: 128β256 (stride 2) |
| - Block 4-6: 256β512 |
| - SE (Squeeze-Excitation) attention in each block |
| Classifier: AdaptiveAvgPool β FC(512β256) β FC(256β120) |
| ``` |
|
|
| ## Usage |
|
|
| ### Download Model |
|
|
| ```bash |
| wget https://huggingface.co/2c6829/litecnn-pure-cpp/resolve/main/model_weights.bin |
| wget https://huggingface.co/2c6829/litecnn-pure-cpp/resolve/main/breed_classes.json |
| ``` |
|
|
| ### Build and Run |
|
|
| ```bash |
| # Clone the inference server |
| git clone https://github.com/stupidcoderJung/litecnn-pure-cpp |
| cd litecnn-pure-cpp |
| |
| # Place model files |
| mv model_weights.bin weights/ |
| mv breed_classes.json . |
| |
| # Build |
| mkdir -p build && cd build |
| cmake .. -DCMAKE_BUILD_TYPE=Release |
| make -j4 |
| |
| # Run server |
| ./litecnn_server --port 8080 |
| ``` |
|
|
| ### API Example |
|
|
| ```bash |
| # Health check |
| curl http://localhost:8080/health |
| |
| # Predict |
| curl -X POST http://localhost:8080/predict \ |
| -F "image=@dog.jpg" |
| ``` |
|
|
| **Response**: |
| ```json |
| { |
| "predictions": [ |
| { |
| "class_id": 81, |
| "score": 0.95, |
| "breed_en": "Border collie", |
| "breed_ko": "보λ μ½λ¦¬" |
| } |
| ] |
| } |
| ``` |
|
|
| ## Performance |
|
|
| | Metric | Value | |
| |--------|-------| |
| | Memory (RSS) | 26 MB | |
| | Binary Size | 803 KB | |
| | Weights Size | 4.0 MB | |
| | Inference Time | <100ms (CPU) | |
|
|
| **Comparison**: |
| - PyTorch: 322 MB β **92% reduction** β
|
| - LibTorch: 130 MB β **80% reduction** β
|
| - ONNX Runtime: 102 MB β **75% reduction** β
|
|
|
| ## Files |
|
|
| - `model_weights.bin` (4.0 MB) - Model weights in binary format |
| - `breed_classes.json` (7.4 KB) - 120 dog breeds (English + Korean) |
| - `extract_weights.py` - PyTorch checkpoint β binary converter |
|
|
| ## Training |
|
|
| The model was trained on the Stanford Dogs dataset with: |
| - Optimizer: AdamW |
| - Learning rate: 1e-3 |
| - Augmentation: Random flip, rotation, color jitter |
| - Epochs: 50 |
| - Best validation accuracy: ~85% |
|
|
| ## License |
|
|
| MIT License |
|
|
| ## Citation |
|
|
| ```bibtex |
| @software{litecnn_pure_cpp_2026, |
| author = {LiteCNN Team}, |
| title = {LiteCNN Pure C++ Inference Server}, |
| year = {2026}, |
| url = {https://github.com/stupidcoderJung/litecnn-pure-cpp} |
| } |
| ``` |
|
|
| ## Contact |
|
|
| - Repository: https://github.com/stupidcoderJung/litecnn-pure-cpp |
| - Issues: https://github.com/stupidcoderJung/litecnn-pure-cpp/issues |
|
|