-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to implement batch predict? #61
Comments
@fanweiya you will create a folder and put the images inside the folder. Perform batch prediction with this modified code. import pixellib
from pixellib.instance import instance_segmentation
import cv2
#import glob to use it to retrieve image names
import glob
seg = instance_segmentation()
seg.load_model("mask_rcnn_coco.h5")
#get image names with glob
imgnames = sorted(glob.glob("pics/*.jpg"))
#loop through each image in the folder
for imgname in imgnames:
#process images
#segment each image consecutively through the loop
segvalues, output = seg.segmentImage(imgname)
# save output images
#get image name with the corresponding extension and save them
#image saved like sample_output.jpg
name, ext = os.path.splitext(imgname)
imgname2 = imgname+"_output"+ext
cv2.imwrite(imgname2, output) Note You did not specify whether you want to batch predict in instance segmentation or semantic segmentation, but the code for iterating through the folder of images is still the same for both, except you will replace the code for instance segmentation for semantic segmentation for performing batch prediction in semantic segmentation. |
@ayoolaolafenwa I want to predict more than one image at a time,something like Keras model.predict_on_batch.
|
@fanweiya this is presently the way to predict multiple images with pixellib and in the nearest future I may introduce a batch prediction function. |
Hi Ayoola, many thanks for creating this library.How do I implement batch predict?How can this library process hundreds of images at once?
The text was updated successfully, but these errors were encountered: