It is now possible to perform segmentation on 150 classes of objects using ade20k model with PixelLib. Ade20k model is a deeplabv3+ model trained on ade20k dataset, a dataset with 150 classes of objects. Thanks to tensorflow deeplab’s model zoo, I extracted ade20k model from its tensorflow model checkpoint.
Install the latest version tensorflow (tensorflow 2.0) with:
Install Pixellib:
Implementation of Semantic Segmentation with PixelLib:
The code to implement semantic segmentation with deeplabv3+ model is trained on ade20k dataset.
“”
import pixellib
from pixellib.semantic import semantic_segmentation
segment_image = semantic_segmentation()
segment_image.load_ade20k_model(“deeplabv3_xception65_ade20k.h5”)
segment_image.segmentAsAde20k(“path_to_image”, output_image_name= “path_to_output_image”)
“”
We shall observe each line of code:
import pixellib
from pixellib.semantic import semantic_segmentation segment_image = semantic_segmentation()
The class for performing semantic segmentation is imported from pixelLib and we created an instance of the class.
segment_image.load_ade20k_model(“deeplabv3_xception65_ade20k.h5”)
In the code above we loaded the xception model trained on ade20k for segmenting objects. The model can be downloaded from here.
segment_image.segmentAsAde20k(“path_to_image”, output_image_name = “path_to_output_image)
We loaded the function to perform segmentation on an image. The function takes two parameters…
#deep-learning #computer-vision #artificial-intelligence #image-segmentation #machine-learning