IMvision12 commited on
Commit
9f0f37d
·
verified ·
1 Parent(s): 0ac6913

fix readme.md

Browse files
Files changed (1) hide show
  1. README.md +61 -6
README.md CHANGED
@@ -1,21 +1,76 @@
1
  ---
2
  pipeline_tag: image-segmentation
3
  license: cc-by-nc-4.0
 
4
  library_name: kerasformers
5
  tags:
6
  - keras
7
  - kerasformers
8
  - maskformer
9
- - tf
10
- - jax
 
11
  - pytorch
 
 
12
  ---
13
 
14
- # maskformer-swin-tiny-coco (Keras 3)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
- Pure-Keras 3 weights for [kerasformers](https://github.com/IMvision12/KerasFormers), mirrored from the source. License: `cc-by-nc-4.0`.
17
 
18
  ```python
19
- from kerasformers.models.maskformer import MaskFormerUniversalSegment
20
- model = MaskFormerUniversalSegment.from_weights("maskformer-swin-tiny-coco")
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  pipeline_tag: image-segmentation
3
  license: cc-by-nc-4.0
4
+ base_model: facebook/maskformer-swin-tiny-coco
5
  library_name: kerasformers
6
  tags:
7
  - keras
8
  - kerasformers
9
  - maskformer
10
+ - universal-segmentation
11
+ - image-segmentation
12
+ - arxiv:2107.06278
13
  - pytorch
14
+ - jax
15
+ - tf
16
  ---
17
 
18
+ ## ***See [our collection](https://huggingface.co/collections/kerasformers/maskformer-6a6a8ece1c77558c676dfb9d) for all versions of MaskFormer.***
19
+
20
+ # Run MaskFormer 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-MaskFormer-blue)](https://imvision12.github.io/KerasFormers/maskformer/) [![Collection](https://img.shields.io/badge/HF-MaskFormer%20collection-yellow)](https://huggingface.co/collections/kerasformers/maskformer-6a6a8ece1c77558c676dfb9d)
23
+
24
+ # kerasformers/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
+
28
+ MaskFormer reframes segmentation as mask classification: a backbone and pixel decoder feed a transformer decoder whose queries each predict a binary mask and a class. One architecture covers semantic, instance, and panoptic outputs via post-processing.\n
29
+ For more details on the model, please go to the upstream [model card](https://huggingface.co/facebook/maskformer-swin-tiny-coco).
30
+
31
+ Pure-**Keras 3** conversion of [`facebook/maskformer-swin-tiny-coco`](https://huggingface.co/facebook/maskformer-swin-tiny-coco) for [kerasformers](https://github.com/IMvision12/KerasFormers). One implementation runs unmodified on **TensorFlow / Torch / JAX**.
32
+
33
+ This is a **universal segmentation** checkpoint (`MaskFormerUniversalSegment`) trained on COCO panoptic.
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"]}.from_weights("kerasformers/{variant}")
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 MaskFormer variant the same way with `from_weights("kerasformers/<variant>")`:
56
+
57
+ | Variant | Hub | Dataset |
58
+ |---|---|---|
59
+ | `maskformer-swin-tiny-coco` | [`kerasformers/maskformer-swin-tiny-coco`](https://huggingface.co/kerasformers/maskformer-swin-tiny-coco) | COCO |
60
+ | `maskformer-swin-small-coco` | [`kerasformers/maskformer-swin-small-coco`](https://huggingface.co/kerasformers/maskformer-swin-small-coco) | COCO |
61
+ | `maskformer-swin-base-coco` | [`kerasformers/maskformer-swin-base-coco`](https://huggingface.co/kerasformers/maskformer-swin-base-coco) | COCO |
62
+ | `maskformer-swin-tiny-ade` | [`kerasformers/maskformer-swin-tiny-ade`](https://huggingface.co/kerasformers/maskformer-swin-tiny-ade) | ADE20K |
63
+ | `maskformer-swin-base-ade` | [`kerasformers/maskformer-swin-base-ade`](https://huggingface.co/kerasformers/maskformer-swin-base-ade) | ADE20K |
64
+
65
+ ## Tips
66
+
67
+ - Set `KERAS_BACKEND` **before** importing Keras / kerasformers.
68
+ - Prefer `MaskFormerImageProcessor.from_weights(...)` so resolution matches the variant.
69
+ - See [MaskFormer docs]({DOCS_URL}) and [Loading Weights](https://imvision12.github.io/KerasFormers/loading_weights/).
70
+ - Community / upstream weights: `MaskFormerUniversalSegment.from_weights("hf:facebook/maskformer-swin-tiny-coco")`.
71
+
72
+ ## Special Thanks
73
+
74
+ A huge thank you to the Facebook AI Research MaskFormer authors for creating and releasing these models.
75
+
76
+ License: CC-BY-NC-4.0 (non-commercial).