Instructions to use zeromodels/pvt-v2-b3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use zeromodels/pvt-v2-b3 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/pvt-v2-b3") - Notebooks
- Google Colab
- Kaggle
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -40,20 +40,23 @@ This is an **image-classification / backbone** checkpoint (`PvtV2ImageClassify`
|
|
| 40 |
|
| 41 |
```python
|
| 42 |
import os
|
|
|
|
| 43 |
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
|
| 44 |
|
| 45 |
from PIL import Image
|
| 46 |
-
import
|
| 47 |
-
from zeromodels.models.pvt_v2 import PvtV2ImageClassify, PvtV2Model
|
| 48 |
|
| 49 |
model = PvtV2ImageClassify.from_weights("zeromodels/pvt-v2-b3")
|
| 50 |
-
|
| 51 |
|
| 52 |
-
image = Image.open("your_image.jpg").convert("RGB")
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
| 57 |
```
|
| 58 |
|
| 59 |
Normalization is baked into the graph, so pass raw `[0, 255]` pixels. Load any PVTv2
|
|
|
|
| 40 |
|
| 41 |
```python
|
| 42 |
import os
|
| 43 |
+
|
| 44 |
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
|
| 45 |
|
| 46 |
from PIL import Image
|
| 47 |
+
from zeromodels.models.pvt_v2 import PvtV2ImageClassify, PvtV2Model, PvtV2ImageProcessor
|
|
|
|
| 48 |
|
| 49 |
model = PvtV2ImageClassify.from_weights("zeromodels/pvt-v2-b3")
|
| 50 |
+
processor = PvtV2ImageProcessor.from_weights("zeromodels/pvt-v2-b3")
|
| 51 |
|
| 52 |
+
image = Image.open("your_image.jpg").convert("RGB")
|
| 53 |
+
pixels = processor(image) # resize + normalize (normalization lives in the processor)
|
| 54 |
+
logits = model(pixels, training=False)
|
| 55 |
+
print(logits.shape) # (1, num_classes)
|
| 56 |
+
|
| 57 |
+
# Feature extraction: the backbone without the classifier head
|
| 58 |
+
backbone = PvtV2Model.from_weights("zeromodels/pvt-v2-b3", as_backbone=True)
|
| 59 |
+
features = backbone(pixels, training=False)
|
| 60 |
```
|
| 61 |
|
| 62 |
Normalization is baked into the graph, so pass raw `[0, 255]` pixels. Load any PVTv2
|