forked from bghira/SimpleTuner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinference_ddpm.py
57 lines (53 loc) · 2.25 KB
/
inference_ddpm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Use Pytorch 2!
import torch
from diffusers import (
StableDiffusionPipeline,
DiffusionPipeline,
AutoencoderKL,
UNet2DConditionModel,
DDPMScheduler,
)
from transformers import CLIPTextModel
# Any model currently on Huggingface Hub.
# model_id = 'junglerally/digital-diffusion'
# model_id = 'ptx0/realism-engine'
# model_id = 'ptx0/artius_v21'
# model_id = 'ptx0/pseudo-journey'
model_id = "ptx0/pseudo-journey-v2"
pipeline = DiffusionPipeline.from_pretrained(model_id)
# Optimize!
pipeline.unet = torch.compile(pipeline.unet)
scheduler = DDPMScheduler.from_pretrained(model_id, subfolder="scheduler")
# Remove this if you get an error.
torch.set_float32_matmul_precision("high")
pipeline.to("cuda")
prompts = {
"woman": "a woman, hanging out on the beach",
"man": "a man playing guitar in a park",
"lion": "Explore the ++majestic beauty++ of untamed ++lion prides++ as they roam the African plains --captivating expressions-- in the wildest national geographic adventure",
"child": "a child flying a kite on a sunny day",
"bear": "best quality ((bear)) in the swiss alps cinematic 8k highly detailed sharp focus intricate fur",
"alien": "an alien exploring the Mars surface",
"robot": "a robot serving coffee in a cafe",
"knight": "a knight protecting a castle",
"menn": "a group of smiling and happy men",
"bicycle": "a bicycle, on a mountainside, on a sunny day",
"cosmic": "cosmic entity, sitting in an impossible position, quantum reality, colours",
"wizard": "a mage wizard, bearded and gray hair, blue star hat with wand and mystical haze",
"wizarddd": "digital art, fantasy, portrait of an old wizard, detailed",
"macro": "a dramatic city-scape at sunset or sunrise",
"micro": "RNA and other molecular machinery of life",
"gecko": "a leopard gecko stalking a cricket",
}
for shortname, prompt in prompts.items():
# old prompt: ''
image = pipeline(
prompt=prompt,
negative_prompt="malformed, disgusting, overexposed, washed-out",
num_inference_steps=32,
generator=torch.Generator(device="cuda").manual_seed(1641421826),
width=1152,
height=768,
guidance_scale=7.5,
).images[0]
image.save(f"test/{shortname}_nobetas.png", format="PNG")