Skip to content

Instantly share code, notes, and snippets.

@jagin
Last active October 21, 2019 13:49
Show Gist options
  • Save jagin/461e68861b091721b90e82c1c0e56da3 to your computer and use it in GitHub Desktop.
Save jagin/461e68861b091721b90e82c1c0e56da3 to your computer and use it in GitHub Desktop.
import cv2
from pipeline.pipeline import Pipeline
import pipeline.utils as utils
class LoadImages(Pipeline):
def __init__(self, src, valid_exts=(".jpg", ".png")):
self.src = src
self.valid_exts = valid_exts
super(LoadImages, self).__init__()
def generator(self):
source = utils.list_images(self.src, self.valid_exts)
while self.has_next():
image_file = next(source)
image = cv2.imread(image_file)
data = {
"image_file": image_file,
"image": image
}
if self.filter(data):
yield self.map(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment