frutiemax commited on
Commit
2a7e546
1 Parent(s): 664819e

Push initial pipeline

Browse files
Files changed (2) hide show
  1. rct_diffusion_pipeline.py +15 -0
  2. test_pipeline.py +8 -0
rct_diffusion_pipeline.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from diffusers import DiffusionPipeline
2
+ import torch
3
+
4
+ class RCTDiffusionPipeline(DiffusionPipeline):
5
+ def __init__(self, unet, scheduler):
6
+ super().__init__()
7
+ self.register_modules(unet=unet, scheduler=scheduler)
8
+
9
+ def __call__(self):
10
+ image = torch.randn((1, self.unet.config.in_channels, self.unet.config.sample_size, self.unet.config.sample_size))
11
+ timestep = 1
12
+
13
+ model_output = self.unet(image, timestep).sample
14
+ scheduler_output = self.scheduler.step(model_output, timestep, image).prev_sample
15
+ return scheduler_output
test_pipeline.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ from rct_diffusion_pipeline import RCTDiffusionPipeline
2
+ from diffusers import DDPMScheduler, UNet2DModel
3
+
4
+ scheduler = DDPMScheduler()
5
+ unet = UNet2DModel()
6
+
7
+ pipeline = RCTDiffusionPipeline(unet=unet, scheduler=scheduler)
8
+ output = pipeline()