IMvision12's picture
fix readme.md
b8bfb78 verified
|
Raw
History Blame Contribute Delete
6.25 kB
---
pipeline_tag: image-classification
license: cc-by-nc-4.0
base_model: timm/convnextv2_tiny.fcmae_ft_in1k
library_name: kerasformers
tags:
- keras
- kerasformers
- image-classification
- convnextv2
- backbone
- arxiv:2301.00808
- pytorch
- jax
- tf
---
## ***See [our collection](https://huggingface.co/collections/kerasformers/convnext-v2-6a6bd292f10bf60554146f7b) for all versions of ConvNeXt-V2.***
# Run ConvNeXt-V2 with Keras 3: JAX, PyTorch, or TensorFlow
[![GitHub](https://img.shields.io/badge/GitHub-KerasFormers-black?logo=github)](https://github.com/IMvision12/KerasFormers) [![Docs](https://img.shields.io/badge/Docs-ConvNeXt--V2-blue)](https://imvision12.github.io/KerasFormers/classification_backbones/) [![Collection](https://img.shields.io/badge/HF-ConvNeXt--V2%20collection-yellow)](https://huggingface.co/collections/kerasformers/convnext-v2-6a6bd292f10bf60554146f7b)
# kerasformers/convnextv2_tiny_fcmae_ft_in1k
Paper: [ConvNeXt V2: Co-designing and Scaling ConvNets with Masked Autoencoders (arXiv:2301.00808)](https://arxiv.org/abs/2301.00808) · [HF Papers](https://huggingface.co/papers/2301.00808)
ConvNeXt V2 adds Global Response Normalization and FCMAE pretraining. Same classifier / backbone split as ConvNeXt.
For more details on the model, please go to the upstream [model card](https://huggingface.co/timm/convnextv2_tiny.fcmae_ft_in1k).
Pure-**Keras 3** conversion of [`timm/convnextv2_tiny.fcmae_ft_in1k`](https://huggingface.co/timm/convnextv2_tiny.fcmae_ft_in1k) for [kerasformers](https://github.com/IMvision12/KerasFormers). One implementation runs unmodified on **TensorFlow / Torch / JAX**.
This is an **image-classification / backbone** checkpoint (`ConvNeXtV2ImageClassify` / `ConvNeXtV2Model`).
## ✨ Quick start
```python
import os
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
from PIL import Image
import numpy as np
from kerasformers.models.convnextv2 import ConvNeXtV2ImageClassify, ConvNeXtV2Model
model = ConvNeXtV2ImageClassify.from_weights("kerasformers/convnextv2_tiny_fcmae_ft_in1k")
backbone = ConvNeXtV2Model.from_weights(
"kerasformers/convnextv2_tiny_fcmae_ft_in1k", as_backbone=True
)
image = Image.open("your_image.jpg").convert("RGB")
image = image.resize((224, 224))
x = np.asarray(image, dtype="float32")[None] # (1, H, W, 3)
print(model(x).shape) # (1, num_classes)
feats = backbone(x)
print(len(feats), [tuple(f.shape) for f in feats])
```
Load any ConvNeXt-V2 variant the same way with `from_weights("kerasformers/<variant>")`:
| Variant | Hub |
|---|---|
| `convnextv2_atto_fcmae_ft_in1k` | [`kerasformers/convnextv2_atto_fcmae_ft_in1k`](https://huggingface.co/kerasformers/convnextv2_atto_fcmae_ft_in1k) |
| `convnextv2_base_fcmae_ft_in1k` | [`kerasformers/convnextv2_base_fcmae_ft_in1k`](https://huggingface.co/kerasformers/convnextv2_base_fcmae_ft_in1k) |
| `convnextv2_base_fcmae_ft_in22k_in1k` | [`kerasformers/convnextv2_base_fcmae_ft_in22k_in1k`](https://huggingface.co/kerasformers/convnextv2_base_fcmae_ft_in22k_in1k) |
| `convnextv2_base_fcmae_ft_in22k_in1k_384` | [`kerasformers/convnextv2_base_fcmae_ft_in22k_in1k_384`](https://huggingface.co/kerasformers/convnextv2_base_fcmae_ft_in22k_in1k_384) |
| `convnextv2_femto_fcmae_ft_in1k` | [`kerasformers/convnextv2_femto_fcmae_ft_in1k`](https://huggingface.co/kerasformers/convnextv2_femto_fcmae_ft_in1k) |
| `convnextv2_huge_fcmae_ft_in1k` | [`kerasformers/convnextv2_huge_fcmae_ft_in1k`](https://huggingface.co/kerasformers/convnextv2_huge_fcmae_ft_in1k) |
| `convnextv2_huge_fcmae_ft_in22k_in1k_384` | [`kerasformers/convnextv2_huge_fcmae_ft_in22k_in1k_384`](https://huggingface.co/kerasformers/convnextv2_huge_fcmae_ft_in22k_in1k_384) |
| `convnextv2_huge_fcmae_ft_in22k_in1k_512` | [`kerasformers/convnextv2_huge_fcmae_ft_in22k_in1k_512`](https://huggingface.co/kerasformers/convnextv2_huge_fcmae_ft_in22k_in1k_512) |
| `convnextv2_large_fcmae_ft_in1k` | [`kerasformers/convnextv2_large_fcmae_ft_in1k`](https://huggingface.co/kerasformers/convnextv2_large_fcmae_ft_in1k) |
| `convnextv2_large_fcmae_ft_in22k_in1k` | [`kerasformers/convnextv2_large_fcmae_ft_in22k_in1k`](https://huggingface.co/kerasformers/convnextv2_large_fcmae_ft_in22k_in1k) |
| `convnextv2_large_fcmae_ft_in22k_in1k_384` | [`kerasformers/convnextv2_large_fcmae_ft_in22k_in1k_384`](https://huggingface.co/kerasformers/convnextv2_large_fcmae_ft_in22k_in1k_384) |
| `convnextv2_nano_fcmae_ft_in1k` | [`kerasformers/convnextv2_nano_fcmae_ft_in1k`](https://huggingface.co/kerasformers/convnextv2_nano_fcmae_ft_in1k) |
| `convnextv2_nano_fcmae_ft_in22k_in1k` | [`kerasformers/convnextv2_nano_fcmae_ft_in22k_in1k`](https://huggingface.co/kerasformers/convnextv2_nano_fcmae_ft_in22k_in1k) |
| `convnextv2_nano_fcmae_ft_in22k_in1k_384` | [`kerasformers/convnextv2_nano_fcmae_ft_in22k_in1k_384`](https://huggingface.co/kerasformers/convnextv2_nano_fcmae_ft_in22k_in1k_384) |
| `convnextv2_pico_fcmae_ft_in1k` | [`kerasformers/convnextv2_pico_fcmae_ft_in1k`](https://huggingface.co/kerasformers/convnextv2_pico_fcmae_ft_in1k) |
| `convnextv2_tiny_fcmae_ft_in1k` | [`kerasformers/convnextv2_tiny_fcmae_ft_in1k`](https://huggingface.co/kerasformers/convnextv2_tiny_fcmae_ft_in1k) |
| `convnextv2_tiny_fcmae_ft_in22k_in1k` | [`kerasformers/convnextv2_tiny_fcmae_ft_in22k_in1k`](https://huggingface.co/kerasformers/convnextv2_tiny_fcmae_ft_in22k_in1k) |
| `convnextv2_tiny_fcmae_ft_in22k_in1k_384` | [`kerasformers/convnextv2_tiny_fcmae_ft_in22k_in1k_384`](https://huggingface.co/kerasformers/convnextv2_tiny_fcmae_ft_in22k_in1k_384) |
## Tips
- Set `KERAS_BACKEND` **before** importing Keras / kerasformers.
- `ConvNeXtV2ImageClassify` returns class logits; `ConvNeXtV2Model` returns features (`as_backbone=True` for multi-scale stages).
- See [docs](https://imvision12.github.io/KerasFormers/classification_backbones/) and [Loading Weights](https://imvision12.github.io/KerasFormers/loading_weights/).
- Upstream / timm checkpoints: `ConvNeXtV2ImageClassify.from_weights("hf:timm/convnextv2_tiny.fcmae_ft_in1k")`.
## Special Thanks
A huge thank you to the ConvNeXt-V2 authors and the timm / Hub communities for creating and releasing these models.
License: see YAML `license` (usually matches the upstream checkpoint).