Instructions to use zeromodels/pvt-medium-224 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ZeroModels
How to use zeromodels/pvt-medium-224 with ZeroModels:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Keras
How to use zeromodels/pvt-medium-224 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-medium-224") - 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 (`PvtImageClassify` /
|
|
| 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 import PvtImageClassify, PvtModel
|
| 48 |
|
| 49 |
model = PvtImageClassify.from_weights("zeromodels/pvt-medium-224")
|
| 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 PVT
|
|
|
|
| 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 import PvtImageClassify, PvtModel, PvtImageProcessor
|
|
|
|
| 48 |
|
| 49 |
model = PvtImageClassify.from_weights("zeromodels/pvt-medium-224")
|
| 50 |
+
processor = PvtImageProcessor.from_weights("zeromodels/pvt-medium-224")
|
| 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 = PvtModel.from_weights("zeromodels/pvt-medium-224", 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 PVT
|