MCPcopy Create free account
hub / github.com/TencentARC/InstantMesh / validation_step

Method validation_step

zero123plus/model.py:236–251  ·  view source on GitHub ↗
(self, batch, batch_idx)

Source from the content-addressed store, hash-verified

234
235 @torch.no_grad()
236 def validation_step(self, batch, batch_idx):
237 # get input
238 cond_imgs, target_imgs = self.prepare_batch_data(batch)
239
240 images_pil = [v2.functional.to_pil_image(cond_imgs[i]) for i in range(cond_imgs.shape[0])]
241
242 outputs = []
243 for cond_img in images_pil:
244 latent = self.pipeline(cond_img, num_inference_steps=75, output_type='latent').images
245 image = unscale_image(self.pipeline.vae.decode(latent / self.pipeline.vae.config.scaling_factor, return_dict=False)[0]) # [-1, 1]
246 image = (image * 0.5 + 0.5).clamp(0, 1)
247 outputs.append(image)
248 outputs = torch.cat(outputs, dim=0).to(self.device)
249 images = torch.cat([target_imgs, outputs], dim=-2)
250
251 self.validation_step_outputs.append(images)
252
253 @torch.no_grad()
254 def on_validation_epoch_end(self):

Callers

nothing calls this directly

Calls 2

prepare_batch_dataMethod · 0.95
unscale_imageFunction · 0.70

Tested by

no test coverage detected