Classify Cats and Dogs

VGG16 fine tuned to classify cats and dogs


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 = ''
# img_url = ''

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))
    print('I am {:.2%} sure this is a Dog'.format(1-prediction))
plt.imshow(img[0], 'Blues')
Downloads last month
Hosted inference API
Image Classification
Drag image file here or click to browse from your device
This model can be loaded on the Inference API on-demand.

Space using carlosaguayo/cats_vs_dogs