IMvision12 commited on
Commit
b8bfb78
·
verified ·
1 Parent(s): 7f7e4f7

fix readme.md

Browse files
Files changed (1) hide show
  1. README.md +73 -9
README.md CHANGED
@@ -8,22 +8,86 @@ tags:
8
  - kerasformers
9
  - image-classification
10
  - convnextv2
11
- - tf
12
- - jax
13
  - pytorch
 
 
14
  ---
15
 
16
- # convnextv2_tiny_fcmae_ft_in1k
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
- Pure-Keras 3 image-classification weight for [kerasformers](https://github.com/IMvision12/KerasFormers), converted from [timm/convnextv2_tiny.fcmae_ft_in1k](https://huggingface.co/timm/convnextv2_tiny.fcmae_ft_in1k).
19
 
20
- > This weight comes from a **non-commercial** upstream checkpoint (CC BY-NC 4.0). Use it for non-commercial purposes only.
21
 
22
- ## Usage
23
 
24
  ```python
25
- from kerasformers.models.convnextv2 import ConvNeXtV2ImageClassify
26
- model = ConvNeXtV2ImageClassify.from_weights("convnextv2_tiny_fcmae_ft_in1k")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  ```
28
 
29
- License: **cc-by-nc-4.0**, inherited from the upstream source.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  - kerasformers
9
  - image-classification
10
  - convnextv2
11
+ - backbone
12
+ - arxiv:2301.00808
13
  - pytorch
14
+ - jax
15
+ - tf
16
  ---
17
 
18
+ ## ***See [our collection](https://huggingface.co/collections/kerasformers/convnext-v2-6a6bd292f10bf60554146f7b) for all versions of ConvNeXt-V2.***
19
+
20
+ # Run ConvNeXt-V2 with Keras 3: JAX, PyTorch, or TensorFlow
21
+
22
+ [![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)
23
+
24
+ # kerasformers/convnextv2_tiny_fcmae_ft_in1k
25
+
26
+ 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)
27
+
28
+ ConvNeXt V2 adds Global Response Normalization and FCMAE pretraining. Same classifier / backbone split as ConvNeXt.
29
+
30
+ For more details on the model, please go to the upstream [model card](https://huggingface.co/timm/convnextv2_tiny.fcmae_ft_in1k).
31
 
32
+ 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**.
33
 
34
+ This is an **image-classification / backbone** checkpoint (`ConvNeXtV2ImageClassify` / `ConvNeXtV2Model`).
35
 
36
+ ## ✨ Quick start
37
 
38
  ```python
39
+ import os
40
+ os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
41
+
42
+ from PIL import Image
43
+ import numpy as np
44
+ from kerasformers.models.convnextv2 import ConvNeXtV2ImageClassify, ConvNeXtV2Model
45
+
46
+ model = ConvNeXtV2ImageClassify.from_weights("kerasformers/convnextv2_tiny_fcmae_ft_in1k")
47
+ backbone = ConvNeXtV2Model.from_weights(
48
+ "kerasformers/convnextv2_tiny_fcmae_ft_in1k", as_backbone=True
49
+ )
50
+
51
+ image = Image.open("your_image.jpg").convert("RGB")
52
+ image = image.resize((224, 224))
53
+ x = np.asarray(image, dtype="float32")[None] # (1, H, W, 3)
54
+ print(model(x).shape) # (1, num_classes)
55
+ feats = backbone(x)
56
+ print(len(feats), [tuple(f.shape) for f in feats])
57
  ```
58
 
59
+ Load any ConvNeXt-V2 variant the same way with `from_weights("kerasformers/<variant>")`:
60
+
61
+ | Variant | Hub |
62
+ |---|---|
63
+ | `convnextv2_atto_fcmae_ft_in1k` | [`kerasformers/convnextv2_atto_fcmae_ft_in1k`](https://huggingface.co/kerasformers/convnextv2_atto_fcmae_ft_in1k) |
64
+ | `convnextv2_base_fcmae_ft_in1k` | [`kerasformers/convnextv2_base_fcmae_ft_in1k`](https://huggingface.co/kerasformers/convnextv2_base_fcmae_ft_in1k) |
65
+ | `convnextv2_base_fcmae_ft_in22k_in1k` | [`kerasformers/convnextv2_base_fcmae_ft_in22k_in1k`](https://huggingface.co/kerasformers/convnextv2_base_fcmae_ft_in22k_in1k) |
66
+ | `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) |
67
+ | `convnextv2_femto_fcmae_ft_in1k` | [`kerasformers/convnextv2_femto_fcmae_ft_in1k`](https://huggingface.co/kerasformers/convnextv2_femto_fcmae_ft_in1k) |
68
+ | `convnextv2_huge_fcmae_ft_in1k` | [`kerasformers/convnextv2_huge_fcmae_ft_in1k`](https://huggingface.co/kerasformers/convnextv2_huge_fcmae_ft_in1k) |
69
+ | `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) |
70
+ | `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) |
71
+ | `convnextv2_large_fcmae_ft_in1k` | [`kerasformers/convnextv2_large_fcmae_ft_in1k`](https://huggingface.co/kerasformers/convnextv2_large_fcmae_ft_in1k) |
72
+ | `convnextv2_large_fcmae_ft_in22k_in1k` | [`kerasformers/convnextv2_large_fcmae_ft_in22k_in1k`](https://huggingface.co/kerasformers/convnextv2_large_fcmae_ft_in22k_in1k) |
73
+ | `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) |
74
+ | `convnextv2_nano_fcmae_ft_in1k` | [`kerasformers/convnextv2_nano_fcmae_ft_in1k`](https://huggingface.co/kerasformers/convnextv2_nano_fcmae_ft_in1k) |
75
+ | `convnextv2_nano_fcmae_ft_in22k_in1k` | [`kerasformers/convnextv2_nano_fcmae_ft_in22k_in1k`](https://huggingface.co/kerasformers/convnextv2_nano_fcmae_ft_in22k_in1k) |
76
+ | `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) |
77
+ | `convnextv2_pico_fcmae_ft_in1k` | [`kerasformers/convnextv2_pico_fcmae_ft_in1k`](https://huggingface.co/kerasformers/convnextv2_pico_fcmae_ft_in1k) |
78
+ | `convnextv2_tiny_fcmae_ft_in1k` | [`kerasformers/convnextv2_tiny_fcmae_ft_in1k`](https://huggingface.co/kerasformers/convnextv2_tiny_fcmae_ft_in1k) |
79
+ | `convnextv2_tiny_fcmae_ft_in22k_in1k` | [`kerasformers/convnextv2_tiny_fcmae_ft_in22k_in1k`](https://huggingface.co/kerasformers/convnextv2_tiny_fcmae_ft_in22k_in1k) |
80
+ | `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) |
81
+
82
+ ## Tips
83
+
84
+ - Set `KERAS_BACKEND` **before** importing Keras / kerasformers.
85
+ - `ConvNeXtV2ImageClassify` returns class logits; `ConvNeXtV2Model` returns features (`as_backbone=True` for multi-scale stages).
86
+ - See [docs](https://imvision12.github.io/KerasFormers/classification_backbones/) and [Loading Weights](https://imvision12.github.io/KerasFormers/loading_weights/).
87
+ - Upstream / timm checkpoints: `ConvNeXtV2ImageClassify.from_weights("hf:timm/convnextv2_tiny.fcmae_ft_in1k")`.
88
+
89
+ ## Special Thanks
90
+
91
+ A huge thank you to the ConvNeXt-V2 authors and the timm / Hub communities for creating and releasing these models.
92
+
93
+ License: see YAML `license` (usually matches the upstream checkpoint).