microsoft/cats_vs_dogs
Viewer • Updated • 23.4k • 4.01k • 77
How to use MrParop/dogs-vs-cats-vit-tiny with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("image-classification", model="MrParop/dogs-vs-cats-vit-tiny")
pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoImageProcessor, AutoModelForImageClassification
processor = AutoImageProcessor.from_pretrained("MrParop/dogs-vs-cats-vit-tiny")
model = AutoModelForImageClassification.from_pretrained("MrParop/dogs-vs-cats-vit-tiny", device_map="auto")Klasyfikator obrazów (kot / pies), fine-tuning modelu WinKawaks/vit-tiny-patch16-224.
cat, dogWinKawaks/vit-tiny-patch16-224 (pretrenowany na ImageNet)| Parametr | Wartość |
|---|---|
| Epoki | 3 |
| Learning rate | 5e-05 |
| Batch size | 32 |
| Precision | fp16 |
| Śledzenie | MLflow |
| Epoch | Training Loss | Validation Loss | Accuracy |
|---|---|---|---|
| 1 | 0.0146 | 0.0456 | 0.9875 |
| 2 | 0.0022 | 0.0504 | 0.9900 |
| 3 | 0.0000 | 0.0355 | 0.9900 |
Test accuracy: 0.9825
| precision | recall | f1-score | support | |
|---|---|---|---|---|
| cat | 0.978 | 0.984 | 0.981 | 184 |
| dog | 0.986 | 0.981 | 0.984 | 216 |
| accuracy | 0.982 | 0.982 | 0.982 | 0.982 |
| macro avg | 0.982 | 0.983 | 0.982 | 400 |
| weighted avg | 0.983 | 0.982 | 0.983 | 400 |
from transformers import pipeline
clf = pipeline("image-classification", model="MrParop/dogs-vs-cats-vit-tiny")
print(clf("zdjecie.jpg", top_k=2))
Model był trenowany na niewielkiej próbce zbioru i rozróżnia tylko koty i psy. Dla innych obiektów wyniki nie mają sensu.
Base model
WinKawaks/vit-tiny-patch16-224