IMvision12's picture
Fix Collection badge link to the current zeromodels collection slug
11661af verified
|
Raw
History Blame Contribute Delete
6.15 kB
---
pipeline_tag: image-classification
license: cc-by-nc-4.0
base_model: timm/convnextv2_base.fcmae_ft_in1k
library_name: zeromodels
tags:
- keras
- zeromodels
- image-classification
- convnextv2
- backbone
- arxiv:2301.00808
- pytorch
- jax
- tf
---
## ***See [our collection](https://huggingface.co/collections/zeromodels/convnext-v2-6a8eaf0a9a918a955e682e1f) for all versions of ConvNeXt-V2.***
# Run ConvNeXt-V2 with Keras 3: JAX, PyTorch, or TensorFlow
[![GitHub](https://img.shields.io/badge/GitHub-ZeroModels-black?logo=github)](https://github.com/IMvision12/ZeroModels) [![Docs](https://img.shields.io/badge/Docs-ConvNeXt--V2-blue)](https://imvision12.github.io/ZeroModels/classification_backbones/) [![Collection](https://img.shields.io/badge/HF-ConvNeXt--V2%20collection-yellow)](https://huggingface.co/collections/zeromodels/convnext-v2-6a8eaf0a9a918a955e682e1f)
# zeromodels/convnextv2_base_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_base.fcmae_ft_in1k).
Pure-**Keras 3** conversion of [`timm/convnextv2_base.fcmae_ft_in1k`](https://huggingface.co/timm/convnextv2_base.fcmae_ft_in1k) for [zeromodels](https://github.com/IMvision12/ZeroModels). 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 zeromodels.models.convnextv2 import ConvNeXtV2ImageClassify, ConvNeXtV2Model
model = ConvNeXtV2ImageClassify.from_weights("zeromodels/convnextv2_base_fcmae_ft_in1k")
backbone = ConvNeXtV2Model.from_weights(
"zeromodels/convnextv2_base_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("zeromodels/<variant>")`:
| Variant | Hub |
|---|---|
| `convnextv2_atto_fcmae_ft_in1k` | [`zeromodels/convnextv2_atto_fcmae_ft_in1k`](https://huggingface.co/zeromodels/convnextv2_atto_fcmae_ft_in1k) |
| `convnextv2_base_fcmae_ft_in1k` | [`zeromodels/convnextv2_base_fcmae_ft_in1k`](https://huggingface.co/zeromodels/convnextv2_base_fcmae_ft_in1k) |
| `convnextv2_base_fcmae_ft_in22k_in1k` | [`zeromodels/convnextv2_base_fcmae_ft_in22k_in1k`](https://huggingface.co/zeromodels/convnextv2_base_fcmae_ft_in22k_in1k) |
| `convnextv2_base_fcmae_ft_in22k_in1k_384` | [`zeromodels/convnextv2_base_fcmae_ft_in22k_in1k_384`](https://huggingface.co/zeromodels/convnextv2_base_fcmae_ft_in22k_in1k_384) |
| `convnextv2_femto_fcmae_ft_in1k` | [`zeromodels/convnextv2_femto_fcmae_ft_in1k`](https://huggingface.co/zeromodels/convnextv2_femto_fcmae_ft_in1k) |
| `convnextv2_huge_fcmae_ft_in1k` | [`zeromodels/convnextv2_huge_fcmae_ft_in1k`](https://huggingface.co/zeromodels/convnextv2_huge_fcmae_ft_in1k) |
| `convnextv2_huge_fcmae_ft_in22k_in1k_384` | [`zeromodels/convnextv2_huge_fcmae_ft_in22k_in1k_384`](https://huggingface.co/zeromodels/convnextv2_huge_fcmae_ft_in22k_in1k_384) |
| `convnextv2_huge_fcmae_ft_in22k_in1k_512` | [`zeromodels/convnextv2_huge_fcmae_ft_in22k_in1k_512`](https://huggingface.co/zeromodels/convnextv2_huge_fcmae_ft_in22k_in1k_512) |
| `convnextv2_large_fcmae_ft_in1k` | [`zeromodels/convnextv2_large_fcmae_ft_in1k`](https://huggingface.co/zeromodels/convnextv2_large_fcmae_ft_in1k) |
| `convnextv2_large_fcmae_ft_in22k_in1k` | [`zeromodels/convnextv2_large_fcmae_ft_in22k_in1k`](https://huggingface.co/zeromodels/convnextv2_large_fcmae_ft_in22k_in1k) |
| `convnextv2_large_fcmae_ft_in22k_in1k_384` | [`zeromodels/convnextv2_large_fcmae_ft_in22k_in1k_384`](https://huggingface.co/zeromodels/convnextv2_large_fcmae_ft_in22k_in1k_384) |
| `convnextv2_nano_fcmae_ft_in1k` | [`zeromodels/convnextv2_nano_fcmae_ft_in1k`](https://huggingface.co/zeromodels/convnextv2_nano_fcmae_ft_in1k) |
| `convnextv2_nano_fcmae_ft_in22k_in1k` | [`zeromodels/convnextv2_nano_fcmae_ft_in22k_in1k`](https://huggingface.co/zeromodels/convnextv2_nano_fcmae_ft_in22k_in1k) |
| `convnextv2_nano_fcmae_ft_in22k_in1k_384` | [`zeromodels/convnextv2_nano_fcmae_ft_in22k_in1k_384`](https://huggingface.co/zeromodels/convnextv2_nano_fcmae_ft_in22k_in1k_384) |
| `convnextv2_pico_fcmae_ft_in1k` | [`zeromodels/convnextv2_pico_fcmae_ft_in1k`](https://huggingface.co/zeromodels/convnextv2_pico_fcmae_ft_in1k) |
| `convnextv2_tiny_fcmae_ft_in1k` | [`zeromodels/convnextv2_tiny_fcmae_ft_in1k`](https://huggingface.co/zeromodels/convnextv2_tiny_fcmae_ft_in1k) |
| `convnextv2_tiny_fcmae_ft_in22k_in1k` | [`zeromodels/convnextv2_tiny_fcmae_ft_in22k_in1k`](https://huggingface.co/zeromodels/convnextv2_tiny_fcmae_ft_in22k_in1k) |
| `convnextv2_tiny_fcmae_ft_in22k_in1k_384` | [`zeromodels/convnextv2_tiny_fcmae_ft_in22k_in1k_384`](https://huggingface.co/zeromodels/convnextv2_tiny_fcmae_ft_in22k_in1k_384) |
## Tips
- Set `KERAS_BACKEND` **before** importing Keras / zeromodels.
- `ConvNeXtV2ImageClassify` returns class logits; `ConvNeXtV2Model` returns features (`as_backbone=True` for multi-scale stages).
- See [docs](https://imvision12.github.io/ZeroModels/classification_backbones/) and [Loading Weights](https://imvision12.github.io/ZeroModels/loading_weights/).
- Upstream / timm checkpoints: `ConvNeXtV2ImageClassify.from_weights("hf:timm/convnextv2_base.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).