Instructions to use zeromodels/regnet-y-064 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use zeromodels/regnet-y-064 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-y-064") - Notebooks
- Google Colab
- Kaggle
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -37,21 +37,23 @@ This is an **image-classification / backbone** checkpoint (`RegNetImageClassify`
|
|
| 37 |
|
| 38 |
```python
|
| 39 |
import os
|
|
|
|
| 40 |
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
|
| 41 |
|
| 42 |
from PIL import Image
|
| 43 |
-
import
|
| 44 |
-
from zeromodels.models.regnet import RegNetImageClassify, RegNetModel
|
| 45 |
|
| 46 |
model = RegNetImageClassify.from_weights("zeromodels/regnet-y-064")
|
| 47 |
-
|
| 48 |
|
| 49 |
image = Image.open("your_image.jpg").convert("RGB")
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
print(
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
| 55 |
```
|
| 56 |
|
| 57 |
Load any RegNet variant the same way with `from_weights("zeromodels/<variant>")`:
|
|
|
|
| 37 |
|
| 38 |
```python
|
| 39 |
import os
|
| 40 |
+
|
| 41 |
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
|
| 42 |
|
| 43 |
from PIL import Image
|
| 44 |
+
from zeromodels.models.regnet import RegNetImageClassify, RegNetModel, RegNetImageProcessor
|
|
|
|
| 45 |
|
| 46 |
model = RegNetImageClassify.from_weights("zeromodels/regnet-y-064")
|
| 47 |
+
processor = RegNetImageProcessor.from_weights("zeromodels/regnet-y-064")
|
| 48 |
|
| 49 |
image = Image.open("your_image.jpg").convert("RGB")
|
| 50 |
+
pixels = processor(image) # resize + normalize (normalization lives in the processor)
|
| 51 |
+
logits = model(pixels, training=False)
|
| 52 |
+
print(logits.shape) # (1, num_classes)
|
| 53 |
+
|
| 54 |
+
# Feature extraction: the backbone without the classifier head
|
| 55 |
+
backbone = RegNetModel.from_weights("zeromodels/regnet-y-064", as_backbone=True)
|
| 56 |
+
features = backbone(pixels, training=False)
|
| 57 |
```
|
| 58 |
|
| 59 |
Load any RegNet variant the same way with `from_weights("zeromodels/<variant>")`:
|