File size: 2,578 Bytes
b3865ae c7b68f0 b3865ae c7b68f0 b3865ae 0776802 c7b68f0 0776802 c7b68f0 0776802 c7b68f0 0776802 c7b68f0 0776802 c7b68f0 0776802 c7b68f0 0776802 c7b68f0 0776802 1c285d4 0776802 c7b68f0 0776802 c7b68f0 1c285d4 c7b68f0 56173d4 c7b68f0 0776802 c7b68f0 56173d4 c7b68f0 0776802 c7b68f0 0776802 c7b68f0 1ce63d0 c7b68f0 0776802 c7b68f0 0776802 c7b68f0 56173d4 0776802 c7b68f0 0776802 c7b68f0 0776802 c7b68f0 0776802 c7b68f0 0776802 c7b68f0 0776802 c7b68f0 |
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 |
---
---
tags:
- image-classification
- cnn
- cifar-10
license: apache-2.0
library_name: pytorch
---
# Tiny CNN Classifier for CIFAR-10
This is a custom **Convolutional Neural Network (CNN)** trained on the **CIFAR-10 dataset**.
It classifies images into 10 categories:
`airplane, automobile, bird, cat, deer, dog, frog, horse, ship, truck`
---
## 📖 Model Overview
- **Type**: Convolutional Neural Network (CNN)
- **Architecture**:
- 2 convolutional layers
- 2 max-pooling layers
- 2 fully connected layers
- ReLU activation functions
- **Dataset**: CIFAR-10 (10 classes)
- **Framework**: PyTorch
- **Test Accuracy**: **69.90%**
- **Training Epochs**: 5
The model uses two convolutional layers followed by max-pooling and fully connected layers to classify images. It was trained using Adam optimizer and Cross-Entropy loss.
---
## How to Use
> ⚠️ Note: This is **not a Hugging Face Transformers model**.
> You **cannot** use `pipeline()`. Instead, load it directly with **PyTorch**.
### 1. Clone the repository
```bash
git clone https://huggingface.co/Udayan012/tiny-cnn-classifier
cd tiny-cnn-classifier
```
### 2. Install Dependencies
```bash
pip install torch torchvision pillow
```
### 3. Load the model
```python
import torch
from model import CustomCNN
# Initialize model and load weights
model = CustomCNN()
model.load_state_dict(torch.load("cnn_model.pth", map_location="cpu"))
model.eval()
```
### 4. Run inference on an image
```python
from torchvision import transforms
from PIL import Image
# CIFAR-10 preprocessing (32x32 RGB)
transform = transforms.Compose([
transforms.Resize((32, 32)),
transforms.ToTensor(),
])
# Load an image
img = Image.open("your_image_path.jpg").convert("RGB")
x = transform(img).unsqueeze(0)
# Predict
with torch.no_grad():
output = model(x)
pred_class = output.argmax(1).item()
classes = ['airplane','automobile','bird','cat','deer','dog','frog','horse','ship','truck']
print("Predicted class:", classes[pred_class])
```
### Training Information
Dataset: CIFAR-10
Optimizer: Adam
Loss Function: Cross-Entropy Loss
Epochs: 5
Batch Size: 32
Learning Rate: 0.001
### Model Limitations
Trained only on CIFAR-10 → works best on 32x32 images with simple backgrounds.
May not generalize well to high-resolution or real-world images.
### License
This model is released under the Apache 2.0 License.
You can freely use, modify, and distribute this model. |