CoolFace
Apppublic

diffusers/benchmark-pt2.1

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
utils.py52 linesDownload Raw Back to root
1from diffusers.utils import load_image2 3 4def get_image_for_img_to_img(pipeline_to_benchmark):5    if pipeline_to_benchmark == "SD I2I":6        url = "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg"7        init_image = load_image(url).convert("RGB")8        init_image = init_image.resize((512, 512))9    elif pipeline_to_benchmark == "SDXL I2I":10        url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/sdxl-img2img.png"11        init_image = load_image(url).convert("RGB")12    return init_image13 14 15def get_image_for_inpainting(pipeline_to_benchmark):16    if pipeline_to_benchmark == "SD Inpainting":17        image_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png"18        mask_url = "https://raw.githubusercontent.com/CompVis/latent-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png"19        init_image = load_image(image_url).convert("RGB").resize((512, 512))20        mask_image = load_image(mask_url).convert("RGB").resize((512, 512))21    elif pipeline_to_benchmark == "SDXL Inpainting":22        image_url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/sdxl-text2img.png"23        mask_url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/sdxl-inpaint-mask.png"24        init_image = load_image(image_url).convert("RGB")25        mask_image = load_image(mask_url).convert("RGB")26    return init_image, mask_image27 28 29def get_image_for_controlnet(pipeline_to_benchmark):30    if pipeline_to_benchmark == "SD ControlNet":31        image = load_image(32            "https://huggingface.co/lllyasviel/sd-controlnet-canny/resolve/main/images/bird_canny.png"33        ).convert("RGB")34    elif pipeline_to_benchmark == "SDXL ControlNet":35        image = load_image(36            "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/hf-logo.png"37        ).convert("RGB")38 39    return image40 41 42def get_image_for_adapters(pipeline_to_benchmark):43    if pipeline_to_benchmark == "SD T2I Adapters":44        image = load_image(45            "https://huggingface.co/datasets/sayakpaul/sample-datasets/resolve/main/sd_t2i_canny.png"46        )47    elif pipeline_to_benchmark == "SDXL T2I Adapters":48        image = load_image(49            "https://huggingface.co/Adapter/t2iadapter/resolve/main/figs_SDXLV1.0/cond_canny.png"50        ).convert("RGB")51    return image52