Instructions to use zeromodels/maskformer-swin-tiny-coco with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use zeromodels/maskformer-swin-tiny-coco 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/maskformer-swin-tiny-coco") - Notebooks
- Google Colab
- Kaggle
Migrate to zeromodels (rename kf_*.json -> zm_*.json, fix refs in config + README, ensure tag + badge)
Browse files- README.md +17 -17
- kf_config.json → zm_config.json +35 -35
- kf_preprocessor.json → zm_preprocessor.json +18 -18
README.md
CHANGED
|
@@ -2,10 +2,10 @@
|
|
| 2 |
pipeline_tag: image-segmentation
|
| 3 |
license: cc-by-nc-4.0
|
| 4 |
base_model: facebook/maskformer-swin-tiny-coco
|
| 5 |
-
library_name:
|
| 6 |
tags:
|
| 7 |
- keras
|
| 8 |
-
-
|
| 9 |
- maskformer
|
| 10 |
- universal-segmentation
|
| 11 |
- image-segmentation
|
|
@@ -15,13 +15,13 @@ tags:
|
|
| 15 |
- tf
|
| 16 |
---
|
| 17 |
|
| 18 |
-
## ***See [our collection](https://huggingface.co/collections/
|
| 19 |
|
| 20 |
# Run MaskFormer with Keras 3: JAX, PyTorch, or TensorFlow
|
| 21 |
|
| 22 |
-
[](https://arxiv.org/abs/2107.06278) · [HF Papers](https://huggingface.co/papers/2107.06278)
|
| 27 |
|
|
@@ -29,7 +29,7 @@ MaskFormer reframes segmentation as mask classification: a backbone and pixel de
|
|
| 29 |
|
| 30 |
For more details on the model, please go to the upstream [model card](https://huggingface.co/facebook/maskformer-swin-tiny-coco).
|
| 31 |
|
| 32 |
-
Pure-**Keras 3** conversion of [`facebook/maskformer-swin-tiny-coco`](https://huggingface.co/facebook/maskformer-swin-tiny-coco) for [
|
| 33 |
|
| 34 |
This is a **universal segmentation** checkpoint (`MaskFormerUniversalSegment`) trained on COCO panoptic.
|
| 35 |
|
|
@@ -40,10 +40,10 @@ import os
|
|
| 40 |
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
|
| 41 |
|
| 42 |
from PIL import Image
|
| 43 |
-
from
|
| 44 |
|
| 45 |
-
model = MaskFormerUniversalSegment.from_weights("
|
| 46 |
-
processor = MaskFormerImageProcessor.from_weights("
|
| 47 |
|
| 48 |
image = Image.open("your_image.jpg").convert("RGB")
|
| 49 |
output = model(processor(image)["pixel_values"], training=False)
|
|
@@ -53,21 +53,21 @@ result = processor.post_process_panoptic_segmentation(
|
|
| 53 |
print(result["segmentation"].shape)
|
| 54 |
```
|
| 55 |
|
| 56 |
-
Load any MaskFormer variant the same way with `from_weights("
|
| 57 |
|
| 58 |
| Variant | Hub | Dataset |
|
| 59 |
|---|---|---|
|
| 60 |
-
| `maskformer-swin-tiny-coco` | [`
|
| 61 |
-
| `maskformer-swin-small-coco` | [`
|
| 62 |
-
| `maskformer-swin-base-coco` | [`
|
| 63 |
-
| `maskformer-swin-tiny-ade` | [`
|
| 64 |
-
| `maskformer-swin-base-ade` | [`
|
| 65 |
|
| 66 |
## Tips
|
| 67 |
|
| 68 |
-
- Set `KERAS_BACKEND` **before** importing Keras /
|
| 69 |
- Prefer `MaskFormerImageProcessor.from_weights(...)` so resolution matches the variant.
|
| 70 |
-
- See [MaskFormer docs]({DOCS_URL}) and [Loading Weights](https://imvision12.github.io/
|
| 71 |
- Community / upstream weights: `MaskFormerUniversalSegment.from_weights("hf:facebook/maskformer-swin-tiny-coco")`.
|
| 72 |
|
| 73 |
## Special Thanks
|
|
|
|
| 2 |
pipeline_tag: image-segmentation
|
| 3 |
license: cc-by-nc-4.0
|
| 4 |
base_model: facebook/maskformer-swin-tiny-coco
|
| 5 |
+
library_name: zeromodels
|
| 6 |
tags:
|
| 7 |
- keras
|
| 8 |
+
- zeromodels
|
| 9 |
- maskformer
|
| 10 |
- universal-segmentation
|
| 11 |
- image-segmentation
|
|
|
|
| 15 |
- tf
|
| 16 |
---
|
| 17 |
|
| 18 |
+
## ***See [our collection](https://huggingface.co/collections/zeromodels/maskformer-6a6a8ece1c77558c676dfb9d) for all versions of MaskFormer.***
|
| 19 |
|
| 20 |
# Run MaskFormer with Keras 3: JAX, PyTorch, or TensorFlow
|
| 21 |
|
| 22 |
+
[](https://github.com/IMvision12/ZeroModels) [](https://imvision12.github.io/ZeroModels/maskformer/) [](https://huggingface.co/collections/zeromodels/maskformer-6a6a8ece1c77558c676dfb9d)
|
| 23 |
|
| 24 |
+
# zeromodels/maskformer-swin-tiny-coco
|
| 25 |
|
| 26 |
Paper: [Per-Pixel Classification is Not All You Need for Semantic Segmentation (arXiv:2107.06278)](https://arxiv.org/abs/2107.06278) · [HF Papers](https://huggingface.co/papers/2107.06278)
|
| 27 |
|
|
|
|
| 29 |
|
| 30 |
For more details on the model, please go to the upstream [model card](https://huggingface.co/facebook/maskformer-swin-tiny-coco).
|
| 31 |
|
| 32 |
+
Pure-**Keras 3** conversion of [`facebook/maskformer-swin-tiny-coco`](https://huggingface.co/facebook/maskformer-swin-tiny-coco) for [zeromodels](https://github.com/IMvision12/ZeroModels). One implementation runs unmodified on **TensorFlow / Torch / JAX**.
|
| 33 |
|
| 34 |
This is a **universal segmentation** checkpoint (`MaskFormerUniversalSegment`) trained on COCO panoptic.
|
| 35 |
|
|
|
|
| 40 |
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
|
| 41 |
|
| 42 |
from PIL import Image
|
| 43 |
+
from zeromodels.models.maskformer import MaskFormerUniversalSegment, MaskFormerImageProcessor
|
| 44 |
|
| 45 |
+
model = MaskFormerUniversalSegment.from_weights("zeromodels/maskformer-swin-tiny-coco")
|
| 46 |
+
processor = MaskFormerImageProcessor.from_weights("zeromodels/maskformer-swin-tiny-coco")
|
| 47 |
|
| 48 |
image = Image.open("your_image.jpg").convert("RGB")
|
| 49 |
output = model(processor(image)["pixel_values"], training=False)
|
|
|
|
| 53 |
print(result["segmentation"].shape)
|
| 54 |
```
|
| 55 |
|
| 56 |
+
Load any MaskFormer variant the same way with `from_weights("zeromodels/<variant>")`:
|
| 57 |
|
| 58 |
| Variant | Hub | Dataset |
|
| 59 |
|---|---|---|
|
| 60 |
+
| `maskformer-swin-tiny-coco` | [`zeromodels/maskformer-swin-tiny-coco`](https://huggingface.co/zeromodels/maskformer-swin-tiny-coco) | COCO |
|
| 61 |
+
| `maskformer-swin-small-coco` | [`zeromodels/maskformer-swin-small-coco`](https://huggingface.co/zeromodels/maskformer-swin-small-coco) | COCO |
|
| 62 |
+
| `maskformer-swin-base-coco` | [`zeromodels/maskformer-swin-base-coco`](https://huggingface.co/zeromodels/maskformer-swin-base-coco) | COCO |
|
| 63 |
+
| `maskformer-swin-tiny-ade` | [`zeromodels/maskformer-swin-tiny-ade`](https://huggingface.co/zeromodels/maskformer-swin-tiny-ade) | ADE20K |
|
| 64 |
+
| `maskformer-swin-base-ade` | [`zeromodels/maskformer-swin-base-ade`](https://huggingface.co/zeromodels/maskformer-swin-base-ade) | ADE20K |
|
| 65 |
|
| 66 |
## Tips
|
| 67 |
|
| 68 |
+
- Set `KERAS_BACKEND` **before** importing Keras / zeromodels.
|
| 69 |
- Prefer `MaskFormerImageProcessor.from_weights(...)` so resolution matches the variant.
|
| 70 |
+
- See [MaskFormer docs]({DOCS_URL}) and [Loading Weights](https://imvision12.github.io/ZeroModels/loading_weights/).
|
| 71 |
- Community / upstream weights: `MaskFormerUniversalSegment.from_weights("hf:facebook/maskformer-swin-tiny-coco")`.
|
| 72 |
|
| 73 |
## Special Thanks
|
kf_config.json → zm_config.json
RENAMED
|
@@ -1,36 +1,36 @@
|
|
| 1 |
-
{
|
| 2 |
-
"library_name": "
|
| 3 |
-
"
|
| 4 |
-
"model_module": "
|
| 5 |
-
"model_class": "MaskFormerUniversalSegment",
|
| 6 |
-
"variant": "maskformer-swin-tiny-coco",
|
| 7 |
-
"weights": "model.weights.h5",
|
| 8 |
-
"schema_version": 2,
|
| 9 |
-
"weight_dtype": "float32",
|
| 10 |
-
"model_type": "maskformer",
|
| 11 |
-
"vision_config": {
|
| 12 |
-
"backbone_embed_dim": 96,
|
| 13 |
-
"backbone_depths": [
|
| 14 |
-
2,
|
| 15 |
-
2,
|
| 16 |
-
6,
|
| 17 |
-
2
|
| 18 |
-
],
|
| 19 |
-
"backbone_num_heads": [
|
| 20 |
-
3,
|
| 21 |
-
6,
|
| 22 |
-
12,
|
| 23 |
-
24
|
| 24 |
-
],
|
| 25 |
-
"backbone_window_size": 7,
|
| 26 |
-
"fpn_feature_size": 256,
|
| 27 |
-
"mask_feature_size": 256,
|
| 28 |
-
"decoder_d_model": 256,
|
| 29 |
-
"decoder_num_layers": 6,
|
| 30 |
-
"decoder_heads": 8,
|
| 31 |
-
"decoder_ffn_dim": 2048,
|
| 32 |
-
"num_queries": 100,
|
| 33 |
-
"num_classes": 133,
|
| 34 |
-
"image_size": 384
|
| 35 |
-
}
|
| 36 |
}
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"library_name": "zeromodels",
|
| 3 |
+
"zeromodels_version": "1.2.1",
|
| 4 |
+
"model_module": "zeromodels.models.maskformer",
|
| 5 |
+
"model_class": "MaskFormerUniversalSegment",
|
| 6 |
+
"variant": "maskformer-swin-tiny-coco",
|
| 7 |
+
"weights": "model.weights.h5",
|
| 8 |
+
"schema_version": 2,
|
| 9 |
+
"weight_dtype": "float32",
|
| 10 |
+
"model_type": "maskformer",
|
| 11 |
+
"vision_config": {
|
| 12 |
+
"backbone_embed_dim": 96,
|
| 13 |
+
"backbone_depths": [
|
| 14 |
+
2,
|
| 15 |
+
2,
|
| 16 |
+
6,
|
| 17 |
+
2
|
| 18 |
+
],
|
| 19 |
+
"backbone_num_heads": [
|
| 20 |
+
3,
|
| 21 |
+
6,
|
| 22 |
+
12,
|
| 23 |
+
24
|
| 24 |
+
],
|
| 25 |
+
"backbone_window_size": 7,
|
| 26 |
+
"fpn_feature_size": 256,
|
| 27 |
+
"mask_feature_size": 256,
|
| 28 |
+
"decoder_d_model": 256,
|
| 29 |
+
"decoder_num_layers": 6,
|
| 30 |
+
"decoder_heads": 8,
|
| 31 |
+
"decoder_ffn_dim": 2048,
|
| 32 |
+
"num_queries": 100,
|
| 33 |
+
"num_classes": 133,
|
| 34 |
+
"image_size": 384
|
| 35 |
+
}
|
| 36 |
}
|
kf_preprocessor.json → zm_preprocessor.json
RENAMED
|
@@ -1,19 +1,19 @@
|
|
| 1 |
-
{
|
| 2 |
-
"library_name": "
|
| 3 |
-
"
|
| 4 |
-
"preprocessor_module": "
|
| 5 |
-
"preprocessor_class": "MaskFormerImageProcessor",
|
| 6 |
-
"variant": null,
|
| 7 |
-
"target_size": 384,
|
| 8 |
-
"image_mean": [
|
| 9 |
-
0.485,
|
| 10 |
-
0.456,
|
| 11 |
-
0.406
|
| 12 |
-
],
|
| 13 |
-
"image_std": [
|
| 14 |
-
0.229,
|
| 15 |
-
0.224,
|
| 16 |
-
0.225
|
| 17 |
-
],
|
| 18 |
-
"data_format": null
|
| 19 |
}
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"library_name": "zeromodels",
|
| 3 |
+
"zeromodels_version": "1.1.3",
|
| 4 |
+
"preprocessor_module": "zeromodels.models.maskformer",
|
| 5 |
+
"preprocessor_class": "MaskFormerImageProcessor",
|
| 6 |
+
"variant": null,
|
| 7 |
+
"target_size": 384,
|
| 8 |
+
"image_mean": [
|
| 9 |
+
0.485,
|
| 10 |
+
0.456,
|
| 11 |
+
0.406
|
| 12 |
+
],
|
| 13 |
+
"image_std": [
|
| 14 |
+
0.229,
|
| 15 |
+
0.224,
|
| 16 |
+
0.225
|
| 17 |
+
],
|
| 18 |
+
"data_format": null
|
| 19 |
}
|