diffusers/tools
1127
1#!/usr/bin/env python32from diffusers import DiffusionPipeline3from safetensors.torch import load_file4import torch5from pathlib import Path6from huggingface_hub import HfApi, hf_hub_download7import os8import hf_image_uploader as hiu9import time10 11api = HfApi()12 13 14pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16)15pipe.to("cuda")16 17# pipe.load_lora_weights("stabilityai/stable-diffusion-xl-base-1.0", weight_name="sd_xl_offset_example-lora_1.0.safetensors", low_cpu_mem_usage=True)18# file = hf_hub_download("TheLastBen/Papercut_SDXL", filename="papercut.safetensors")19file = hf_hub_download("hf-internal-testing/sdxl-0.9-daiton-lora", filename="daiton-xl-lora-test.safetensors")20 21start_time = time.time()22pipe.load_lora_weights("Pclanglais/TintinIA")23pipe.fuse_lora()24pipe.unfuse_lora()25pipe.unload_lora_weights()26 27pipe.load_lora_weights("ProomptEngineer/pe-balloon-diffusion-style")28pipe.fuse_lora()29pipe.unload_lora_weights()30pipe.unfuse_lora()31 32pipe.load_lora_weights("ostris/crayon_style_lora_sdxl")33pipe.fuse_lora()34pipe.unload_lora_weights()35pipe.unfuse_lora()36print(time.time() - start_time)37 38prompt = "masterpiece, best quality, mountain"39 40images = pipe(prompt=prompt, 41 num_inference_steps=20, 42 generator=torch.manual_seed(0)43).images44 45hiu.upload(images[0], "patrickvonplaten/images")46 