IMvision12 commited on
Commit
9848b28
·
verified ·
1 Parent(s): b586aae

fix readme.md

Browse files
Files changed (1) hide show
  1. README.md +76 -7
README.md CHANGED
@@ -8,23 +8,92 @@ tags:
8
  - kerasformers
9
  - image-classification
10
  - convnext
11
- - jax
 
12
  - pytorch
 
13
  - tf
14
  ---
15
 
16
- # convnext_xlarge_fb_in22k
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
- Pure-Keras 3 image-classification weight for [kerasformers](https://github.com/IMvision12/KerasFormers), converted from [timm/convnext_xlarge.fb_in22k](https://huggingface.co/timm/convnext_xlarge.fb_in22k).
19
 
20
- ## Usage
 
 
21
 
22
  ```python
 
 
23
 
24
- from kerasformers.models.convnext import ConvNeXtImageClassify
 
 
25
 
26
- model = ConvNeXtImageClassify.from_weights("convnext_xlarge_fb_in22k")
 
 
 
27
 
 
 
 
 
 
 
28
  ```
29
 
30
- License: **apache-2.0**, inherited from the upstream source.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  - kerasformers
9
  - image-classification
10
  - convnext
11
+ - backbone
12
+ - arxiv:2201.03545
13
  - pytorch
14
+ - jax
15
  - tf
16
  ---
17
 
18
+ ## ***See [our collection](https://huggingface.co/collections/kerasformers/convnext-6a6bd0f2a94679977d564d48) for all versions of ConvNeXt.***
19
+
20
+ # Run ConvNeXt 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-blue)](https://imvision12.github.io/KerasFormers/classification_backbones/) [![Collection](https://img.shields.io/badge/HF-ConvNeXt%20collection-yellow)](https://huggingface.co/collections/kerasformers/convnext-6a6bd0f2a94679977d564d48)
23
+
24
+ # kerasformers/convnext_xlarge_fb_in22k
25
+
26
+ Paper: [A ConvNet for the 2020s (arXiv:2201.03545)](https://arxiv.org/abs/2201.03545) · [HF Papers](https://huggingface.co/papers/2201.03545)
27
+
28
+ ConvNeXt modernizes a ResNet-style CNN with ViT-inspired design choices. Use as ImageNet classifier or 4-stage backbone.
29
+
30
+ For more details on the model, please go to the upstream [model card](https://huggingface.co/timm/convnext_xlarge.fb_in22k).
31
 
32
+ Pure-**Keras 3** conversion of [`timm/convnext_xlarge.fb_in22k`](https://huggingface.co/timm/convnext_xlarge.fb_in22k) for [kerasformers](https://github.com/IMvision12/KerasFormers). One implementation runs unmodified on **TensorFlow / Torch / JAX**.
33
 
34
+ This is an **image-classification / backbone** checkpoint (`ConvNeXtImageClassify` / `ConvNeXtModel`).
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.convnext import ConvNeXtImageClassify, ConvNeXtModel
45
 
46
+ model = ConvNeXtImageClassify.from_weights("kerasformers/convnext_xlarge_fb_in22k")
47
+ backbone = ConvNeXtModel.from_weights(
48
+ "kerasformers/convnext_xlarge_fb_in22k", 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 variant the same way with `from_weights("kerasformers/<variant>")`:
60
+
61
+ | Variant | Hub |
62
+ |---|---|
63
+ | `convnext_atto_d2_in1k` | [`kerasformers/convnext_atto_d2_in1k`](https://huggingface.co/kerasformers/convnext_atto_d2_in1k) |
64
+ | `convnext_base_fb_in1k` | [`kerasformers/convnext_base_fb_in1k`](https://huggingface.co/kerasformers/convnext_base_fb_in1k) |
65
+ | `convnext_base_fb_in22k` | [`kerasformers/convnext_base_fb_in22k`](https://huggingface.co/kerasformers/convnext_base_fb_in22k) |
66
+ | `convnext_base_fb_in22k_ft_in1k` | [`kerasformers/convnext_base_fb_in22k_ft_in1k`](https://huggingface.co/kerasformers/convnext_base_fb_in22k_ft_in1k) |
67
+ | `convnext_base_fb_in22k_ft_in1k_384` | [`kerasformers/convnext_base_fb_in22k_ft_in1k_384`](https://huggingface.co/kerasformers/convnext_base_fb_in22k_ft_in1k_384) |
68
+ | `convnext_femto_d1_in1k` | [`kerasformers/convnext_femto_d1_in1k`](https://huggingface.co/kerasformers/convnext_femto_d1_in1k) |
69
+ | `convnext_large_fb_in1k` | [`kerasformers/convnext_large_fb_in1k`](https://huggingface.co/kerasformers/convnext_large_fb_in1k) |
70
+ | `convnext_large_fb_in22k` | [`kerasformers/convnext_large_fb_in22k`](https://huggingface.co/kerasformers/convnext_large_fb_in22k) |
71
+ | `convnext_large_fb_in22k_ft_in1k` | [`kerasformers/convnext_large_fb_in22k_ft_in1k`](https://huggingface.co/kerasformers/convnext_large_fb_in22k_ft_in1k) |
72
+ | `convnext_large_fb_in22k_ft_in1k_384` | [`kerasformers/convnext_large_fb_in22k_ft_in1k_384`](https://huggingface.co/kerasformers/convnext_large_fb_in22k_ft_in1k_384) |
73
+ | `convnext_nano_d1h_in1k` | [`kerasformers/convnext_nano_d1h_in1k`](https://huggingface.co/kerasformers/convnext_nano_d1h_in1k) |
74
+ | `convnext_nano_in12k_ft_in1k` | [`kerasformers/convnext_nano_in12k_ft_in1k`](https://huggingface.co/kerasformers/convnext_nano_in12k_ft_in1k) |
75
+ | `convnext_pico_d1_in1k` | [`kerasformers/convnext_pico_d1_in1k`](https://huggingface.co/kerasformers/convnext_pico_d1_in1k) |
76
+ | `convnext_small_fb_in1k` | [`kerasformers/convnext_small_fb_in1k`](https://huggingface.co/kerasformers/convnext_small_fb_in1k) |
77
+ | `convnext_small_fb_in22k` | [`kerasformers/convnext_small_fb_in22k`](https://huggingface.co/kerasformers/convnext_small_fb_in22k) |
78
+ | `convnext_small_fb_in22k_ft_in1k` | [`kerasformers/convnext_small_fb_in22k_ft_in1k`](https://huggingface.co/kerasformers/convnext_small_fb_in22k_ft_in1k) |
79
+ | `convnext_small_fb_in22k_ft_in1k_384` | [`kerasformers/convnext_small_fb_in22k_ft_in1k_384`](https://huggingface.co/kerasformers/convnext_small_fb_in22k_ft_in1k_384) |
80
+ | `convnext_tiny_fb_in1k` | [`kerasformers/convnext_tiny_fb_in1k`](https://huggingface.co/kerasformers/convnext_tiny_fb_in1k) |
81
+ | `convnext_tiny_fb_in22k` | [`kerasformers/convnext_tiny_fb_in22k`](https://huggingface.co/kerasformers/convnext_tiny_fb_in22k) |
82
+ | `convnext_tiny_fb_in22k_ft_in1k` | [`kerasformers/convnext_tiny_fb_in22k_ft_in1k`](https://huggingface.co/kerasformers/convnext_tiny_fb_in22k_ft_in1k) |
83
+ | `convnext_tiny_fb_in22k_ft_in1k_384` | [`kerasformers/convnext_tiny_fb_in22k_ft_in1k_384`](https://huggingface.co/kerasformers/convnext_tiny_fb_in22k_ft_in1k_384) |
84
+ | `convnext_xlarge_fb_in22k` | [`kerasformers/convnext_xlarge_fb_in22k`](https://huggingface.co/kerasformers/convnext_xlarge_fb_in22k) |
85
+ | `convnext_xlarge_fb_in22k_ft_in1k` | [`kerasformers/convnext_xlarge_fb_in22k_ft_in1k`](https://huggingface.co/kerasformers/convnext_xlarge_fb_in22k_ft_in1k) |
86
+ | `convnext_xlarge_fb_in22k_ft_in1k_384` | [`kerasformers/convnext_xlarge_fb_in22k_ft_in1k_384`](https://huggingface.co/kerasformers/convnext_xlarge_fb_in22k_ft_in1k_384) |
87
+
88
+ ## Tips
89
+
90
+ - Set `KERAS_BACKEND` **before** importing Keras / kerasformers.
91
+ - `ConvNeXtImageClassify` returns class logits; `ConvNeXtModel` returns features (`as_backbone=True` for multi-scale stages).
92
+ - See [docs](https://imvision12.github.io/KerasFormers/classification_backbones/) and [Loading Weights](https://imvision12.github.io/KerasFormers/loading_weights/).
93
+ - Upstream / timm checkpoints: `ConvNeXtImageClassify.from_weights("hf:timm/convnext_xlarge.fb_in22k")`.
94
+
95
+ ## Special Thanks
96
+
97
+ A huge thank you to the ConvNeXt authors and the timm / Hub communities for creating and releasing these models.
98
+
99
+ License: see YAML `license` (usually matches the upstream checkpoint).