--- license: apache-2.0 library_name: pytorch pipeline_tag: image-classification tags: - image-classification - vision - cats - pytorch --- # stackmeo 🐱 stackmeo is a small image-classification model that recognizes cat breeds from a photo. The name comes from "mèo", Vietnamese for cat. Give it one picture of a cat and it returns the most likely breeds, each with a confidence score. It's kept lightweight so it's easy to drop into a hobby project, a demo, or an app. ## What it recognizes stackmeo knows 10 breeds: - **Maine Coon**: a large, friendly cat known for its bushy tail, tufted ears, and playful personality. - **Ragdoll**: a calm, affectionate cat that tends to go limp when you hold it. - **British Shorthair**: a sturdy, quiet, and easygoing cat with a dense coat and round face. - **Siamese**: a slender, vocal cat with striking blue eyes and sharp color points. - **Persian**: a fluffy, quiet "couch potato" with a flat face that needs daily grooming. - **Sphynx**: a hairless, high-energy cat with big ears and warm, suede-like skin. - **Bengal**: an active, athletic cat with a spotted coat that looks like a wild leopard. - **Scottish Fold**: a sweet-tempered cat known for its folded-over ears and round eyes. - **Russian Blue**: a graceful cat with a shimmering silver-gray coat and a gentle, quiet nature. - **Abyssinian**: a lean, curious, and playful cat with a ticked, multi-colored coat. ## Quick start ```bash pip install torch torchvision pillow huggingface_hub ``` ```python import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision import transforms path = hf_hub_download("hgrrg/stackmeo", "test.pt") model = torch.jit.load(path, map_location="cpu").eval() LABELS = [ "Maine Coon", "Ragdoll", "British Shorthair", "Siamese", "Persian", "Sphynx", "Bengal", "Scottish Fold", "Russian Blue", "Abyssinian", ] preprocess = transforms.Compose([ transforms.Resize((224, 224)), transforms.ToTensor(), transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]), ]) img = preprocess(Image.open("my_cat.jpg").convert("RGB")).unsqueeze(0) with torch.no_grad(): probs = model(img).softmax(dim=1)[0] top = probs.topk(3) for score, idx in zip(top.values, top.indices): print(f"{LABELS[idx]}: {score:.1%}") ``` This prints the 3 most likely breeds for `my_cat.jpg` with a confidence score for each. ## Limitations - It only knows cats. Show it a dog or a teapot and it will still answer with a cat breed, because it can't say "this isn't a cat". - Mixed-breed cats, and breeds that aren't in the list above, get matched to the closest known breed. - It works best on clear photos where the cat fills most of the frame.