| 161 | |
| 162 | |
| 163 | def stack_images_gen(gen, real_imgs=None): |
| 164 | print("Stacking frames..") |
| 165 | allframes = gen |
| 166 | nframes, nspa, nats, h, w, pix = allframes.shape |
| 167 | blackborder = np.zeros((w * nspa, h // 30, pix), dtype=allframes.dtype) |
| 168 | blackborder = blackborder[None, ...].repeat(nats, |
| 169 | axis=0).transpose(0, 2, 1, 3) |
| 170 | |
| 171 | frames = [] |
| 172 | for frame_idx in tqdm(range(nframes)): |
| 173 | rows = np.vstack(allframes[frame_idx].transpose(0, 3, 2, 4, |
| 174 | 1)).transpose( |
| 175 | 3, 1, 0, 2) |
| 176 | rows = np.concatenate((rows, blackborder), 1) |
| 177 | frame = np.concatenate(rows, 0) |
| 178 | frames.append(frame) |
| 179 | |
| 180 | if real_imgs is not None: |
| 181 | # ToDo Add images |
| 182 | resize_imgs = convert_img(real_imgs, h)[:nframes, ...] |
| 183 | for i in range(len(frames)): |
| 184 | imgs = np.vstack(resize_imgs[i, ...]) |
| 185 | #imgs = torch2numpy(imgs) |
| 186 | frames[i] = np.concatenate((imgs, frames[i]), 1) |
| 187 | return np.stack(frames) |
| 188 | |
| 189 | |
| 190 | def generate_by_video(visualization, reconstructions, generation, |