LWWZH commited on
Commit
3d6784f
Β·
verified Β·
1 Parent(s): 8567570

Upload safetensors format model file

Browse files
Files changed (2) hide show
  1. Mini-Vision-V3.safetensors +3 -0
  2. README.md +121 -120
Mini-Vision-V3.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f2de3c3bb054f22a779b1e3965a7af97c9dc3fbb515e0edb07ffaa4e021aa1ac
3
+ size 1605284
README.md CHANGED
@@ -1,121 +1,122 @@
1
- ---
2
- license: mit
3
- library_name: pytorch
4
- tags:
5
- - image-classification
6
- - emnist
7
- - cnn
8
- - computer-vision
9
- - pytorch
10
- - mini-vision
11
- - mini-vision-series
12
- metrics:
13
- - accuracy
14
- pipeline_tag: image-classification
15
- datasets:
16
- - emnist
17
- ---
18
-
19
- # Mini-Vision-V3: EMNIST Balanced Handwritten Character Classifier
20
-
21
- ![Model Size](https://img.shields.io/badge/Params-0.40M-blue) ![Accuracy](https://img.shields.io/badge/Accuracy-90.06%25-green)
22
-
23
- Welcome to **Mini-Vision-V3**, the third model in the Mini-Vision series. Following the MNIST digit recognition task in V2, this model expands capabilities to **47 classes** of handwritten characters (Digits & Uppercase & Lowercase letters) using the EMNIST Balanced dataset. It features a deeper yet highly efficient 3-layer CNN architecture, achieving over 90% accuracy with less than half a million parameters.
24
-
25
- ## Model Description
26
-
27
- Mini-Vision-V3 is a custom 3-layer CNN architecture tailored for 28x28 grayscale images. While maintaining a lightweight footprint with only **0.40M parameters** (half the size of V2), it handles the significantly increased complexity of 47 character classes. This project demonstrates how depth and Batch Normalization can improve performance on more complex classification tasks without increasing model size.
28
-
29
- - **Dataset**: [EMNIST Balanced](https://www.nist.gov/itl/products-and-services/emnist-dataset) (28x28 grayscale images, 47 classes)
30
- - **Framework**: PyTorch
31
- - **Total Parameters**: 0.40M
32
-
33
- ## Model Architecture
34
-
35
- The network utilizes a deeper structure compared to V2, featuring three convolutional blocks. This allows for better feature extraction in the more complex 47-class task.
36
-
37
- | Layer | Input Channels | Output Channels | Kernel Size | Stride | Padding | Activation | Other |
38
- | :--- | :---: | :---: | :---: | :---: | :---: | :--- | :--- |
39
- | **Conv Block 1** | 1 | 32 | 3 | 1 | 1 | ReLU | MaxPool(2), BatchNorm |
40
- | **Conv Block 2** | 32 | 64 | 3 | 1 | 1 | ReLU | MaxPool(2), BatchNorm |
41
- | **Conv Block 3** | 64 | 128 | 3 | 1 | 1 | ReLU | MaxPool(2), BatchNorm |
42
- | **Flatten** | - | - | - | - | - | - | Output: 1152 |
43
- | **Linear 1** | 1152 | 256 | - | - | - | ReLU | Dropout(0.3) |
44
- | **Linear 2** | 256 | 47 | - | - | - | - | - |
45
-
46
- ## Training Strategy
47
-
48
- The training strategy was adjusted for the larger dataset and increased class complexity, utilizing a higher initial learning rate and a StepLR scheduler for convergence.
49
-
50
- - **Optimizer**: SGD (Momentum=0.8)
51
- - **Initial Learning Rate**: 0.05
52
- - **Scheduler**: StepLR (Step size=5, Gamma=0.5)
53
- - **Loss Function**: CrossEntropyLoss
54
- - **Batch Size**: 256
55
- - **Epochs**: 50 (Best model at Epoch 40)
56
- - **Data Preprocessing**:
57
- - EMNIST specific alignment: Rotate -90 degrees and Flip Horizontal (to match standard image orientation).
58
- - Random Crop (28x28 with padding=2)
59
- - Random Rotation (10 degrees)
60
-
61
- ## Performance
62
-
63
- The model achieved solid results on the EMNIST Balanced test set (18800 samples), selected based on the best performing epoch (Epoch 40):
64
-
65
- | Metric | Value |
66
- | :--- | :---: |
67
- | **Test Accuracy** | **90.06%** |
68
- | Test Loss | 0.28 |
69
- | Train Loss | 0.28 |
70
- | Parameters | 0.40M |
71
-
72
- ### Training Visualization (TensorBoard)
73
-
74
- Below are the training and testing curves visualized via TensorBoard.
75
-
76
- #### 1. Training Loss
77
-
78
- ![Training Loss](assets/train_loss.png)
79
- *(Recorded every epoch)*
80
-
81
- #### 2. Test Loss & Accuracy
82
- ![Test Loss](assets/test_loss.png)
83
- *(Recorded every epoch)*
84
-
85
- ## Quick Start
86
-
87
- ### Dependencies
88
- - Python 3.x
89
- - PyTorch
90
- - Torchvision
91
- - Gradio (for demo)
92
- - Pillow
93
-
94
- ### Inference / Web Demo
95
-
96
- Run the Gradio demo to draw characters and see predictions in real-time:
97
-
98
- ```bash
99
- python demo.py
100
- ```
101
-
102
- *Note: The demo supports inverted drawing (white ink on black background) to match the EMNIST format.*
103
-
104
- ## File Structure
105
-
106
- ```
107
- .
108
- β”œβ”€β”€ model.py # Model architecture definition (MiniVisionV3)
109
- β”œβ”€β”€ train.py # Training script
110
- β”œβ”€β”€ demo.py # Gradio Web Interface
111
- β”œβ”€β”€ Mini-Vision-V3.pth # Trained model weights (Epoch 40)
112
- β”œβ”€β”€ config.json
113
- β”œβ”€β”€ README.md
114
- └── assets
115
- β”œβ”€β”€ train_loss.png # Visualized train loss graph
116
- └── test_loss.png # Visualized test loss graph
117
- ```
118
-
119
- ## License
120
-
 
121
  This project is licensed under the MIT License.
 
1
+ ---
2
+ license: mit
3
+ library_name: pytorch
4
+ tags:
5
+ - image-classification
6
+ - emnist
7
+ - cnn
8
+ - computer-vision
9
+ - pytorch
10
+ - mini-vision
11
+ - mini-vision-series
12
+ metrics:
13
+ - accuracy
14
+ pipeline_tag: image-classification
15
+ datasets:
16
+ - emnist
17
+ ---
18
+
19
+ # Mini-Vision-V3: EMNIST Balanced Handwritten Character Classifier
20
+
21
+ ![Model Size](https://img.shields.io/badge/Params-0.40M-blue) ![Accuracy](https://img.shields.io/badge/Accuracy-90.06%25-green)
22
+
23
+ Welcome to **Mini-Vision-V3**, the third model in the Mini-Vision series. Following the MNIST digit recognition task in V2, this model expands capabilities to **47 classes** of handwritten characters (Digits & Uppercase & Lowercase letters) using the EMNIST Balanced dataset. It features a deeper yet highly efficient 3-layer CNN architecture, achieving over 90% accuracy with less than half a million parameters.
24
+
25
+ ## Model Description
26
+
27
+ Mini-Vision-V3 is a custom 3-layer CNN architecture tailored for 28x28 grayscale images. While maintaining a lightweight footprint with only **0.40M parameters** (half the size of V2), it handles the significantly increased complexity of 47 character classes. This project demonstrates how depth and Batch Normalization can improve performance on more complex classification tasks without increasing model size.
28
+
29
+ - **Dataset**: [EMNIST Balanced](https://www.nist.gov/itl/products-and-services/emnist-dataset) (28x28 grayscale images, 47 classes)
30
+ - **Framework**: PyTorch
31
+ - **Total Parameters**: 0.40M
32
+
33
+ ## Model Architecture
34
+
35
+ The network utilizes a deeper structure compared to V2, featuring three convolutional blocks. This allows for better feature extraction in the more complex 47-class task.
36
+
37
+ | Layer | Input Channels | Output Channels | Kernel Size | Stride | Padding | Activation | Other |
38
+ | :--- | :---: | :---: | :---: | :---: | :---: | :--- | :--- |
39
+ | **Conv Block 1** | 1 | 32 | 3 | 1 | 1 | ReLU | MaxPool(2), BatchNorm |
40
+ | **Conv Block 2** | 32 | 64 | 3 | 1 | 1 | ReLU | MaxPool(2), BatchNorm |
41
+ | **Conv Block 3** | 64 | 128 | 3 | 1 | 1 | ReLU | MaxPool(2), BatchNorm |
42
+ | **Flatten** | - | - | - | - | - | - | Output: 1152 |
43
+ | **Linear 1** | 1152 | 256 | - | - | - | ReLU | Dropout(0.3) |
44
+ | **Linear 2** | 256 | 47 | - | - | - | - | - |
45
+
46
+ ## Training Strategy
47
+
48
+ The training strategy was adjusted for the larger dataset and increased class complexity, utilizing a higher initial learning rate and a StepLR scheduler for convergence.
49
+
50
+ - **Optimizer**: SGD (Momentum=0.8)
51
+ - **Initial Learning Rate**: 0.05
52
+ - **Scheduler**: StepLR (Step size=5, Gamma=0.5)
53
+ - **Loss Function**: CrossEntropyLoss
54
+ - **Batch Size**: 256
55
+ - **Epochs**: 50 (Best model at Epoch 40)
56
+ - **Data Preprocessing**:
57
+ - EMNIST specific alignment: Rotate -90 degrees and Flip Horizontal (to match standard image orientation).
58
+ - Random Crop (28x28 with padding=2)
59
+ - Random Rotation (10 degrees)
60
+
61
+ ## Performance
62
+
63
+ The model achieved solid results on the EMNIST Balanced test set (18800 samples), selected based on the best performing epoch (Epoch 40):
64
+
65
+ | Metric | Value |
66
+ | :--- | :---: |
67
+ | **Test Accuracy** | **90.06%** |
68
+ | Test Loss | 0.28 |
69
+ | Train Loss | 0.28 |
70
+ | Parameters | 0.40M |
71
+
72
+ ### Training Visualization (TensorBoard)
73
+
74
+ Below are the training and testing curves visualized via TensorBoard.
75
+
76
+ #### 1. Training Loss
77
+
78
+ ![Training Loss](assets/train_loss.png)
79
+ *(Recorded every epoch)*
80
+
81
+ #### 2. Test Loss & Accuracy
82
+ ![Test Loss](assets/test_loss.png)
83
+ *(Recorded every epoch)*
84
+
85
+ ## Quick Start
86
+
87
+ ### Dependencies
88
+ - Python 3.x
89
+ - PyTorch
90
+ - Torchvision
91
+ - Gradio (for demo)
92
+ - Pillow
93
+
94
+ ### Inference / Web Demo
95
+
96
+ Run the Gradio demo to draw characters and see predictions in real-time:
97
+
98
+ ```bash
99
+ python demo.py
100
+ ```
101
+
102
+ *Note: The demo supports inverted drawing (white ink on black background) to match the EMNIST format.*
103
+
104
+ ## File Structure
105
+
106
+ ```
107
+ .
108
+ β”œβ”€β”€ model.py # Model architecture definition (MiniVisionV3)
109
+ β”œβ”€β”€ train.py # Training script
110
+ β”œβ”€β”€ demo.py # Gradio Web Interface
111
+ β”œβ”€β”€ Mini-Vision-V3.pth # Trained model weights (Epoch 40)
112
+ β”œβ”€β”€ Mini-Vision-V3.safetensors # Safetensors format model weights
113
+ β”œβ”€β”€ config.json
114
+ β”œβ”€β”€ README.md
115
+ └── assets
116
+ β”œβ”€β”€ train_loss.png # Visualized train loss graph
117
+ └── test_loss.png # Visualized test loss graph
118
+ ```
119
+
120
+ ## License
121
+
122
  This project is licensed under the MIT License.