From df9017737da7aa5f5d8373f73896c5a0202392de Mon Sep 17 00:00:00 2001 From: mayukhdeb Date: Sun, 25 Feb 2024 22:47:47 +0530 Subject: [PATCH] successfully decoupled amplitude and phase info --- torch_dreams/maco/image_param.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/torch_dreams/maco/image_param.py b/torch_dreams/maco/image_param.py index af9cac8..bd223dc 100644 --- a/torch_dreams/maco/image_param.py +++ b/torch_dreams/maco/image_param.py @@ -53,29 +53,25 @@ def __init__( def reconstruct_image_param(self, amplitude, phase): reconstructed_image_param = amplitude * torch.exp(1j * phase) - return reconstructed_image_param + return reconstructed_image_param.real def check_whether_we_get_image_param(self, amplitude, phase, image_param): reconstructed_image_param = self.reconstruct_image_param( amplitude=amplitude, phase=phase ) - + assert torch.allclose( image_param, - reconstructed_image_param.real + reconstructed_image_param ), f"Could not reconstruct image param. Very sad." - def get_image_param_from_phase_and_amplitude_spectrum(self): - pass - - def postprocess(self, device): img = fft_to_rgb( height=self.height, width=self.width, - image_parameter=self.get_image_param_from_phase_and_amplitude_spectrum(), + image_parameter=self.reconstruct_image_param(amplitude = self.amplitude_spectrum, phase=self.param), device=device, ) img = lucid_colorspace_to_rgb(t=img, device=device)