Render a latent vector interpolation video.
(
network_pkl: str,
latent: str,
output: str,
truncation_psi: float,
truncation_cutoff: int,
grid: Tuple[int,int],
num_keyframes: Optional[int],
w_frames: int,
reload_modules: bool,
cfg: str,
image_mode: str,
sampling_multiplier: float,
nrr: Optional[int],
shapes: bool,
interpolate: bool,
)
| 229 | @click.option('--interpolate', type=bool, help='Interpolate between seeds', default=True, show_default=True) |
| 230 | |
| 231 | def generate_images( |
| 232 | network_pkl: str, |
| 233 | latent: str, |
| 234 | output: str, |
| 235 | truncation_psi: float, |
| 236 | truncation_cutoff: int, |
| 237 | grid: Tuple[int,int], |
| 238 | num_keyframes: Optional[int], |
| 239 | w_frames: int, |
| 240 | reload_modules: bool, |
| 241 | cfg: str, |
| 242 | image_mode: str, |
| 243 | sampling_multiplier: float, |
| 244 | nrr: Optional[int], |
| 245 | shapes: bool, |
| 246 | interpolate: bool, |
| 247 | ): |
| 248 | """Render a latent vector interpolation video. |
| 249 | |
| 250 | """ |
| 251 | |
| 252 | print('Loading networks from "%s"...' % network_pkl) |
| 253 | device = torch.device('cuda') |
| 254 | with dnnlib.util.open_url(network_pkl) as f: |
| 255 | G = legacy.load_network_pkl(f)['G_ema'].to(device) # type: ignore |
| 256 | |
| 257 | |
| 258 | G.rendering_kwargs['depth_resolution'] = int(G.rendering_kwargs['depth_resolution'] * sampling_multiplier) |
| 259 | G.rendering_kwargs['depth_resolution_importance'] = int(G.rendering_kwargs['depth_resolution_importance'] * sampling_multiplier) |
| 260 | if nrr is not None: G.neural_rendering_resolution = nrr |
| 261 | |
| 262 | if truncation_cutoff == 0: |
| 263 | truncation_psi = 1.0 # truncation cutoff of 0 means no truncation anyways |
| 264 | if truncation_psi == 1.0: |
| 265 | truncation_cutoff = 14 # no truncation so doesn't matter where we cutoff |
| 266 | |
| 267 | ws = torch.tensor(np.load(latent)['w']).to(device) |
| 268 | gen_interp_video(G=G, mp4=output, ws=ws, bitrate='10M', grid_dims=grid, num_keyframes=num_keyframes, w_frames=w_frames, psi=truncation_psi, truncation_cutoff=truncation_cutoff, cfg=cfg, image_mode=image_mode, gen_shapes=shapes) |
| 269 | |
| 270 | #---------------------------------------------------------------------------- |
| 271 |
no test coverage detected