DineshKumar1329 commited on
Commit
2845792
·
verified ·
1 Parent(s): a758463

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +53 -17
README.md CHANGED
@@ -11,25 +11,61 @@ library_name: transformers
11
  ---
12
 
13
 
 
14
 
15
- # Dog and Cat Classification using DeepLearning
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
- - The model architecture utilizes a pretrained ResNet-18 with the final layer adapted for binary classification (cats vs. dogs). Training involves defining a loss function (CrossEntropyLoss), an optimizer (Adam), and a learning rate scheduler. The training loop iterates through epochs, evaluating performance with training loss plotted over epochs.
19
 
20
- - After training, the model is evaluated on a test set to compute accuracy, achieving approximately 90.27% accuracy in this case. Trained model parameters are saved for future use. Inference capabilities include loading a single image, preprocessing it for prediction, and using the model to classify it as a cat or dog, with visualization of the prediction.
 
 
 
21
 
22
- - The code's modularity, utilizing PyTorch's DataLoader for efficient batch processing and GPU acceleration if available. Visualization tools such as matplotlib and seaborn aid in understanding dataset characteristics and model performance. Overall, it provides a robust framework for training and deploying a deep learning model for binary image classification tasks.
 
 
 
 
 
 
23
 
24
- # Contributors
25
- - S.Dinesh Kumar
26
- - Y.Gokul
27
- ### Panimalar Engineering College Chennai
28
- ## References:
29
- https://www.geeksforgeeks.org/cat-dog-classification-using-convolutional-neural-network-in-python/
30
- https://pytorch.org/vision/stable/index.html
31
- http://pytorch.org/vision/stable/models.html
32
- ## Support:
33
- - Mr.Kanav Bansal Cheif DataScientist (Innomatics Research Labs)
34
- # DataSet
35
- https://huggingface.co/datasets/microsoft/cats_vs_dogs
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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"}')