hgrrg commited on
Commit
e7a52dc
·
verified ·
1 Parent(s): e7c67b8

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +77 -0
README.md ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: pytorch
4
+ pipeline_tag: image-classification
5
+ tags:
6
+ - image-classification
7
+ - vision
8
+ - cats
9
+ - pytorch
10
+ ---
11
+
12
+ # stackmeo 🐱
13
+
14
+ stackmeo is a small image-classification model that recognizes cat breeds from a photo.
15
+ The name comes from "mèo", Vietnamese for cat.
16
+
17
+ Give it one picture of a cat and it returns the most likely breeds, each with a confidence score.
18
+ It's kept lightweight so it's easy to drop into a hobby project, a demo, or an app.
19
+
20
+ ## What it recognizes
21
+
22
+ stackmeo knows 10 breeds:
23
+
24
+ - **Maine Coon**: a large, friendly cat known for its bushy tail, tufted ears, and playful personality.
25
+ - **Ragdoll**: a calm, affectionate cat that tends to go limp when you hold it.
26
+ - **British Shorthair**: a sturdy, quiet, and easygoing cat with a dense coat and round face.
27
+ - **Siamese**: a slender, vocal cat with striking blue eyes and sharp color points.
28
+ - **Persian**: a fluffy, quiet "couch potato" with a flat face that needs daily grooming.
29
+ - **Sphynx**: a hairless, high-energy cat with big ears and warm, suede-like skin.
30
+ - **Bengal**: an active, athletic cat with a spotted coat that looks like a wild leopard.
31
+ - **Scottish Fold**: a sweet-tempered cat known for its folded-over ears and round eyes.
32
+ - **Russian Blue**: a graceful cat with a shimmering silver-gray coat and a gentle, quiet nature.
33
+ - **Abyssinian**: a lean, curious, and playful cat with a ticked, multi-colored coat.
34
+
35
+ ## Quick start
36
+
37
+ ```bash
38
+ pip install torch torchvision pillow huggingface_hub
39
+ ```
40
+
41
+ ```python
42
+ import torch
43
+ from huggingface_hub import hf_hub_download
44
+ from PIL import Image
45
+ from torchvision import transforms
46
+
47
+ path = hf_hub_download("<your-username>/stackmeo", "stackmeo.pt")
48
+ model = torch.jit.load(path, map_location="cpu").eval()
49
+
50
+ LABELS = [
51
+ "Maine Coon", "Ragdoll", "British Shorthair", "Siamese", "Persian",
52
+ "Sphynx", "Bengal", "Scottish Fold", "Russian Blue", "Abyssinian",
53
+ ]
54
+
55
+ preprocess = transforms.Compose([
56
+ transforms.Resize((224, 224)),
57
+ transforms.ToTensor(),
58
+ transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
59
+ ])
60
+
61
+ img = preprocess(Image.open("my_cat.jpg").convert("RGB")).unsqueeze(0)
62
+ with torch.no_grad():
63
+ probs = model(img).softmax(dim=1)[0]
64
+
65
+ top = probs.topk(3)
66
+ for score, idx in zip(top.values, top.indices):
67
+ print(f"{LABELS[idx]}: {score:.1%}")
68
+ ```
69
+
70
+ This prints the 3 most likely breeds for `my_cat.jpg` with a confidence score for each.
71
+
72
+ ## Limitations
73
+
74
+ - It only knows cats. Show it a dog or a teapot and it will still answer with a cat breed,
75
+ because it can't say "this isn't a cat".
76
+ - Mixed-breed cats, and breeds that aren't in the list above, get matched to the closest known breed.
77
+ - It works best on clear photos where the cat fills most of the frame.