blatoet commited on
Commit
47a0ad0
·
verified ·
1 Parent(s): d120b53

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +85 -0
README.md ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - image-classification
5
+ - pytorch
6
+ - cats-vs-dogs
7
+ - computer-vision
8
+ datasets:
9
+ - microsoft/cats_vs_dogs
10
+ metrics:
11
+ - accuracy
12
+ ---
13
+
14
+ # Cat vs Dog Classifier
15
+
16
+ This model is a simple CNN (Convolutional Neural Network) trained to classify images as either cats or dogs.
17
+
18
+ ## Model Description
19
+
20
+ - **Architecture**: Custom CNN with 3 convolutional layers and 3 fully connected layers
21
+ - **Input**: 224x224 RGB images
22
+ - **Output**: Binary classification (Cat or Dog)
23
+ - **Framework**: PyTorch
24
+
25
+ ## Training Data
26
+
27
+ The model was trained on the [microsoft/cats_vs_dogs](https://huggingface.co/datasets/microsoft/cats_vs_dogs) dataset from Hugging Face.
28
+
29
+ ## Usage
30
+
31
+ ```python
32
+ import torch
33
+ from PIL import Image
34
+ from torchvision import transforms
35
+
36
+ # Load model
37
+ model = CatDogClassifier()
38
+ model.load_state_dict(torch.load('model_weights.pth'))
39
+ model.eval()
40
+
41
+ # Prepare image
42
+ transform = transforms.Compose([
43
+ transforms.Resize((224, 224)),
44
+ transforms.ToTensor(),
45
+ transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
46
+ ])
47
+
48
+ image = Image.open('your_image.jpg').convert('RGB')
49
+ image_tensor = transform(image).unsqueeze(0)
50
+
51
+ # Predict
52
+ with torch.no_grad():
53
+ outputs = model(image_tensor)
54
+ _, predicted = torch.max(outputs.data, 1)
55
+
56
+ classes = ['Cat', 'Dog']
57
+ print(f"Prediction: {classes[predicted.item()]}")
58
+ ```
59
+
60
+ ## Training Procedure
61
+
62
+ - **Optimizer**: Adam with learning rate 0.001
63
+ - **Loss Function**: CrossEntropyLoss
64
+ - **Batch Size**: 32
65
+ - **Epochs**: 10
66
+ - **Data Augmentation**: Random horizontal flip, rotation, and color jitter
67
+
68
+ ## Performance
69
+
70
+ The model achieves approximately 85-90% accuracy on the validation set (results may vary based on training run).
71
+
72
+ ## Limitations
73
+
74
+ - Model is trained specifically on cats and dogs only
75
+ - Performance may degrade on images with multiple animals
76
+ - Works best with clear, well-lit images
77
+ - Input images must be resized to 224x224
78
+
79
+ ## License
80
+
81
+ MIT License
82
+
83
+ ## Author
84
+
85
+ Created as an educational project for learning image classification with PyTorch.