horseee / DeepCache

[CVPR 2024] DeepCache: Accelerating Diffusion Models for Free
https://horseee.github.io/Diffusion_DeepCache/
Apache License 2.0
687 stars 32 forks source link

Does it support SD-Inpaint model? #11

Open kadirnar opened 7 months ago

kadirnar commented 7 months ago

I changed the UNet2DConditionModel, ImageProjection and DiffusionPipeline functions in the pipeline_stable_diffusion_inpaint.py file. The code is fast but the output is terrible. What can I do to improve this?

kadirnar commented 7 months ago

Code:

outputv0 = pipe(
    prompt, 
    image=image,
    mask_image=mask,
    num_inference_steps=35,
    guidance_scale=5.0,
    strength=1.0,
    num_images_per_prompt=1,
    cache_interval=5, 
    cache_layer_id=0, 
    cache_block_id=0,
    uniform=True,
    output_type='pil', 
    return_dict=True
).images

image

VainF commented 6 months ago

Hi @kadirnar, please tune the cache_interval, cache_layer_id & cache_block_id. Caching in a deeper layer can improve the quality yet reduce the speedup.

kadirnar commented 6 months ago

Hi @kadirnar, please tune the cache_interval, cache_layer_id & cache_block_id. Caching in a deeper layer can improve the quality yet reduce the speedup.

Can you suggest sample values? I don't know what values I should give.

VainF commented 6 months ago

Maybe we can use a smaller cache_interval like 3 or 4, and choose a deeper layer for caching by increasing the cache_block_id & cache_layer_id. cache_layer_id=0 & cache_block_id=0 uses the very first skip connection for caching.