File size: 2,754 Bytes
db8e1bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# 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