Holoviews: Significant performance degradation with rasterize(image) * Overlay(objects)?

Created on 14 Aug 2018  路  7Comments  路  Source: holoviz/holoviews

Wondering if this is expected given the data I'm working with.

Let's say I have a 2048x2048 image that I have localized ~150 objects in. I then go to plot this image, and because it is large, I rasterize() it with Datashader. Each object is indicated on top of this raster with an hv.Ellipse (which are compiled into an hv.Overlay).

Any sort of zooming / scrolling redraws on the raster are then immensely slowed down if I overlay the rasterized image with the ellipse overlay.

Skeleton example:

hv_ellipses = [
    hv.Ellipse(centroid[1], centroid[0], 4 * centroid[2])
    for centroid in centroids
]

rasterize(hv.Image(image, bounds=(0, 0, image.shape[1], image.shape[0])).options(
    title_format=f'Movie frame with identified objects', 
    colorbar=True
)) * hv.Overlay(hv_ellipses)

I've noted that the slowdown scales with the number of ellipses.

Do you guys think this is expected given the number of ellipses I am drawing? I just realized that in this particular case, I could just draw a scatter plot with transparent faces and circular markers, but I guess I was wondering if more in general (like if I wanted to draw many lines for object trajectories, for example) it is untenable to have many objects overlaid on top of a raster and achieve good performance on raster redraws in response to axes changes.

bug

Most helpful comment

I can reproduce a pretty large slow down caused by ranges being computed for all 150 ROIs each time, fairly inefficiently. In general it's probably a good idea to replace hv.Overlay(hv_ellipses) with hv.Path(hv_ellipses) but we should be able to achieve a major speedup using Overlays too.

All 7 comments

Do you guys think this is expected given the number of ellipses I am drawing?

Definitely not expected, static elements like this should not be redrawn so there should be no performance impact.

I can reproduce a pretty large slow down caused by ranges being computed for all 150 ROIs each time, fairly inefficiently. In general it's probably a good idea to replace hv.Overlay(hv_ellipses) with hv.Path(hv_ellipses) but we should be able to achieve a major speedup using Overlays too.

Thanks for the alternative!

Wish I'd recorded the timings here, it does seem to be somewhat faster now at least, I'm getting 0.7 seconds per update.

@philippjfr - sweet. I'll check this out soon and let you know what I see.

Actually getting 420 ms with the latest minor optimization.

The main recommendation here is still to combine all the polygons into a single element but the overlay based approach is now also much faster so I'll close this.

Was this page helpful?
0 / 5 - 0 ratings