Doodleverse / doodleverse_utils

A set of common Doodleverse tools and utilities
MIT License
4 stars 3 forks source link

make inference faster, and add more specificity to `do_seg` wrt inputs and outputs #27

Closed dbuscombe-usgs closed 9 months ago

dbuscombe-usgs commented 1 year ago
  1. Inference is slow. How do we speed it up?
  2. add functionality to control which outputs are created
ebgoldstein commented 1 year ago

Has anybody profiled the code to see what step is the longest in the inference code? (i.e., via cPython or the even the tensorflow profiler?) I have not done it, but i presume its just the actual model.predict call? And do we have an understanding of model.predict speed on GPU vs CPU?

dbuscombe-usgs commented 1 year ago

In many of my applications, a single model.predict is a small fraction of the total time. I use several other function calls to prepare inputs and outputs. I also tend to call the model several times for the same image. Writing outputs to file often takes longer than creating them. So, parallelizing the model inference makes sense anyway

According to the docs, model(x) should be quicker than model.predict(x) on a single input

It would be really nice to not have to rely on GPU, which will be out of reach for a lot of users and hinder cloud deployments

dbuscombe-usgs commented 1 year ago

I added a small change to enable the option to use model in parallel using joblib using gym, zoo, etc.

https://github.com/Doodleverse/doodleverse_utils/blob/0999c404f43f461001f700390d2e3ce5d691a6ca/doodleverse_utils/prediction_imports.py#L133

https://github.com/Doodleverse/doodleverse_utils/commit/0999c404f43f461001f700390d2e3ce5d691a6ca

dbuscombe-usgs commented 9 months ago

Superseded by https://github.com/Doodleverse/doodleverse_utils/issues/31