ComputationalRadiationPhysics / student_project_python_bindings

The student project investigates the performance and memory handling of Python bindings for CUDA C++ code created with pybind11.
GNU General Public License v3.0
1 stars 0 forks source link

Test stability of the reconstruction #3

Closed SimeonEhrig closed 3 years ago

SimeonEhrig commented 3 years ago

I saw some strange behavior when running the CUDA implementation on image a.png. The object itself was good reconstructed but the orientation or if it was mirrored was constantly changing with each execution.

Please write a helper script that allows to run the Python and CUDA implementation of the algorithm n times on an image. The results should be written to files. This is to verify that the algorithm is generally stable. The possible parameters of the script should be: path to the image file, number of iterations of the whole algorithm, number of iterations within the algorithm.

I would suggest argparse to handle the arguments in the helper script.

For this issue, issue #1 and #2 should be solved before.

afif-ishamsyah commented 3 years ago

what is the best way to write the arrays into images in C++ that works on both linux and windows?

SimeonEhrig commented 3 years ago

I would suggest, you solve at first issue #1 With this knowledge, you can safe use the Python library to generate the image. But if you really want to use a C++ solution, I would suggest pngwriter.

afif-ishamsyah commented 3 years ago

So issue #1 is still unsolved?

SimeonEhrig commented 3 years ago

I didn't saw your last commit. GitHub does not notify me, if you do a simple commit. Please write a comment in the related issue (in the best case with linkage to the commit, code line or so one) if your are finish and I should review.

I think in the next VC, we change the your workflow to a Pull Request approach. That's makes much easier for me to review and it is really common in open source development.

SimeonEhrig commented 3 years ago

But back to the topic, the vector copy example looks good. I think you can use the Python library to write the images. I will do the full review probably tomorrow.

afif-ishamsyah commented 3 years ago

I have difficulties to do it with python, combine with the loop (n time of image) is very confusing. I will try some other alternative for now

SimeonEhrig commented 3 years ago

It's okay, if you only prints the actual reconstructed images without axis, comparison and so one. The following script should do this:

import imageio
import matplotlib.pyplot as plt
import numpy as np

def main():
    file_names = ["a", "b", "c" ,"d"]
    file_extension = ".png"

    for file_name in file_names:
        image = imageio.imread(file_name + file_extension , as_gray=True)

        plt.imsave(file_name + "_new" + file_extension, image, cmap='gray')

if __name__ == "__main__":
    main()
afif-ishamsyah commented 3 years ago

It is not that part that I have difficulties. It is how do I get the image from phase retrieval to python with loop

afif-ishamsyah commented 3 years ago

@SimeonEhrig could you explain it again what needs to be done with this issue?

SimeonEhrig commented 3 years ago

The idea is as test, which do the same like python example.py but do this n times and write the result images to files. I'm not sure, if it is necessary any more. The original idea was, to check if the Python implementation and the CUDA implementation are equals over a series of different initial phases. But now, I think we can say that it is.

afif-ishamsyah commented 3 years ago

I think I can do the argparse part. Should I do it in example.py?

SimeonEhrig commented 3 years ago

No, makes a extra file. The example.py should not become to complex.

SimeonEhrig commented 3 years ago

The algorithm is already stable. No addition tests are necessary.