Edit model card

Report Issue

If you encounter any problems with downloading or using the model, please report the issue by creating one at the following GitHub repository: https://github.com/parneetsingh022/dog-cat-classification.git

Demo

https://huggingface.co/spaces/parneetsingh022/cat-vs-dog

Loading and using the model.

In order to download and use the model follow these steps:

  1. Clone this reposetory:
git clone https://github.com/parneetsingh022/dog-cat-classification.git
  1. Download transformers liberary
pip install transformers
  1. After installation, you can utilize the model in other scripts outside of this directory custom_classifier as described below:

Required Imports:

import torch
from PIL import Image
from torchvision import transforms

from custom_classifier.configuration import CustomModelConfig
from custom_classifier.model import CustomClassifier

Loading the model:

model_name = "parneetsingh022/dog-cat-classification"
config = CustomModelConfig.from_pretrained(model_name)
model = CustomClassifier.from_pretrained(model_name, config=config)

Pridicting probability of individual class:

# Load an example image
image_path = "dog.jpeg"
outputs = model.predict(image_path)
print(outputs)

Output: {'cat': 0.003, 'dog': 0.997}

Getting class name instead of probabilities:

# Load an example image
image_path = "dog_new.jpeg"
outputs = model.predict(image_path, get_class=True)

print(output)

Output: 'dog'

Downloads last month
92
Safetensors
Model size
4.44M params
Tensor type
F32
·
Unable to determine this model’s pipeline type. Check the docs .

Dataset used to train parneetsingh022/dog-cat-classification