| import torch |
| import time |
|
|
| from lyrasd_model import LyraSdTxt2ImgPipeline |
|
|
| |
| |
| |
| |
| |
|
|
| |
| lib_path = "./lyrasd_model/lyrasd_lib/libth_lyrasd_cu12_sm80.so" |
| model_path = "./models/rev-animated" |
| lora_path = "./models/xiaorenshu.safetensors" |
|
|
| torch.classes.load_library(lib_path) |
|
|
| |
| model = LyraSdTxt2ImgPipeline() |
| model.reload_pipe(model_path) |
|
|
| |
| |
| model.load_lora_v2(lora_path, "xiaorenshu", 0.4) |
|
|
| |
| prompt = "a cat, cute, cartoon, concise, traditional, chinese painting, Tang and Song Dynasties, masterpiece, 4k, 8k, UHD, best quality" |
| negative_prompt = "(((horrible))), (((scary))), (((naked))), (((large breasts))), high saturation, colorful, human:2, body:2, low quality, bad quality, lowres, out of frame, duplicate, watermark, signature, text, frames, cut, cropped, malformed limbs, extra limbs, (((missing arms))), (((missing legs)))" |
| height, width = 512, 512 |
| steps = 20 |
| guidance_scale = 7 |
| generator = torch.Generator().manual_seed(123) |
| num_images = 1 |
|
|
| start = time.perf_counter() |
| |
| images = model(prompt, height, width, steps, |
| guidance_scale, negative_prompt, num_images, |
| generator=generator) |
| print("image gen cost: ", time.perf_counter() - start) |
| |
| for i, image in enumerate(images): |
| image.save(f"outputs/res_txt2img_lora_{i}.png") |
|
|
| |
| model.unload_lora_v2("xiaorenshu", True) |
|
|