File size: 4,363 Bytes
35c1d4f 3850765 35c1d4f 8580335 efb1dd9 8e227d7 efb1dd9 8e227d7 efb1dd9 8e227d7 efb1dd9 e550739 8580335 efb1dd9 e550739 efb1dd9 e550739 efb1dd9 e550739 efb1dd9 e550739 efb1dd9 e550739 3850765 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
---
library_name: keras-hub
license: apache-2.0
tags:
- image-segmentation
---
## Model Overview
DeepLabv3+ model is developed by Google for semantic segmentation. This guide demonstrates how to finetune and use DeepLabv3+ model for image semantic segmentaion with KerasCV. Its architecture that combines atrous convolutions, contextual information aggregation, and powerful backbones to achieve accurate and detailed semantic segmentation. The DeepLabv3+ model has been shown to achieve state-of-the-art results on a variety of image segmentation benchmarks. This model is supported in both KerasCV and KerasHub. KerasCV will no longer be actively developed, so please try to use KerasHub.
`
Weights are released under the [Apache 2 License](https://apache.org/licenses/LICENSE-2.0). Keras model code is released under the [Apache 2 License](https://github.com/keras-team/keras-hub/blob/master/LICENSE).
## Links
* [DeepLabV3Plus Quickstart Notebook](https://www.kaggle.com/code/prasadsachin/deeplabv3plus-quickstart)
* [DeepLabV3Plus Finetune Notebook](https://www.kaggle.com/code/prasadsachin/deeplabv3plus-finetune-notebook/)
* [DeepLabV3Plus API Documentation](https://keras.io/api/keras_hub/models/deeplab_v3/)
## Installation
Keras and KerasHub can be installed with:
```
pip install -U -q keras-hub
pip install -U -q keras
```
Jax, TensorFlow, and Torch come preinstalled in Kaggle Notebooks. For instructions on installing them in another environment see the [Keras Getting Started](https://keras.io/getting_started/) page.
## Presets
The following model checkpoints are provided by the Keras team. Full code examples for each are available below.
| Preset name | Parameters | Description |
|------------------------------------|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| deeplab_v3_plus_resnet50_pascalvoc | 39.1M | DeeplabV3Plus with a ResNet50 v2 backbone. Trained on PascalVOC 2012 Semantic segmentation task, which consists of 20 classes and one background class. This model achieves a final categorical accuracy of 89.34% and mIoU of 0.6391 on evaluation dataset. This preset is only comptabile with Keras 3. |
## Model card
https://arxiv.org/abs/1802.02611
## Example Usage
Load DeepLabv3+ presets a extension of DeepLabv3 by adding a simple yet
effective decoder module to refine the segmentation results especially
along object boundaries.
```python
images = np.ones(shape=(1, 96, 96, 3))
labels = np.zeros(shape=(1, 96, 96, 2))
segmenter = keras_hub.models.DeepLabV3ImageSegmenter.from_preset(
"deeplab_v3_plus_resnet50_pascalvoc",
)
segmenter.predict(images)
```
Specify `num_classes` to load randomly initialized segmentation head.
```python
segmenter = keras_hub.models.DeepLabV3ImageSegmenter.from_preset(
"deeplab_v3_plus_resnet50_pascalvoc",
num_classes=2,
)
segmenter.preprocessor.image_size = (96, 96)
segmenter.fit(images, labels, epochs=3)
segmenter.predict(images) # Trained 2 class segmentation.
```
## Example Usage with Hugging Face URI
Load DeepLabv3+ presets a extension of DeepLabv3 by adding a simple yet
effective decoder module to refine the segmentation results especially
along object boundaries.
```python
images = np.ones(shape=(1, 96, 96, 3))
labels = np.zeros(shape=(1, 96, 96, 2))
segmenter = keras_hub.models.DeepLabV3ImageSegmenter.from_preset(
"hf://keras/deeplab_v3_plus_resnet50_pascalvoc",
)
segmenter.predict(images)
```
Specify `num_classes` to load randomly initialized segmentation head.
```python
segmenter = keras_hub.models.DeepLabV3ImageSegmenter.from_preset(
"hf://keras/deeplab_v3_plus_resnet50_pascalvoc",
num_classes=2,
)
segmenter.preprocessor.image_size = (96, 96)
segmenter.fit(images, labels, epochs=3)
segmenter.predict(images) # Trained 2 class segmentation.
``` |