File size: 1,809 Bytes
8a48ffd ab6d81c c7fdb40 f0ebf06 2845792 f0ebf06 2845792 f0ebf06 2845792 f0ebf06 2845792 f0ebf06 2845792 f0ebf06 2845792 f32744b 2845792 f32744b 2845792 f32744b 2845792 f32744b 2845792 0786365 |
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 |
---
license: mit
language:
- en
metrics:
- accuracy
pipeline_tag: image-classification
tags:
- code
library_name: transformers
---
# ResNet Cat-Dog Classifier
This repository contains a ResNet-based convolutional neural network trained to classify images as either cats or dogs. The model achieves an accuracy of 90.27% on a test dataset and is fine-tuned using transfer learning on the ImageNet dataset. It uses PyTorch for training and inference.
## Model Details
### Architecture:
- Backbone: ResNet-18
- Input Size: 128x128 RGB images
- Output: Binary classification (Cat or Dog)
### Training Details:
- Dataset: Kaggle Cats and Dogs dataset
- Loss Function: Cross-entropy loss
- Optimizer: Adam optimizer
- Learning Rate: 0.001
- Epochs: 15
- Batch Size: 32
### Performance:
- Accuracy: 90.27% on test images
- Training Time: Approximately 1 hour on NVIDIA GTX 1080 Ti
## Usage
### Installation:
- Dependencies: PyTorch, TorchVision, matplotlib
### Inference:
```python
import torch
from torchvision import transforms
from PIL import Image
from transformers import pipeline
# Define the image transformation
transform = transforms.Compose([
transforms.Resize((128, 128)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])
# Load the model from Hugging Face
pipe = pipeline("image-classification", model="DineshKumar1329/DogCat_Classifier")
# Load and preprocess an image
image_path = 'path/to/your/image.jpg'
image = Image.open(image_path)
image = transform(image)
image = image.unsqueeze(0) # Add batch dimension
# Make a prediction
result = classifier(image_path)
# Extract the predicted label
predicted_label = result[0]['label']
# Output the prediction
print(f'The predicted class for the image is: {predicted_label}') |