Eulerian-Video-Magnification icon indicating copy to clipboard operation
Eulerian-Video-Magnification copied to clipboard

Compilation issue

Open jojokeeps opened this issue 2 years ago • 3 comments

Everything works up until the final part and I keep getting this issue:

numpy.core._exceptions._ArrayMemoryError: Unable to allocate 12.0 GiB for an array with shape (3, 720, 1280, 292) and data type complex 128

Any help? Thanks!

jojokeeps avatar Jul 02 '23 22:07 jojokeeps

Hi,

Do not use the default parameters, they are the reason for running out of memory. Use the ones suggested inside the 'results' folder.

kodavatimahendra avatar Nov 19 '23 03:11 kodavatimahendra

Sorry my bad, inside each iteration of gaussian and laplacian functions, the lists are continuously appended. These lists aren't cleared until the end. Therefore for higher resolution or longer videos, the memory will overflow.

These functions have to be optimized.

kodavatimahendra avatar Nov 19 '23 04:11 kodavatimahendra

The following function require less memory if using Gaussian kernel.

from scipy.fft import fft, ifft, fftfreq

def idealTemporalBandpassFilter_chunck(images, fps, freq_range, axis=0, chunk_size=200):
    num_frames = images.shape[axis]
    result = np.empty_like(images)

    for start in tqdm.tqdm(
        range(0, num_frames, chunk_size), ascii=True, desc="Gaussian Pyramids Filtering"
    ):
        end = min(start + chunk_size, num_frames)
        chunk = images.take(np.arange(start, end), axis=axis, mode="clip")
        fft_result = fft(chunk, axis=axis)
        frequencies = fftfreq(chunk.shape[0], d=1.0 / fps)

        low = (np.abs(frequencies - freq_range[0])).argmin()
        high = (np.abs(frequencies - freq_range[1])).argmin()

        fft_result[:low] = 0
        fft_result[high:] = 0

        result[start:end, ...] = ifft(fft_result, axis=0).real
    return result

8188 avatar Apr 03 '24 08:04 8188