Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions motion_magnification_pytorch.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -569,13 +569,13 @@
},
{
"cell_type": "code",
"execution_count": 158,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"## Get DFT of all video frames\n",
"frames_tensor = torch.tensor(np.array(frames)).type(torch.float32).to(device)\n",
"video_dft = torch.fft.fftshift(torch.fft.fft2(frames_tensor, dim=(1,2))).type(torch.complex64).to(device)"
"video_dft = torch.fft.fftshift(torch.fft.fft2(frames_tensor, dim=(1,2)), dim=(1,2)).type(torch.complex64).to(device)"
]
},
{
Expand Down Expand Up @@ -631,7 +631,7 @@
},
{
"cell_type": "code",
"execution_count": 163,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -660,8 +660,7 @@
" _delta = torch.angle(curr_pyr) - ref_phase \n",
"\n",
" # get phase delta wrapped to [-pi, pi]\n",
" phase_deltas[:, vid_idx, :, :] = ((torch.pi + _delta) \\\n",
" % 2*torch.pi) - torch.pi\n",
" phase_deltas[:, vid_idx, :, :] = ((torch.pi + _delta) % (2*torch.pi)) - torch.pi\n",
" \n",
" ## Temporally Filter the phase deltas\n",
" # Filter in Frequency Domain and convert back to phase space\n",
Expand Down
3 changes: 1 addition & 2 deletions phase_based_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ def process_single_channel(self,
_delta = torch.angle(curr_pyr) - ref_phase

# get phase delta wrapped to [-pi, pi]
phase_deltas[:, vid_idx, :, :] = ((torch.pi + _delta) \
% 2*torch.pi) - torch.pi
phase_deltas[:, vid_idx, :, :] = ((torch.pi + _delta) % (2*torch.pi)) - torch.pi

## Temporally Filter the phase deltas
# Filter in Frequency Domain and convert back to phase space
Expand Down
2 changes: 1 addition & 1 deletion phase_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def create_gif_from_numpy(save_path, images):
## Misc utils

def get_fft2_batch(tensor_in):
return torch.fft.fftshift(torch.fft.fft2(tensor_in, dim=(1,2))).type(torch.complex64)
return torch.fft.fftshift(torch.fft.fft2(tensor_in, dim=(1, 2)), dim=(1, 2)).type(torch.complex64)


def bandpass_filter(freq_lo, freq_hi, fs, num_taps, device):
Expand Down