Closed alexander-rakhlin closed 4 years ago
Yes, the difference is view vs copy. Slicing shares data with the original object https://scipy-cookbook.readthedocs.io/items/ViewsVsCopies.html
Another thing you may implement here is to move self.input_image
to GPU at initialization. This should improve speed (but not by much in my case)
crop_im = self.input_image_cuda[top:top + size, left:left + size, :].data.clone()
There are definitely a LOT of things to optimize! I am only taking care of serious bugs currently, I am no longer in the field of this work... If you fixed the bug and would like to open a PR I would appreciate the contribution
Thanks for the PR. I will verify performance is not hurt on the entire dataset and will merge. It may take me a while to get to it
Every time you add noise to
crop_im
you change originalself.input_image
https://github.com/sefibk/KernelGAN/blob/7218a37f0933519513aac97f40b8a72d3676eec9/data.py#L44should change
crop_im = self.input_image[top:top + size, left:left + size, :]
tocrop_im = self.input_image[top:top + size, left:left + size, :].copy()