Instructions to use zeromodels/mask2former-swin-tiny-coco-instance with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- KerasFormers
How to use zeromodels/mask2former-swin-tiny-coco-instance with KerasFormers:
# 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/mask2former-swin-tiny-coco-instance 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/mask2former-swin-tiny-coco-instance") - Notebooks
- Google Colab
- Kaggle
fix readme.md
Browse files
README.md
CHANGED
|
@@ -1,21 +1,77 @@
|
|
| 1 |
---
|
| 2 |
pipeline_tag: image-segmentation
|
| 3 |
license: mit
|
|
|
|
| 4 |
library_name: kerasformers
|
| 5 |
tags:
|
| 6 |
- keras
|
| 7 |
- kerasformers
|
| 8 |
- mask2former
|
| 9 |
-
-
|
| 10 |
-
-
|
|
|
|
| 11 |
- pytorch
|
|
|
|
|
|
|
| 12 |
---
|
| 13 |
|
| 14 |
-
# mask2former-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
|
| 18 |
```python
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
pipeline_tag: image-segmentation
|
| 3 |
license: mit
|
| 4 |
+
base_model: facebook/mask2former-swin-tiny-coco-instance
|
| 5 |
library_name: kerasformers
|
| 6 |
tags:
|
| 7 |
- keras
|
| 8 |
- kerasformers
|
| 9 |
- mask2former
|
| 10 |
+
- instance-segmentation
|
| 11 |
+
- image-segmentation
|
| 12 |
+
- arxiv:2112.01527
|
| 13 |
- pytorch
|
| 14 |
+
- jax
|
| 15 |
+
- tf
|
| 16 |
---
|
| 17 |
|
| 18 |
+
## ***See [our collection](https://huggingface.co/collections/kerasformers/mask2former-6a6a8f4248526cc9a74b9b97) for all versions of Mask2Former.***
|
| 19 |
+
|
| 20 |
+
# Run Mask2Former with Keras 3: JAX, PyTorch, or TensorFlow
|
| 21 |
+
|
| 22 |
+
[](https://github.com/IMvision12/KerasFormers) [](https://imvision12.github.io/KerasFormers/mask2former/) [](https://huggingface.co/collections/kerasformers/mask2former-6a6a8f4248526cc9a74b9b97)
|
| 23 |
+
|
| 24 |
+
# kerasformers/mask2former-swin-tiny-coco-instance
|
| 25 |
+
|
| 26 |
+
Paper: [Masked-attention Mask Transformer for Universal Image Segmentation (arXiv:2112.01527)](https://arxiv.org/abs/2112.01527) · [HF Papers](https://huggingface.co/papers/2112.01527)
|
| 27 |
+
|
| 28 |
+
Mask2Former improves MaskFormer with masked attention in the transformer decoder, restricting cross-attention to predicted mask regions for sharper boundaries and stronger universal segmentation.\n
|
| 29 |
+
For more details on the model, please go to the upstream [model card](https://huggingface.co/facebook/mask2former-swin-tiny-coco-instance).
|
| 30 |
+
|
| 31 |
+
Pure-**Keras 3** conversion of [`facebook/mask2former-swin-tiny-coco-instance`](https://huggingface.co/facebook/mask2former-swin-tiny-coco-instance) for [kerasformers](https://github.com/IMvision12/KerasFormers). One implementation runs unmodified on **TensorFlow / Torch / JAX**.
|
| 32 |
+
|
| 33 |
+
This is a **instance** checkpoint (`Mask2FormerUniversalSegment`) (trained for instance; architecture is universal).
|
| 34 |
|
| 35 |
+
## ✨ Quick start
|
| 36 |
|
| 37 |
```python
|
| 38 |
+
import os
|
| 39 |
+
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
|
| 40 |
+
|
| 41 |
+
from PIL import Image
|
| 42 |
+
from {meta['import_path']} import {meta['load_cls']}, {meta['proc_cls']}
|
| 43 |
+
|
| 44 |
+
model = {meta["load_cls"]}.from_weights("kerasformers/{variant}")
|
| 45 |
+
processor = {meta['proc_cls']}()
|
| 46 |
+
|
| 47 |
+
image = Image.open("your_image.jpg").convert("RGB")
|
| 48 |
+
output = model(processor(image)["pixel_values"], training=False)
|
| 49 |
+
result = processor.post_process_panoptic_segmentation(
|
| 50 |
+
output, target_size=(image.height, image.width)
|
| 51 |
+
)
|
| 52 |
+
print(result["segmentation"].shape)
|
| 53 |
```
|
| 54 |
+
|
| 55 |
+
Load any Mask2Former variant the same way with `from_weights("kerasformers/<variant>")`:
|
| 56 |
+
|
| 57 |
+
| Variant | Hub | Task |
|
| 58 |
+
|---|---|---|
|
| 59 |
+
| `mask2former-swin-tiny-coco-instance` | [`kerasformers/mask2former-swin-tiny-coco-instance`](https://huggingface.co/kerasformers/mask2former-swin-tiny-coco-instance) | instance |
|
| 60 |
+
| `mask2former-swin-small-coco-instance` | [`kerasformers/mask2former-swin-small-coco-instance`](https://huggingface.co/kerasformers/mask2former-swin-small-coco-instance) | instance |
|
| 61 |
+
| `mask2former-swin-base-coco-instance` | [`kerasformers/mask2former-swin-base-coco-instance`](https://huggingface.co/kerasformers/mask2former-swin-base-coco-instance) | instance |
|
| 62 |
+
| `mask2former-swin-large-coco-instance` | [`kerasformers/mask2former-swin-large-coco-instance`](https://huggingface.co/kerasformers/mask2former-swin-large-coco-instance) | instance |
|
| 63 |
+
| `mask2former-swin-tiny-coco-panoptic` | [`kerasformers/mask2former-swin-tiny-coco-panoptic`](https://huggingface.co/kerasformers/mask2former-swin-tiny-coco-panoptic) | panoptic |
|
| 64 |
+
| `mask2former-swin-tiny-ade-semantic` | [`kerasformers/mask2former-swin-tiny-ade-semantic`](https://huggingface.co/kerasformers/mask2former-swin-tiny-ade-semantic) | semantic |
|
| 65 |
+
|
| 66 |
+
## Tips
|
| 67 |
+
|
| 68 |
+
- Set `KERAS_BACKEND` **before** importing Keras / kerasformers.
|
| 69 |
+
- The task suffix is what the checkpoint was trained for; post-process accordingly.
|
| 70 |
+
- See [Mask2Former docs]({DOCS_URL}) and [Loading Weights](https://imvision12.github.io/KerasFormers/loading_weights/).
|
| 71 |
+
- Community / upstream weights: `Mask2FormerUniversalSegment.from_weights("hf:facebook/mask2former-swin-tiny-coco-instance")`.
|
| 72 |
+
|
| 73 |
+
## Special Thanks
|
| 74 |
+
|
| 75 |
+
A huge thank you to the Facebook AI Research Mask2Former authors for creating and releasing these models.
|
| 76 |
+
|
| 77 |
+
License: MIT.
|