| 76 | |
| 77 | |
| 78 | def resize_PIL(channel_first, interp, w, h): |
| 79 | pil_resample = resample_dali2pil[interp] |
| 80 | |
| 81 | def resize(input): |
| 82 | num_frames = input.shape[0] |
| 83 | out_seq = [] |
| 84 | for i in range(num_frames): |
| 85 | frame = input[i] |
| 86 | if channel_first: |
| 87 | frame = frame.transpose([1, 2, 0]) |
| 88 | out_frame = PIL.Image.fromarray(frame).resize([w, h], resample=pil_resample) |
| 89 | out_frame = np.array(out_frame) |
| 90 | if channel_first: |
| 91 | out_frame = out_frame.transpose([2, 0, 1]) |
| 92 | out_seq.append(out_frame) |
| 93 | return np.array(out_seq) |
| 94 | |
| 95 | return resize |
| 96 | |
| 97 | |
| 98 | def create_ref_pipe(channel_first, seq_len, interp, dtype, w, h, batch_size=2): |