timothybrooks / hdr-plus

HDR+ Implementation
MIT License
594 stars 201 forks source link

Convert Code to python? #41

Closed Titaniumtown closed 5 years ago

Titaniumtown commented 5 years ago

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

timothybrooks commented 5 years ago

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.

timothybrooks commented 5 years ago

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

pedrodiamel commented 5 years ago

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 !!!

martin-marek commented 3 years ago

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