IMvision12's picture
fix readme.md
b8bfb78 verified
|
Raw
History Blame Contribute Delete
6.25 kB
metadata
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 for all versions of ConvNeXt-V2.

Run ConvNeXt-V2 with Keras 3: JAX, PyTorch, or TensorFlow

GitHub Docs Collection

kerasformers/convnextv2_tiny_fcmae_ft_in1k

Paper: ConvNeXt V2: Co-designing and Scaling ConvNets with Masked Autoencoders (arXiv:2301.00808) · HF Papers

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.

Pure-Keras 3 conversion of timm/convnextv2_tiny.fcmae_ft_in1k for kerasformers. One implementation runs unmodified on TensorFlow / Torch / JAX.

This is an image-classification / backbone checkpoint (ConvNeXtV2ImageClassify / ConvNeXtV2Model).

✨ Quick start

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
convnextv2_base_fcmae_ft_in1k kerasformers/convnextv2_base_fcmae_ft_in1k
convnextv2_base_fcmae_ft_in22k_in1k kerasformers/convnextv2_base_fcmae_ft_in22k_in1k
convnextv2_base_fcmae_ft_in22k_in1k_384 kerasformers/convnextv2_base_fcmae_ft_in22k_in1k_384
convnextv2_femto_fcmae_ft_in1k kerasformers/convnextv2_femto_fcmae_ft_in1k
convnextv2_huge_fcmae_ft_in1k kerasformers/convnextv2_huge_fcmae_ft_in1k
convnextv2_huge_fcmae_ft_in22k_in1k_384 kerasformers/convnextv2_huge_fcmae_ft_in22k_in1k_384
convnextv2_huge_fcmae_ft_in22k_in1k_512 kerasformers/convnextv2_huge_fcmae_ft_in22k_in1k_512
convnextv2_large_fcmae_ft_in1k kerasformers/convnextv2_large_fcmae_ft_in1k
convnextv2_large_fcmae_ft_in22k_in1k kerasformers/convnextv2_large_fcmae_ft_in22k_in1k
convnextv2_large_fcmae_ft_in22k_in1k_384 kerasformers/convnextv2_large_fcmae_ft_in22k_in1k_384
convnextv2_nano_fcmae_ft_in1k kerasformers/convnextv2_nano_fcmae_ft_in1k
convnextv2_nano_fcmae_ft_in22k_in1k kerasformers/convnextv2_nano_fcmae_ft_in22k_in1k
convnextv2_nano_fcmae_ft_in22k_in1k_384 kerasformers/convnextv2_nano_fcmae_ft_in22k_in1k_384
convnextv2_pico_fcmae_ft_in1k kerasformers/convnextv2_pico_fcmae_ft_in1k
convnextv2_tiny_fcmae_ft_in1k kerasformers/convnextv2_tiny_fcmae_ft_in1k
convnextv2_tiny_fcmae_ft_in22k_in1k kerasformers/convnextv2_tiny_fcmae_ft_in22k_in1k
convnextv2_tiny_fcmae_ft_in22k_in1k_384 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 and 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).