Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,89 +1,103 @@
|
|
| 1 |
---
|
|
|
|
| 2 |
tags:
|
| 3 |
- image-classification
|
| 4 |
- cnn
|
| 5 |
- cifar-10
|
| 6 |
license: apache-2.0
|
| 7 |
-
library_name:
|
| 8 |
---
|
| 9 |
-
README.md for tiny-cnn-classifier
|
| 10 |
-
|
| 11 |
-
Tiny CNN Classifier for Image Classification (CIFAR-10)
|
| 12 |
-
|
| 13 |
-
This is a custom Convolutional Neural Network (CNN) model trained on the CIFAR-10 dataset. The model classifies images into 10 categories: airplane, automobile, bird, cat, deer, dog, frog, horse, ship, and truck. It was trained using the PyTorch framework.
|
| 14 |
-
|
| 15 |
-
Model Overview
|
| 16 |
-
|
| 17 |
-
Type: Convolutional Neural Network (CNN)
|
| 18 |
-
|
| 19 |
-
Architecture:
|
| 20 |
-
- 2 convolutional layers
|
| 21 |
-
- 2 max-pooling layers
|
| 22 |
-
- 2 fully connected layers
|
| 23 |
-
- ReLU activation functions
|
| 24 |
-
|
| 25 |
-
Dataset: CIFAR-10 (10 classes)
|
| 26 |
-
|
| 27 |
-
Test Accuracy: 69.90%
|
| 28 |
|
| 29 |
-
|
| 30 |
-
The model uses two convolutional layers followed by max-pooling and fully connected layers to classify images. The model was trained for 5 epochs on the CIFAR-10 dataset.
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
```python
|
| 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 |
-
Training Information
|
| 70 |
|
| 71 |
Dataset: CIFAR-10
|
| 72 |
Optimizer: Adam
|
| 73 |
Loss Function: Cross-Entropy Loss
|
| 74 |
-
|
| 75 |
Batch Size: 32
|
| 76 |
Learning Rate: 0.001
|
| 77 |
|
| 78 |
-
Model Limitations:
|
| 79 |
-
|
| 80 |
-
The model is trained on the CIFAR-10 dataset and performs well on images similar to the CIFAR-10 test set.
|
| 81 |
-
The model may not generalize well to high-resolution images or images with complex backgrounds.
|
| 82 |
-
It performs best on 32x32 pixel images with simple backgrounds, similar to those in the CIFAR-10 dataset.
|
| 83 |
|
|
|
|
| 84 |
|
|
|
|
|
|
|
| 85 |
|
| 86 |
-
License:
|
| 87 |
|
| 88 |
-
|
| 89 |
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
---
|
| 3 |
tags:
|
| 4 |
- image-classification
|
| 5 |
- cnn
|
| 6 |
- cifar-10
|
| 7 |
license: apache-2.0
|
| 8 |
+
library_name: pytorch
|
| 9 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
# Tiny CNN Classifier for CIFAR-10
|
|
|
|
| 12 |
|
| 13 |
+
This is a custom **Convolutional Neural Network (CNN)** trained on the **CIFAR-10 dataset**.
|
| 14 |
+
It classifies images into 10 categories:
|
| 15 |
+
`airplane, automobile, bird, cat, deer, dog, frog, horse, ship, truck`
|
| 16 |
|
| 17 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
## 📖 Model Overview
|
| 20 |
|
| 21 |
+
- **Type**: Convolutional Neural Network (CNN)
|
| 22 |
+
- **Architecture**:
|
| 23 |
+
- 2 convolutional layers
|
| 24 |
+
- 2 max-pooling layers
|
| 25 |
+
- 2 fully connected layers
|
| 26 |
+
- ReLU activation functions
|
| 27 |
+
- **Dataset**: CIFAR-10 (10 classes)
|
| 28 |
+
- **Framework**: PyTorch
|
| 29 |
+
- **Test Accuracy**: **69.90%**
|
| 30 |
+
- **Training Epochs**: 5
|
| 31 |
|
| 32 |
+
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.
|
| 33 |
|
| 34 |
+
---
|
| 35 |
|
| 36 |
+
## 🚀 How to Use
|
| 37 |
|
| 38 |
+
> ⚠️ Note: This is **not a Hugging Face Transformers model**.
|
| 39 |
+
> You **cannot** use `pipeline()`. Instead, load it directly with **PyTorch**.
|
| 40 |
|
| 41 |
+
### 1. Clone the repository
|
| 42 |
+
```bash
|
| 43 |
+
git clone https://huggingface.co/Udayan012/tiny-cnn-classifier
|
| 44 |
+
cd tiny-cnn-classifier
|
| 45 |
|
| 46 |
+
### 2. Install Dependencies
|
| 47 |
+
```bash
|
| 48 |
+
pip install torch torchvision pillow
|
| 49 |
|
| 50 |
+
### 3. Load the model
|
| 51 |
+
```python
|
| 52 |
+
import torch
|
| 53 |
+
from model import CustomCNN
|
| 54 |
|
| 55 |
+
# Initialize model and load weights
|
| 56 |
+
model = CustomCNN()
|
| 57 |
+
model.load_state_dict(torch.load("cnn_model.pth", map_location="cpu"))
|
| 58 |
+
model.eval()
|
| 59 |
|
| 60 |
+
### 4. Run inference on an image
|
| 61 |
+
```python
|
| 62 |
+
from torchvision import transforms
|
| 63 |
+
from PIL import Image
|
| 64 |
|
| 65 |
+
# CIFAR-10 preprocessing (32x32 RGB)
|
| 66 |
+
transform = transforms.Compose([
|
| 67 |
+
transforms.Resize((32, 32)),
|
| 68 |
+
transforms.ToTensor(),
|
| 69 |
+
])
|
| 70 |
|
| 71 |
+
# Load an image
|
| 72 |
+
img = Image.open("test.jpg").convert("RGB")
|
| 73 |
+
x = transform(img).unsqueeze(0)
|
| 74 |
|
| 75 |
+
# Predict
|
| 76 |
+
with torch.no_grad():
|
| 77 |
+
output = model(x)
|
| 78 |
+
pred_class = output.argmax(1).item()
|
| 79 |
|
| 80 |
+
classes = ['airplane','automobile','bird','cat','deer','dog','frog','horse','ship','truck']
|
| 81 |
+
print("Predicted class:", classes[pred_class])
|
| 82 |
|
| 83 |
|
| 84 |
+
### Training Information
|
| 85 |
|
| 86 |
Dataset: CIFAR-10
|
| 87 |
Optimizer: Adam
|
| 88 |
Loss Function: Cross-Entropy Loss
|
| 89 |
+
Epochs: 5
|
| 90 |
Batch Size: 32
|
| 91 |
Learning Rate: 0.001
|
| 92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
+
### Model Limitations
|
| 95 |
|
| 96 |
+
Trained only on CIFAR-10 → works best on 32x32 images with simple backgrounds.
|
| 97 |
+
May not generalize well to high-resolution or real-world images.
|
| 98 |
|
|
|
|
| 99 |
|
| 100 |
+
### License
|
| 101 |
|
| 102 |
+
This model is released under the Apache 2.0 License.
|
| 103 |
+
You can freely use, modify, and distribute this model.
|