Use PixelLib to extract objects in images and videos with 5 lines of code
Use PixelLib to extract objects in images and videos with 5 Lines of code
For example, first do the following:
pip3 install pixellib
Then run the following Python code:
import pixellib
from pixellib.instance import instance_segmentation
segment_image=instance_segmentation()
segment_image.load_model("mask_rcnn_coco.h5")
segment_image.segmentImage("input.jpg", extract_segmented_objects=True,save_extracted_objects=True, show_bboxes=True, output_image_name="output.jpg")
NOTE:
1. You can get the model "mask_rcnn_coco.h5" by using the "wget" command: wget https://github.com/ayoolaolafenwa/PixelLib/releases/download/1.2/mask_rcnn_coco.h5
2. "input.jpg" is an input image
3. "output.jpg" is the input image with the objects marked
"ouptut.jpg" will then contain:
Photo by Han Le on Unsplash
PixelLib Extracts Objects In Images and Videos with 5 Lines of Code
Towards Data Science https://towardsdatascience.com/extraction-of-objects-in-images-and-videos-using-5-lines-of-code-6a9e35677a31
PixelLib PyPI registry https://pypi.org/project/pixellib
PixelLib GitHub https://github.com/ayoolaolafenwa/PixelLib
PixelLib documentation https://pixellib.readthedocs.io/en/latest
Please like and share this post if you enjoyed it using the buttons at the bottom!
Stay up to date. Subscribe to my posts https://morrislee1234.wixsite.com/website/contact
Web site with my other posts by category https://morrislee1234.wixsite.com/website
Comentarios