carlosaguayo commited on
Commit
b773642
1 Parent(s): a81310a

Cats vs Dogs classifier

Browse files
Files changed (4) hide show
  1. .DS_Store +0 -0
  2. README.md +55 -0
  3. config.json +7 -0
  4. preprocessor_config.json +15 -0
.DS_Store ADDED
Binary file (6.15 kB). View file
 
README.md ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - image-classification
4
+ widget:
5
+ - src: https://upload.wikimedia.org/wikipedia/commons/0/0c/About_The_Dog.jpg
6
+ example_title: Dog-1
7
+ - src: https://yt3.ggpht.com/ytc/AKedOLRvxGYSdEHqu0X4EYcJ2kq7BttRKBNpfwdHJf3FSg=s900-c-k-c0x00ffffff-no-rj
8
+ example_title: Dog-2
9
+ - src: https://upload.wikimedia.org/wikipedia/commons/c/c7/Tabby_cat_with_blue_eyes-3336579.jpg
10
+ example_title: Cat-1
11
+ - src: https://pixabay.com/get/g31cf3b945cf9b9144eb6c1ecf514b4db668875b75d0c615e0330aec74bef5edde11567ef4a6f5fdb61a828b8086a39d3a0e72fb326d78467786dcdde4e6fa23c5c4c309d0abc089a8663809c175aee22_1920.jpg
12
+ example_title: Cat-2
13
+ ---
14
+
15
+ # Classify Cats and Dogs
16
+
17
+ VGG16 fine tuned to classify cats and dogs
18
+
19
+ Notebook
20
+
21
+ https://www.kaggle.com/carlosaguayo/cats-vs-dogs-transfer-learning-pre-trained-vgg16
22
+
23
+ ### How to use
24
+
25
+ Here is how to use this model to classify an image as a cat or dog:
26
+
27
+ ```python
28
+ from skimage import io
29
+ import cv2
30
+ import matplotlib.pyplot as plt
31
+ from huggingface_hub import from_pretrained_keras
32
+ %matplotlib inline
33
+
34
+ ROWS, COLS = 150, 150
35
+
36
+ model = from_pretrained_keras("carlosaguayo/cats_vs_dogs")
37
+
38
+ img_url = 'https://upload.wikimedia.org/wikipedia/commons/0/0c/About_The_Dog.jpg'
39
+ # img_url = 'https://upload.wikimedia.org/wikipedia/commons/c/c7/Tabby_cat_with_blue_eyes-3336579.jpg'
40
+
41
+ img = io.imread(img_url)
42
+ img = cv2.resize(img, (ROWS, COLS), interpolation=cv2.INTER_CUBIC)
43
+ img = img / 255.0
44
+ img = img.reshape(1,ROWS,COLS,3)
45
+
46
+ prediction = model.predict(img)[0][0]
47
+ if prediction >= 0.5:
48
+ print('I am {:.2%} sure this is a Cat'.format(prediction))
49
+ else:
50
+ print('I am {:.2%} sure this is a Dog'.format(1-prediction))
51
+
52
+ plt.imshow(img[0], 'Blues')
53
+ plt.axis("off")
54
+ plt.show()
55
+ ```
config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "id2label": {
3
+ "0": "Dog",
4
+ "1": "Cat"
5
+ },
6
+ "num_channels": 3
7
+ }
preprocessor_config.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_normalize": true,
3
+ "do_resize": true,
4
+ "image_mean": [
5
+ 0.5,
6
+ 0.5,
7
+ 0.5
8
+ ],
9
+ "image_std": [
10
+ 0.5,
11
+ 0.5,
12
+ 0.5
13
+ ],
14
+ "size": 150
15
+ }