timothybrooks / hdr-plus

HDR+ Implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Convert Code to python?

Titaniumtown opened this issue · comments

I was thinking about possibly converting the code to python. Does anyone have any idea of how one could do that?

Python is not well suited for this workload. I do not recommend doing this. Image processing pipelines are very computationally expensive, since images are large (~22 million pixels for a 5D III) and there are many stages of processing with many operations for each pixel. A naive implementation of this pipeline would take hours to run. To make the performance reasonable, I implemented the pipeline in Halide, the same language used in the original HDR+ paper, which provides a simple abstraction for writing highly optimized code that exploits parallelism, vectorization, tiling, unrolling, etc.

This level of optimization is not feasible in Python. If you would like to try using Python for an implementation of HDR+, I recommend trying your best to leverage vectorized NumPy operations, and doing it in a new repository rather than converting this one.

If you have difficulty maintaining the code written in Halide, there are some tutorials on halide-lang.org which may be useful. I can answer some questions, and it may be worthwhile finding more collaborators on the project who are experienced with C++ and/or Halide.

Also, if you would simply like to call the full pipeline from within Python, you can run the binary using Python's subprocess module.

I think that @Titaniumtown is referring to use of the wrapper of python for Halide provide for Halide project.

https://github.com/halide/Halide/tree/master/python_bindings

In my humble opinion, the use of python in this project does not represent an improvement to get an open source implementation of HDRp.

@timothybrooks thank for your code !!!

If anyone is still interested, I implemented the alignment part in PyTorch. It runs at ~100 ms / image on a GPU.

https://github.com/martin-marek/hdr-plus-pytorch