(
self,
stable_diffusion_config,
drop_cond_prob=0.1,
)
| 42 | |
| 43 | class MVDiffusion(pl.LightningModule): |
| 44 | def __init__( |
| 45 | self, |
| 46 | stable_diffusion_config, |
| 47 | drop_cond_prob=0.1, |
| 48 | ): |
| 49 | super(MVDiffusion, self).__init__() |
| 50 | |
| 51 | self.drop_cond_prob = drop_cond_prob |
| 52 | |
| 53 | self.register_schedule() |
| 54 | |
| 55 | # init modules |
| 56 | pipeline = DiffusionPipeline.from_pretrained(**stable_diffusion_config) |
| 57 | pipeline.scheduler = EulerAncestralDiscreteScheduler.from_config( |
| 58 | pipeline.scheduler.config, timestep_spacing='trailing' |
| 59 | ) |
| 60 | self.pipeline = pipeline |
| 61 | |
| 62 | train_sched = DDPMScheduler.from_config(self.pipeline.scheduler.config) |
| 63 | if isinstance(self.pipeline.unet, UNet2DConditionModel): |
| 64 | self.pipeline.unet = RefOnlyNoisedUNet(self.pipeline.unet, train_sched, self.pipeline.scheduler) |
| 65 | |
| 66 | self.train_scheduler = train_sched # use ddpm scheduler during training |
| 67 | |
| 68 | self.unet = pipeline.unet |
| 69 | |
| 70 | # validation output buffer |
| 71 | self.validation_step_outputs = [] |
| 72 | |
| 73 | def register_schedule(self): |
| 74 | self.num_timesteps = 1000 |
nothing calls this directly
no test coverage detected