Classify Cats and Dogs
VGG16 fine tuned to classify cats and dogs
Notebook
https://www.kaggle.com/carlosaguayo/cats-vs-dogs-transfer-learning-pre-trained-vgg16
How to use
Here is how to use this model to classify an image as a cat or dog:
from skimage import io
import cv2
import matplotlib.pyplot as plt
from huggingface_hub import from_pretrained_keras
%matplotlib inline
ROWS, COLS = 150, 150
model = from_pretrained_keras("carlosaguayo/cats_vs_dogs")
img_url = 'https://upload.wikimedia.org/wikipedia/commons/0/0c/About_The_Dog.jpg'
# img_url = 'https://upload.wikimedia.org/wikipedia/commons/c/c7/Tabby_cat_with_blue_eyes-3336579.jpg'
img = io.imread(img_url)
img = cv2.resize(img, (ROWS, COLS), interpolation=cv2.INTER_CUBIC)
img = img / 255.0
img = img.reshape(1,ROWS,COLS,3)
prediction = model.predict(img)[0][0]
if prediction >= 0.5:
print('I am {:.2%} sure this is a Cat'.format(prediction))
else:
print('I am {:.2%} sure this is a Dog'.format(1-prediction))
plt.imshow(img[0], 'Blues')
plt.axis("off")
plt.show()
- Downloads last month
- 13
Inference API (serverless) does not yet support tf-keras models for this pipeline type.