IMvision12 commited on
Commit
10f7a76
·
verified ·
1 Parent(s): a09b2bb

Migrate to zeromodels (rename kf_*.json -> zm_*.json, fix refs in config + README, ensure tag + badge)

Browse files
README.md CHANGED
@@ -2,10 +2,10 @@
2
  pipeline_tag: image-segmentation
3
  license: mit
4
  base_model: facebook/mask2former-swin-small-coco-instance
5
- library_name: kerasformers
6
  tags:
7
  - keras
8
- - kerasformers
9
  - mask2former
10
  - instance-segmentation
11
  - image-segmentation
@@ -15,13 +15,13 @@ tags:
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
- [![GitHub](https://img.shields.io/badge/GitHub-KerasFormers-black?logo=github)](https://github.com/IMvision12/KerasFormers) [![Docs](https://img.shields.io/badge/Docs-Mask2Former-blue)](https://imvision12.github.io/KerasFormers/mask2former/) [![Collection](https://img.shields.io/badge/HF-Mask2Former%20collection-yellow)](https://huggingface.co/collections/kerasformers/mask2former-6a6a8f4248526cc9a74b9b97)
23
 
24
- # kerasformers/mask2former-swin-small-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
 
@@ -29,7 +29,7 @@ Mask2Former improves MaskFormer with masked attention in the transformer decoder
29
 
30
  For more details on the model, please go to the upstream [model card](https://huggingface.co/facebook/mask2former-swin-small-coco-instance).
31
 
32
- Pure-**Keras 3** conversion of [`facebook/mask2former-swin-small-coco-instance`](https://huggingface.co/facebook/mask2former-swin-small-coco-instance) for [kerasformers](https://github.com/IMvision12/KerasFormers). One implementation runs unmodified on **TensorFlow / Torch / JAX**.
33
 
34
  This is a **instance** checkpoint (`Mask2FormerUniversalSegment`) (trained for instance; architecture is universal).
35
 
@@ -40,10 +40,10 @@ import os
40
  os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
41
 
42
  from PIL import Image
43
- from kerasformers.models.mask2former import Mask2FormerUniversalSegment, Mask2FormerImageProcessor
44
 
45
- model = Mask2FormerUniversalSegment.from_weights("kerasformers/mask2former-swin-small-coco-instance")
46
- processor = Mask2FormerImageProcessor.from_weights("kerasformers/mask2former-swin-small-coco-instance")
47
 
48
  image = Image.open("your_image.jpg").convert("RGB")
49
  output = model(processor(image)["pixel_values"], training=False)
@@ -53,22 +53,22 @@ result = processor.post_process_panoptic_segmentation(
53
  print(result["segmentation"].shape)
54
  ```
55
 
56
- Load any Mask2Former variant the same way with `from_weights("kerasformers/<variant>")`:
57
 
58
  | Variant | Hub | Task |
59
  |---|---|---|
60
- | `mask2former-swin-tiny-coco-instance` | [`kerasformers/mask2former-swin-tiny-coco-instance`](https://huggingface.co/kerasformers/mask2former-swin-tiny-coco-instance) | instance |
61
- | `mask2former-swin-small-coco-instance` | [`kerasformers/mask2former-swin-small-coco-instance`](https://huggingface.co/kerasformers/mask2former-swin-small-coco-instance) | instance |
62
- | `mask2former-swin-base-coco-instance` | [`kerasformers/mask2former-swin-base-coco-instance`](https://huggingface.co/kerasformers/mask2former-swin-base-coco-instance) | instance |
63
- | `mask2former-swin-large-coco-instance` | [`kerasformers/mask2former-swin-large-coco-instance`](https://huggingface.co/kerasformers/mask2former-swin-large-coco-instance) | instance |
64
- | `mask2former-swin-tiny-coco-panoptic` | [`kerasformers/mask2former-swin-tiny-coco-panoptic`](https://huggingface.co/kerasformers/mask2former-swin-tiny-coco-panoptic) | panoptic |
65
- | `mask2former-swin-tiny-ade-semantic` | [`kerasformers/mask2former-swin-tiny-ade-semantic`](https://huggingface.co/kerasformers/mask2former-swin-tiny-ade-semantic) | semantic |
66
 
67
  ## Tips
68
 
69
- - Set `KERAS_BACKEND` **before** importing Keras / kerasformers.
70
  - The task suffix is what the checkpoint was trained for; post-process accordingly.
71
- - See [Mask2Former docs]({DOCS_URL}) and [Loading Weights](https://imvision12.github.io/KerasFormers/loading_weights/).
72
  - Community / upstream weights: `Mask2FormerUniversalSegment.from_weights("hf:facebook/mask2former-swin-small-coco-instance")`.
73
 
74
  ## Special Thanks
 
2
  pipeline_tag: image-segmentation
3
  license: mit
4
  base_model: facebook/mask2former-swin-small-coco-instance
5
+ library_name: zeromodels
6
  tags:
7
  - keras
8
+ - zeromodels
9
  - mask2former
10
  - instance-segmentation
11
  - image-segmentation
 
15
  - tf
16
  ---
17
 
18
+ ## ***See [our collection](https://huggingface.co/collections/zeromodels/mask2former-6a6a8f4248526cc9a74b9b97) for all versions of Mask2Former.***
19
 
20
  # Run Mask2Former with Keras 3: JAX, PyTorch, or TensorFlow
21
 
22
+ [![GitHub](https://img.shields.io/badge/GitHub-ZeroModels-black?logo=github)](https://github.com/IMvision12/ZeroModels) [![Docs](https://img.shields.io/badge/Docs-Mask2Former-blue)](https://imvision12.github.io/ZeroModels/mask2former/) [![Collection](https://img.shields.io/badge/HF-Mask2Former%20collection-yellow)](https://huggingface.co/collections/zeromodels/mask2former-6a6a8f4248526cc9a74b9b97)
23
 
24
+ # zeromodels/mask2former-swin-small-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
 
 
29
 
30
  For more details on the model, please go to the upstream [model card](https://huggingface.co/facebook/mask2former-swin-small-coco-instance).
31
 
32
+ Pure-**Keras 3** conversion of [`facebook/mask2former-swin-small-coco-instance`](https://huggingface.co/facebook/mask2former-swin-small-coco-instance) for [zeromodels](https://github.com/IMvision12/ZeroModels). One implementation runs unmodified on **TensorFlow / Torch / JAX**.
33
 
34
  This is a **instance** checkpoint (`Mask2FormerUniversalSegment`) (trained for instance; architecture is universal).
35
 
 
40
  os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
41
 
42
  from PIL import Image
43
+ from zeromodels.models.mask2former import Mask2FormerUniversalSegment, Mask2FormerImageProcessor
44
 
45
+ model = Mask2FormerUniversalSegment.from_weights("zeromodels/mask2former-swin-small-coco-instance")
46
+ processor = Mask2FormerImageProcessor.from_weights("zeromodels/mask2former-swin-small-coco-instance")
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 Mask2Former variant the same way with `from_weights("zeromodels/<variant>")`:
57
 
58
  | Variant | Hub | Task |
59
  |---|---|---|
60
+ | `mask2former-swin-tiny-coco-instance` | [`zeromodels/mask2former-swin-tiny-coco-instance`](https://huggingface.co/zeromodels/mask2former-swin-tiny-coco-instance) | instance |
61
+ | `mask2former-swin-small-coco-instance` | [`zeromodels/mask2former-swin-small-coco-instance`](https://huggingface.co/zeromodels/mask2former-swin-small-coco-instance) | instance |
62
+ | `mask2former-swin-base-coco-instance` | [`zeromodels/mask2former-swin-base-coco-instance`](https://huggingface.co/zeromodels/mask2former-swin-base-coco-instance) | instance |
63
+ | `mask2former-swin-large-coco-instance` | [`zeromodels/mask2former-swin-large-coco-instance`](https://huggingface.co/zeromodels/mask2former-swin-large-coco-instance) | instance |
64
+ | `mask2former-swin-tiny-coco-panoptic` | [`zeromodels/mask2former-swin-tiny-coco-panoptic`](https://huggingface.co/zeromodels/mask2former-swin-tiny-coco-panoptic) | panoptic |
65
+ | `mask2former-swin-tiny-ade-semantic` | [`zeromodels/mask2former-swin-tiny-ade-semantic`](https://huggingface.co/zeromodels/mask2former-swin-tiny-ade-semantic) | semantic |
66
 
67
  ## Tips
68
 
69
+ - Set `KERAS_BACKEND` **before** importing Keras / zeromodels.
70
  - The task suffix is what the checkpoint was trained for; post-process accordingly.
71
+ - See [Mask2Former docs]({DOCS_URL}) and [Loading Weights](https://imvision12.github.io/ZeroModels/loading_weights/).
72
  - Community / upstream weights: `Mask2FormerUniversalSegment.from_weights("hf:facebook/mask2former-swin-small-coco-instance")`.
73
 
74
  ## Special Thanks
kf_config.json → zm_config.json RENAMED
@@ -1,37 +1,37 @@
1
- {
2
- "library_name": "kerasformers",
3
- "kerasformers_version": "1.2.1",
4
- "model_module": "kerasformers.models.mask2former",
5
- "model_class": "Mask2FormerUniversalSegment",
6
- "variant": "mask2former-swin-small-coco-instance",
7
- "weights": "model.weights.h5",
8
- "schema_version": 2,
9
- "weight_dtype": "float32",
10
- "model_type": "mask2former",
11
- "vision_config": {
12
- "backbone_embed_dim": 96,
13
- "backbone_depths": [
14
- 2,
15
- 2,
16
- 18,
17
- 2
18
- ],
19
- "backbone_num_heads": [
20
- 3,
21
- 6,
22
- 12,
23
- 24
24
- ],
25
- "backbone_window_size": 7,
26
- "hidden_dim": 256,
27
- "mask_feature_size": 256,
28
- "encoder_num_layers": 6,
29
- "encoder_ffn_dim": 1024,
30
- "decoder_num_layers": 9,
31
- "decoder_ffn_dim": 2048,
32
- "num_heads": 8,
33
- "num_queries": 100,
34
- "num_classes": 80,
35
- "image_size": 384
36
- }
37
  }
 
1
+ {
2
+ "library_name": "zeromodels",
3
+ "zeromodels_version": "1.2.1",
4
+ "model_module": "zeromodels.models.mask2former",
5
+ "model_class": "Mask2FormerUniversalSegment",
6
+ "variant": "mask2former-swin-small-coco-instance",
7
+ "weights": "model.weights.h5",
8
+ "schema_version": 2,
9
+ "weight_dtype": "float32",
10
+ "model_type": "mask2former",
11
+ "vision_config": {
12
+ "backbone_embed_dim": 96,
13
+ "backbone_depths": [
14
+ 2,
15
+ 2,
16
+ 18,
17
+ 2
18
+ ],
19
+ "backbone_num_heads": [
20
+ 3,
21
+ 6,
22
+ 12,
23
+ 24
24
+ ],
25
+ "backbone_window_size": 7,
26
+ "hidden_dim": 256,
27
+ "mask_feature_size": 256,
28
+ "encoder_num_layers": 6,
29
+ "encoder_ffn_dim": 1024,
30
+ "decoder_num_layers": 9,
31
+ "decoder_ffn_dim": 2048,
32
+ "num_heads": 8,
33
+ "num_queries": 100,
34
+ "num_classes": 80,
35
+ "image_size": 384
36
+ }
37
  }
kf_preprocessor.json → zm_preprocessor.json RENAMED
@@ -1,19 +1,19 @@
1
- {
2
- "library_name": "kerasformers",
3
- "kerasformers_version": "1.1.3",
4
- "preprocessor_module": "kerasformers.models.mask2former",
5
- "preprocessor_class": "Mask2FormerImageProcessor",
6
- "variant": "mask2former-swin-small-coco-instance",
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.mask2former",
5
+ "preprocessor_class": "Mask2FormerImageProcessor",
6
+ "variant": "mask2former-swin-small-coco-instance",
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
  }