hansyan commited on
Commit
5cf0693
1 Parent(s): f50f6d7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +33 -0
README.md CHANGED
@@ -1,3 +1,36 @@
1
  ---
2
  license: cc-by-nc-4.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: cc-by-nc-4.0
3
  ---
4
+
5
+ Github repo: https://github.com/magic-research/piecewise-rectified-flow <br>
6
+ Project page: https://piecewise-rectified-flow.github.io/
7
+
8
+ ```python
9
+ import torch, torchvision
10
+ from diffusers import StableDiffusionPipeline, UNet2DConditionModel
11
+ from src.utils_perflow import merge_delta_weights_into_unet
12
+ from src.scheduler_perflow import PeRFlowScheduler
13
+ delta_weights = UNet2DConditionModel.from_pretrained("hansyan/piecewise-rectified-flow-delta-weights", torch_dtype=torch.float16, variant="v0-1",).state_dict()
14
+ pipe = StableDiffusionPipeline.from_pretrained("Lykon/dreamshaper-8", torch_dtype=torch.float16,)
15
+ pipe = merge_delta_weights_into_unet(pipe, delta_weights)
16
+ pipe.scheduler = PeRFlowScheduler.from_config(pipe.scheduler.config, prediction_type="epsilon", num_time_windows=4)
17
+ pipe.to("cuda", torch.float16)
18
+
19
+ prompts_list = ["A man with brown skin, a beard, and dark eyes", "A colorful bird standing on the tree, open beak",]
20
+ for i, prompt in enumerate(prompts_list):
21
+ generator = torch.Generator("cuda").manual_seed(1024)
22
+ prompt = "RAW photo, 8k uhd, dslr, high quality, film grain, highly detailed, masterpiece; " + prompt
23
+ neg_prompt = "distorted, blur, smooth, low-quality, warm, haze, over-saturated, high-contrast, out of focus, dark"
24
+ samples = pipe(
25
+ prompt = [prompt] * 8,
26
+ negative_prompt = [neg_prompt] * 8,
27
+ height = 512,
28
+ width = 512,
29
+ num_inference_steps = 8,
30
+ guidance_scale = 7.5,
31
+ generator = generator,
32
+ output_type = 'pt',
33
+ ).images
34
+ torchvision.utils.save_image(torchvision.utils.make_grid(samples, nrow=4), f"tmp_{i}.png")
35
+
36
+ ```