-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreatePic.py
30 lines (23 loc) · 977 Bytes
/
createPic.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
import torch
import model.lora.lora as lora
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
def generate_pic(prompt:str):
prompt= prompt
device = "cuda"
lora_path = "SVG.safetensors"
base_model = "jianghushinian/animefull-final-pruned"
generator = torch.Generator(device=device)
seed = generator.seed()
pipe = StableDiffusionPipeline.from_pretrained(base_model,
torch_dtype=torch.float16,
# safety_checker = None,
)
# pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
pipe.enable_xformers_memory_efficient_attention()
# pipe.set_scheduler('sample_dpmpp_2m')
pipe.to(device)
pipe = lora.load_lora_weights(pipe, lora_path, 1.0, 'cuda', torch.float16)
image = pipe(prompt=prompt,
num_inference_steps=32, generator=torch.Generator(device=device).manual_seed(seed),
width=512, height=512).images[0]
return image