Table of contents

This is a simple CNN model from 503,426 It is a textbook example of learning the model of classification of images in class 2

0 = Cat

1 = Dog

Training

The Neurose was trained on 23,000 images 224x224 from the Microsoft/cats_vs_dogs dating back 40 eras.

Architecture

Model banner

The neuro-layer is a set of 3 layers with an input to the MLP classifier.

Puff layers are used to extract traits from images, and mlp model is used to select a picture class.

Inference example

from transformers import AutoConfig, AutoModelForImageClassification
from PIL import Image
from torchvision import transforms
import numpy as np
import torch

repo_id = "Neweret/catdog"

np.set_printoptions(suppress=True)

transform = transforms.Compose([
        transforms.Resize((224, 224)),
        transforms.ToTensor(),
        transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
    ])

def load_image(image_path):

    image = Image.open(image_path).convert('RGB')

    image_tensor = transform(image)

    return image_tensor

def prediction(model, x):
    model.eval()
    with torch.no_grad():
        logits = model(x)
        pred = torch.softmax(logits, dim=1)
        print(logits)
        out = torch.argmax(pred, dim=1)

    return out

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

model = AutoModelForImageClassification.from_pretrained(
    repo_id,
    trust_remote_code = True

).to(device)

print('Print the image name: ')
image_path = input().strip()

try:
    tensor = load_image(image_path).to(device).unsqueeze(0)

except AttributeError:
        print('Error: Incorrect value type!')
        exit()
    
except FileNotFoundError:
        print('Error: File not exist!')
        exit()



pred = prediction(model, tensor)

if pred == 0:
    print('It`s cat!๐Ÿฑ')
else:
    print('It`s dog!๐Ÿ•')
Downloads last month
74
Safetensors
Model size
503k params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support