|
import torch |
|
from lyrasd_model import LyraSdXLTxt2ImgPipeline |
|
import time |
|
import GPUtil |
|
import os |
|
from glob import glob |
|
import random |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib_path = "./lyrasd_model/lyrasd_lib/libth_lyrasd_cu12_sm80.so" |
|
model_path = "./models/helloworldSDXL20Fp16" |
|
lora_path = "./models/dissolve_sdxl.safetensors" |
|
torch.classes.load_library(lib_path) |
|
|
|
|
|
model = LyraSdXLTxt2ImgPipeline() |
|
|
|
model.reload_pipe(model_path) |
|
|
|
|
|
|
|
model.load_lora_v2(lora_path, "dissolve_sdxl", 0.4) |
|
|
|
|
|
prompt = "a cat, ral-dissolve" |
|
negative_prompt = "nswf, watermark" |
|
height, width = 1024, 1024 |
|
steps = 20 |
|
guidance_scale = 7.5 |
|
generator = torch.Generator().manual_seed(8788800) |
|
|
|
start = time.perf_counter() |
|
|
|
images = model(prompt, |
|
height=height, |
|
width=width, |
|
num_inference_steps=steps, |
|
num_images_per_prompt=1, |
|
guidance_scale=guidance_scale, |
|
negative_prompt=negative_prompt, |
|
generator=generator |
|
) |
|
print("image gen cost: ", time.perf_counter() - start) |
|
|
|
for i, image in enumerate(images): |
|
image.save(f"outputs/res_txt2img_xl_lora_{i}.png") |
|
|
|
|
|
model.unload_lora_v2("dissolve_sdxl", True) |
|
|