github.com/pachyderm/pachyderm@v1.13.4/examples/opencv/edges.py (about) 1 import cv2 2 import numpy as np 3 from matplotlib import pyplot as plt 4 import os 5 6 # make_edges reads an image from /pfs/images and outputs the result of running 7 # edge detection on that image to /pfs/out. Note that /pfs/images and 8 # /pfs/out are special directories that Pachyderm injects into the container. 9 def make_edges(image): 10 img = cv2.imread(image) 11 tail = os.path.split(image)[1] 12 edges = cv2.Canny(img,100,200) 13 plt.imsave(os.path.join("/pfs/out", os.path.splitext(tail)[0]+'.png'), edges, cmap = 'gray') 14 15 # walk /pfs/images and call make_edges on every file found 16 for dirpath, dirs, files in os.walk("/pfs/images"): 17 for file in files: 18 make_edges(os.path.join(dirpath, file))