Instructions to use zeromodels/regnet-x-004 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use zeromodels/regnet-x-004 with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://zeromodels/regnet-x-004") - Notebooks
- Google Colab
- Kaggle
Add regnet-x-004
Browse files- README.md +99 -0
- model.weights.h5 +3 -0
- zm_config.json +29 -0
README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
pipeline_tag: image-classification
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
base_model: facebook/regnet-x-004
|
| 5 |
+
library_name: zeromodels
|
| 6 |
+
tags:
|
| 7 |
+
- keras
|
| 8 |
+
- zeromodels
|
| 9 |
+
- image-classification
|
| 10 |
+
- regnet
|
| 11 |
+
- backbone
|
| 12 |
+
- arxiv:2003.13678
|
| 13 |
+
- pytorch
|
| 14 |
+
- jax
|
| 15 |
+
- tf
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
## ***See [our collection](https://huggingface.co/collections/zeromodels/regnet-6a9270a4e723a861ea988d0b) for all versions of RegNet.***
|
| 19 |
+
|
| 20 |
+
# Run RegNet with Keras 3: JAX, PyTorch, or TensorFlow
|
| 21 |
+
|
| 22 |
+
[](https://github.com/IMvision12/ZeroModels) [](https://imvision12.github.io/ZeroModels/regnet/) [](https://huggingface.co/collections/zeromodels/regnet-6a9270a4e723a861ea988d0b)
|
| 23 |
+
|
| 24 |
+
# zeromodels/regnet-x-004
|
| 25 |
+
|
| 26 |
+
Paper: [Designing Network Design Spaces (arXiv:2003.13678)](https://arxiv.org/abs/2003.13678) · [HF Papers](https://huggingface.co/papers/2003.13678)
|
| 27 |
+
|
| 28 |
+
RegNet is a family of ConvNets whose per-stage widths and depths follow a simple quantized-linear rule. This is the **X** variant: a 3x3 stride-2 stem then four stages of `1x1 -> 3x3 grouped -> [SE] -> 1x1` residual blocks. Use as an ImageNet classifier or a 4-stage backbone.
|
| 29 |
+
|
| 30 |
+
For more details on the model, please go to the upstream [model card](https://huggingface.co/facebook/regnet-x-004).
|
| 31 |
+
|
| 32 |
+
Pure-**Keras 3** conversion of [`facebook/regnet-x-004`](https://huggingface.co/facebook/regnet-x-004) for [zeromodels](https://github.com/IMvision12/ZeroModels). One implementation runs unmodified on **TensorFlow / Torch / JAX**.
|
| 33 |
+
|
| 34 |
+
This is an **image-classification / backbone** checkpoint (`RegNetImageClassify` / `RegNetModel`).
|
| 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 zeromodels.models.regnet import RegNetImageClassify, RegNetModel
|
| 45 |
+
|
| 46 |
+
model = RegNetImageClassify.from_weights("zeromodels/regnet-x-004")
|
| 47 |
+
backbone = RegNetModel.from_weights("zeromodels/regnet-x-004", as_backbone=True)
|
| 48 |
+
|
| 49 |
+
image = Image.open("your_image.jpg").convert("RGB")
|
| 50 |
+
image = image.resize((224, 224))
|
| 51 |
+
x = np.asarray(image, dtype="float32")[None] # (1, H, W, 3)
|
| 52 |
+
print(model(x).shape) # (1, num_classes)
|
| 53 |
+
feats = backbone(x)
|
| 54 |
+
print(len(feats), [tuple(f.shape) for f in feats])
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
Load any RegNet variant the same way with `from_weights("zeromodels/<variant>")`:
|
| 58 |
+
|
| 59 |
+
| Variant | Hub |
|
| 60 |
+
|---|---|
|
| 61 |
+
| `regnet-x-002` | [`zeromodels/regnet-x-002`](https://huggingface.co/zeromodels/regnet-x-002) |
|
| 62 |
+
| `regnet-x-004` | [`zeromodels/regnet-x-004`](https://huggingface.co/zeromodels/regnet-x-004) |
|
| 63 |
+
| `regnet-x-006` | [`zeromodels/regnet-x-006`](https://huggingface.co/zeromodels/regnet-x-006) |
|
| 64 |
+
| `regnet-x-008` | [`zeromodels/regnet-x-008`](https://huggingface.co/zeromodels/regnet-x-008) |
|
| 65 |
+
| `regnet-x-016` | [`zeromodels/regnet-x-016`](https://huggingface.co/zeromodels/regnet-x-016) |
|
| 66 |
+
| `regnet-x-032` | [`zeromodels/regnet-x-032`](https://huggingface.co/zeromodels/regnet-x-032) |
|
| 67 |
+
| `regnet-x-040` | [`zeromodels/regnet-x-040`](https://huggingface.co/zeromodels/regnet-x-040) |
|
| 68 |
+
| `regnet-x-064` | [`zeromodels/regnet-x-064`](https://huggingface.co/zeromodels/regnet-x-064) |
|
| 69 |
+
| `regnet-x-080` | [`zeromodels/regnet-x-080`](https://huggingface.co/zeromodels/regnet-x-080) |
|
| 70 |
+
| `regnet-x-120` | [`zeromodels/regnet-x-120`](https://huggingface.co/zeromodels/regnet-x-120) |
|
| 71 |
+
| `regnet-x-160` | [`zeromodels/regnet-x-160`](https://huggingface.co/zeromodels/regnet-x-160) |
|
| 72 |
+
| `regnet-x-320` | [`zeromodels/regnet-x-320`](https://huggingface.co/zeromodels/regnet-x-320) |
|
| 73 |
+
| `regnet-y-002` | [`zeromodels/regnet-y-002`](https://huggingface.co/zeromodels/regnet-y-002) |
|
| 74 |
+
| `regnet-y-004` | [`zeromodels/regnet-y-004`](https://huggingface.co/zeromodels/regnet-y-004) |
|
| 75 |
+
| `regnet-y-006` | [`zeromodels/regnet-y-006`](https://huggingface.co/zeromodels/regnet-y-006) |
|
| 76 |
+
| `regnet-y-008` | [`zeromodels/regnet-y-008`](https://huggingface.co/zeromodels/regnet-y-008) |
|
| 77 |
+
| `regnet-y-016` | [`zeromodels/regnet-y-016`](https://huggingface.co/zeromodels/regnet-y-016) |
|
| 78 |
+
| `regnet-y-032` | [`zeromodels/regnet-y-032`](https://huggingface.co/zeromodels/regnet-y-032) |
|
| 79 |
+
| `regnet-y-040` | [`zeromodels/regnet-y-040`](https://huggingface.co/zeromodels/regnet-y-040) |
|
| 80 |
+
| `regnet-y-064` | [`zeromodels/regnet-y-064`](https://huggingface.co/zeromodels/regnet-y-064) |
|
| 81 |
+
| `regnet-y-080` | [`zeromodels/regnet-y-080`](https://huggingface.co/zeromodels/regnet-y-080) |
|
| 82 |
+
| `regnet-y-120` | [`zeromodels/regnet-y-120`](https://huggingface.co/zeromodels/regnet-y-120) |
|
| 83 |
+
| `regnet-y-160` | [`zeromodels/regnet-y-160`](https://huggingface.co/zeromodels/regnet-y-160) |
|
| 84 |
+
| `regnet-y-320` | [`zeromodels/regnet-y-320`](https://huggingface.co/zeromodels/regnet-y-320) |
|
| 85 |
+
|
| 86 |
+
## Tips
|
| 87 |
+
|
| 88 |
+
- Set `KERAS_BACKEND` **before** importing Keras / zeromodels.
|
| 89 |
+
- `RegNetImageClassify` returns class logits; `RegNetModel` returns features (`as_backbone=True` for multi-scale stages at strides 4, 8, 16, 32).
|
| 90 |
+
- Normalization is baked in (`include_normalization=True`): pass raw `[0, 255]` pixels.
|
| 91 |
+
- Both `channels_last` and `channels_first` are supported (bit-exact); set the format before building.
|
| 92 |
+
- See [docs](https://imvision12.github.io/ZeroModels/regnet/) and [Loading Weights](https://imvision12.github.io/ZeroModels/loading_weights/).
|
| 93 |
+
- Upstream checkpoints: `RegNetImageClassify.from_weights("hf:facebook/regnet-x-004")`.
|
| 94 |
+
|
| 95 |
+
## Special Thanks
|
| 96 |
+
|
| 97 |
+
A huge thank you to the RegNet authors and the transformers / Hub communities for creating and releasing these models.
|
| 98 |
+
|
| 99 |
+
License: see YAML `license` (matches the upstream checkpoint: apache-2.0).
|
model.weights.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9fe1f9f09fc88f2a766c2aaa02a88719ae088d90eb43b7339ddb487170c4003f
|
| 3 |
+
size 21433656
|
zm_config.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"library_name": "zeromodels",
|
| 3 |
+
"zeromodels_version": "1.2.7",
|
| 4 |
+
"model_module": "zeromodels.models.regnet",
|
| 5 |
+
"model_class": "RegNetImageClassify",
|
| 6 |
+
"variant": "regnet-x-004",
|
| 7 |
+
"weights": "model.weights.h5",
|
| 8 |
+
"schema_version": 2,
|
| 9 |
+
"model_type": "regnet",
|
| 10 |
+
"vision_config": {
|
| 11 |
+
"embedding_size": 32,
|
| 12 |
+
"hidden_sizes": [
|
| 13 |
+
32,
|
| 14 |
+
64,
|
| 15 |
+
160,
|
| 16 |
+
384
|
| 17 |
+
],
|
| 18 |
+
"depths": [
|
| 19 |
+
1,
|
| 20 |
+
2,
|
| 21 |
+
7,
|
| 22 |
+
12
|
| 23 |
+
],
|
| 24 |
+
"groups_width": 16,
|
| 25 |
+
"layer_type": "x",
|
| 26 |
+
"downsample_in_first_stage": true,
|
| 27 |
+
"num_classes": 1000
|
| 28 |
+
}
|
| 29 |
+
}
|