felix2703 commited on
Commit
6d74043
Β·
verified Β·
1 Parent(s): 386ccf7

Upload checkpoint and readme file

Browse files
Files changed (2) hide show
  1. README.md +82 -0
  2. TinyCNN_model_acc_98.97.pth +3 -0
README.md ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 🧠 TinyCNN for MNIST (94K params)
2
+
3
+ This repository contains a lightweight Convolutional Neural Network (CNN) designed for the MNIST handwritten digit classification task.
4
+ The model is optimized to be **small, fast, and easy to deploy**, suitable for both research and educational purposes.
5
+
6
+ ---
7
+
8
+ ## πŸ“Œ Model Summary
9
+
10
+ | Attribute | Value |
11
+ |---------|--------|
12
+ | Model Name | **TinyCNN** |
13
+ | Dataset | MNIST (28Γ—28 grayscale digits) |
14
+ | Total Parameters | ~94,410 |
15
+ | Architecture | Conv-BN-ReLU Γ—3 β†’ Global Avg Pool β†’ FC |
16
+ | Input Shape | (1, 28, 28) |
17
+ | Output Classes | 10 |
18
+ | Framework | PyTorch |
19
+
20
+ ---
21
+
22
+ ## πŸ— Architecture Overview
23
+
24
+ **Input**: 1Γ—28Γ—28
25
+
26
+
27
+ **Conv Block 1:** Conv(1β†’32, 3Γ—3) β†’ BatchNorm β†’ ReLU β†’ MaxPool(2Γ—2)
28
+
29
+
30
+ **Conv Block 2:** Conv(32β†’64, 3Γ—3) β†’ BatchNorm β†’ ReLU β†’ MaxPool(2Γ—2)
31
+
32
+ **Conv Block 3:** Conv(64β†’128, 3Γ—3) β†’ BatchNorm β†’ ReLU β†’ MaxPool(2Γ—2)
33
+
34
+ **Global Average Pooling**
35
+
36
+ **Fully Connected Layer** β†’ 10 output classes
37
+
38
+
39
+ This architecture emphasizes parameter efficiency while maintaining strong representation capability.
40
+
41
+ ---
42
+
43
+ ## βš™οΈ Installation
44
+
45
+ ```bash
46
+ pip install torch torchvision
47
+ ```
48
+ ## πŸš€ Load Model From Hub
49
+ ```
50
+ import torch
51
+ from model import TinyCNN # Ensure this file is included in your repo
52
+
53
+ model = TinyCNN(num_classes=10)
54
+
55
+ state_dict = torch.hub.load_state_dict_from_url(
56
+ "https://huggingface.co/<your-username>/<your-model-repo>/resolve/main/tinycnn_mnist.pth"
57
+ )
58
+ model.load_state_dict(state_dict)
59
+ model.eval()
60
+ ```
61
+
62
+ ## πŸ–Ό Example Inference
63
+ ```
64
+ import torch
65
+ from torchvision import transforms
66
+ from PIL import Image
67
+
68
+ transform = transforms.Compose([
69
+ transforms.Grayscale(),
70
+ transforms.Resize((28, 28)),
71
+ transforms.ToTensor()
72
+ ])
73
+
74
+ img = Image.open("digit.png")
75
+ x = transform(img).unsqueeze(0) # shape: (1, 1, 28, 28)
76
+
77
+ with torch.no_grad():
78
+ logits = model(x)
79
+ pred = logits.argmax(dim=1).item()
80
+
81
+ print("Predicted digit:", pred)
82
+ ```
TinyCNN_model_acc_98.97.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:31c1f418a47ad67d224803858c0459d422c7c4252ba92598698242793fd90409
3
+ size 388607