Update README.md
Browse files
README.md
CHANGED
@@ -11,25 +11,61 @@ library_name: transformers
|
|
11 |
---
|
12 |
|
13 |
|
|
|
14 |
|
15 |
-
|
16 |
-
- Implementing a deep learning pipeline for classifying images of cats and dogs using the PyTorch framework. It begins by preparing a dataset, visualizing class distributions, and splitting data into training and testing sets. Image preprocessing involves resizing, random transformations, and normalization.
|
17 |
|
18 |
-
|
19 |
|
20 |
-
|
|
|
|
|
|
|
21 |
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
-
|
25 |
-
-
|
26 |
-
-
|
27 |
-
|
28 |
-
##
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
---
|
12 |
|
13 |
|
14 |
+
# ResNet Cat-Dog Classifier
|
15 |
|
16 |
+
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.
|
|
|
17 |
|
18 |
+
## Model Details
|
19 |
|
20 |
+
### Architecture:
|
21 |
+
- Backbone: ResNet-18
|
22 |
+
- Input Size: 128x128 RGB images
|
23 |
+
- Output: Binary classification (Cat or Dog)
|
24 |
|
25 |
+
### Training Details:
|
26 |
+
- Dataset: Kaggle Cats and Dogs dataset
|
27 |
+
- Loss Function: Cross-entropy loss
|
28 |
+
- Optimizer: Adam optimizer
|
29 |
+
- Learning Rate: 0.001
|
30 |
+
- Epochs: 15
|
31 |
+
- Batch Size: 32
|
32 |
|
33 |
+
### Performance:
|
34 |
+
- Accuracy: 90.27% on test images
|
35 |
+
- Training Time: Approximately 1 hour on NVIDIA GTX 1080 Ti
|
36 |
+
|
37 |
+
## Usage
|
38 |
+
|
39 |
+
### Installation:
|
40 |
+
- Dependencies: PyTorch, TorchVision, matplotlib
|
41 |
+
|
42 |
+
### Inference:
|
43 |
+
```python
|
44 |
+
import torch
|
45 |
+
from torchvision import transforms
|
46 |
+
from PIL import Image
|
47 |
+
|
48 |
+
# Load the model
|
49 |
+
model = torch.hub.load('your-username/your-repository', 'resnet_cat_dog_classifier')
|
50 |
+
|
51 |
+
# Define the transformation
|
52 |
+
transform = transforms.Compose([
|
53 |
+
transforms.Resize((128, 128)),
|
54 |
+
transforms.ToTensor(),
|
55 |
+
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
|
56 |
+
])
|
57 |
+
|
58 |
+
# Load an image
|
59 |
+
image_path = 'path/to/your/image.jpg'
|
60 |
+
image = Image.open(image_path)
|
61 |
+
image = transform(image)
|
62 |
+
image = image.unsqueeze(0) # Add batch dimension
|
63 |
+
|
64 |
+
# Make a prediction
|
65 |
+
model.eval()
|
66 |
+
with torch.no_grad():
|
67 |
+
outputs = model(image)
|
68 |
+
temp, predicted = torch.max(outputs, 1)
|
69 |
+
|
70 |
+
# Output the prediction
|
71 |
+
print(f'The predicted class for the image is: {"Cat" if predicted.item() == 0 else "Dog"}')
|