--- library_name: keras-hub license: apache-2.0 tags: - image-segmentation pipeline_tag: 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. ```