|
Download README.md from Udayan012/tiny-cnn-classifier: direct link, hf CLI and curl.
- Browser
- Download file 2.58 kB
-
https://huggingface.co/Udayan012/tiny-cnn-classifier/resolve/main/README.md
- Command line
-
hf download hf://Udayan012/tiny-cnn-classifier/README.md
-
curl -L -o README.md https://huggingface.co/Udayan012/tiny-cnn-classifier/resolve/main/README.md
2.58 kB
| 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. |