Downloads · 30 days
14
0% of all-time downloads
parneetsingh022/dog-cat-classification
dog-cat-classification is a machine learning model from parneetsingh022. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as mit.
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
Downloads · 30 days
14
0% of all-time downloads
All-time downloads
43.7K
Public
Parameters
4.4M
17.8 MB on disk
Likes
3
Public
Click a slice to open those files.
.safetensors17.8 MB · 100%
From the Hugging Face model README
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
https://huggingface.co/spaces/parneetsingh022/cat-vs-dog
In order to download and use the model follow these steps:
git clone https://github.com/parneetsingh022/dog-cat-classification.git
pip install transformers
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'