qubvel / segmentation_models

Segmentation models with pretrained backbones. Keras and TensorFlow Keras.
MIT License
4.77k stars 1.03k forks source link

batch size when predicting #572

Open vuhungtvt2018 opened 1 year ago

vuhungtvt2018 commented 1 year ago

how can I apply batch size when predicting multible image plsease help me! thanks!

tshr-d-dragon commented 1 year ago

@vuhungtvt142 you can try this code snippet:

from glob import glob
import numpy as np
import cv2

images_paths = glob("/*")
images_array = []

for image_path in images_paths:
    image = cv2.imread(image_path)[:,:,::-1]
    images.append(image)

images_array = np.asarray(images_array).reshape(len(images_paths), H, W, N_CHANNELS)

predictions = model.predict(images_array)

Please let me know if this works! Also, close the issue if this solves the problem!!!:)