IMvision12 commited on
Commit
6a40033
·
verified ·
1 Parent(s): aaf57aa

fix readme.md

Browse files
Files changed (1) hide show
  1. README.md +68 -6
README.md CHANGED
@@ -1,21 +1,83 @@
1
  ---
2
  pipeline_tag: image-segmentation
3
  license: apple-amlr
 
4
  library_name: kerasformers
5
  tags:
6
  - keras
7
  - kerasformers
8
  - mobilevit
9
- - tf
10
- - jax
 
 
 
11
  - pytorch
 
 
12
  ---
13
 
14
- # mobilevit_s_deeplabv3 (Keras 3)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
- Pure-Keras 3 weights for [kerasformers](https://github.com/IMvision12/KerasFormers), mirrored from the source. License: `apple-amlr`.
 
 
17
 
18
  ```python
19
- from kerasformers.models.mobilevit import MobileViTSemanticSegment
20
- model = MobileViTSemanticSegment.from_weights("mobilevit_s_deeplabv3")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  pipeline_tag: image-segmentation
3
  license: apple-amlr
4
+ base_model: apple/deeplabv3-mobilevit-small
5
  library_name: kerasformers
6
  tags:
7
  - keras
8
  - kerasformers
9
  - mobilevit
10
+ - deeplabv3
11
+ - image-segmentation
12
+ - semantic-segmentation
13
+ - arxiv:2110.02178
14
+ - arxiv:2206.02680
15
  - pytorch
16
+ - jax
17
+ - tf
18
  ---
19
 
20
+ ## ***See [our collection](https://huggingface.co/collections/kerasformers/mobilevit-v1-and-v2-6a6a900d3e9e4847e4242a72) for MobileViT / MobileViTV2 DeepLabV3 segmentation.***
21
+
22
+ # Run MobileViT DeepLabV3 with Keras 3: JAX, PyTorch, or TensorFlow
23
+
24
+ [![GitHub](https://img.shields.io/badge/GitHub-KerasFormers-black?logo=github)](https://github.com/IMvision12/KerasFormers) [![Docs](https://img.shields.io/badge/Docs-MobileViT%20DeepLabV3-blue)](https://imvision12.github.io/KerasFormers/mobilevit/) [![Collection](https://img.shields.io/badge/HF-MobileViT%20seg%20collection-yellow)](https://huggingface.co/collections/kerasformers/mobilevit-v1-and-v2-6a6a900d3e9e4847e4242a72)
25
+
26
+ # kerasformers/mobilevit_s_deeplabv3
27
+
28
+ Papers: [MobileViT (arXiv:{PAPER_ARXIV})]({PAPER_URL}) · [MobileViTV2 (arXiv:2206.02680)](https://arxiv.org/abs/2206.02680) · [HF Papers](https://huggingface.co/papers/2110.02178)
29
+
30
+ MobileViT backbone + **DeepLabV3 ASPP** head for Pascal VOC semantic segmentation (21 classes). **Resolution is 512**, not the 256 used by ImageNet classification checkpoints. Always load the processor with `from_weights` so resize/crop match.
31
+
32
+ For more details on the model, please go to the upstream [model card](https://huggingface.co/apple/deeplabv3-mobilevit-small).
33
+
34
+ Pure-**Keras 3** conversion of [`apple/deeplabv3-mobilevit-small`](https://huggingface.co/apple/deeplabv3-mobilevit-small) for [kerasformers](https://github.com/IMvision12/KerasFormers). One implementation runs unmodified on **TensorFlow / Torch / JAX**.
35
 
36
+ This is a **semantic segmentation** checkpoint (`MobileViTSemanticSegment`).
37
+
38
+ ## ✨ Quick start
39
 
40
  ```python
41
+ import os
42
+ os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
43
+
44
+ from PIL import Image
45
+ from kerasformers.models.mobilevit import (
46
+ MobileViTSemanticSegment,
47
+ MobileViTImageProcessor,
48
+ )
49
+
50
+ model = MobileViTSemanticSegment.from_weights("kerasformers/mobilevit_s_deeplabv3")
51
+ processor = MobileViTImageProcessor.from_weights("kerasformers/mobilevit_s_deeplabv3")
52
+
53
+ image = Image.open("your_image.jpg").convert("RGB")
54
+ output = model(processor(image)["pixel_values"], training=False)
55
+ result = processor.post_process_semantic_segmentation(
56
+ output, target_size=(image.height, image.width)
57
+ )
58
+ print(result["segmentation"].shape) # (H, W) class ids
59
  ```
60
+
61
+ Load any DeepLabV3 MobileViT variant the same way with `from_weights("kerasformers/<variant>")`:
62
+
63
+ | Variant | Hub | Family |
64
+ |---|---|---|
65
+ | `mobilevit_xxs_deeplabv3` | [`kerasformers/mobilevit_xxs_deeplabv3`](https://huggingface.co/kerasformers/mobilevit_xxs_deeplabv3) | MobileViT v1 |
66
+ | `mobilevit_xs_deeplabv3` | [`kerasformers/mobilevit_xs_deeplabv3`](https://huggingface.co/kerasformers/mobilevit_xs_deeplabv3) | MobileViT v1 |
67
+ | `mobilevit_s_deeplabv3` | [`kerasformers/mobilevit_s_deeplabv3`](https://huggingface.co/kerasformers/mobilevit_s_deeplabv3) | MobileViT v1 |
68
+ | `mobilevitv2_100_deeplabv3` | [`kerasformers/mobilevitv2_100_deeplabv3`](https://huggingface.co/kerasformers/mobilevitv2_100_deeplabv3) | MobileViT v2 |
69
+ | `mobilevitv2_150_deeplabv3` | [`kerasformers/mobilevitv2_150_deeplabv3`](https://huggingface.co/kerasformers/mobilevitv2_150_deeplabv3) | MobileViT v2 |
70
+
71
+ ## Tips
72
+
73
+ - Set `KERAS_BACKEND` **before** importing Keras / kerasformers.
74
+ - Do not reuse a classification processor: seg checkpoints need 544/512.
75
+ - v1 imports from `mobilevit`; v2 from `mobilevitv2`.
76
+ - See [docs](https://imvision12.github.io/KerasFormers/mobilevit/) and [Loading Weights](https://imvision12.github.io/KerasFormers/loading_weights/).
77
+ - Upstream: `MobileViTSemanticSegment.from_weights("hf:apple/deeplabv3-mobilevit-small")`.
78
+
79
+ ## Special Thanks
80
+
81
+ A huge thank you to the Apple MobileViT authors for creating and releasing these models.
82
+
83
+ License: see YAML / upstream card.