-
Hmm … it seems the error is not
dask
-related, so I can’t be sure from here what is causing it. Corrupted video file perhaps? -
Correction: once you call
compute()
dask
will execute the task-graph, not generate it. A task-graph is built any time you call adask
function likemap_blocks()
orimread()
. -
Since the chunksize (number of images in a chunk) has been changed to
100
, you must be aware thatmake_hogs()
receives a chunk of 100 images at once as input. So you probably should loophog()
over all those images and stack-up all the processed images, sincehog()
is unable to process more than one image at a time (right?). Alternatively, you could rewritehog()
's source code to do that (without looping), like I did forpims.as_grey()
. In fact, I encourage you to try that and see if it boosts performance. In the meantime, here’s an untested code snippet:
def make_hogs(frames, coords):
new_frames = frames[
:,
coords[1]:coords[1] + coords[3],
coords[0]:coords[1] + coords[2],
]
nframes = new_frames.shape[0]
first_frame = new_frames[0]
hog_descriptor, hog_image = hog(first_frame)
hog_images = np.empty((nframes,) + hog_image.shape, dtype=frames.dtype)
hog_descriptors = np.empty((nframes,) + hog_descriptor.shape, dtype=frames.dtype)
for i, image in enumerate(new_frames):
hog_descriptor, hog_image = hog(image)
hog_descriptors[i, ...] = hog_descriptor
hog_images[i, ...] = hog_image
return hog_descriptors, hog_images
I do not know exactly what hog()
does. I’ve simply assumed above that it returns a tuple of two arrays whose sizes remain constant over all the images in the chunk.
- See this link for help on how to return more than one output.