Update README.md (#2)
Browse files- Update README.md (507091618a1108769d6536f09c898d81e3a92ff2)
Co-authored-by: Yiqin Tan <tyq1024@users.noreply.huggingface.co>
    	
        README.md
    CHANGED
    
    | @@ -1,3 +1,67 @@ | |
| 1 | 
             
            ---
         | 
| 2 | 
             
            license: mit
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
| 3 | 
             
            ---
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
             
            ---
         | 
| 2 | 
             
            license: mit
         | 
| 3 | 
            +
            language:
         | 
| 4 | 
            +
            - en
         | 
| 5 | 
            +
            pipeline_tag: text-to-image
         | 
| 6 | 
            +
            tags:
         | 
| 7 | 
            +
            - text-to-image
         | 
| 8 | 
             
            ---
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            # Latent Consistency Models
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            Official Repository of the paper: *[Latent Consistency Models: Synthesizing High-Resolution Images with Few-Step Inference](https://arxiv.org/abs/2310.04378)*.
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            Project Page: https://latent-consistency-models.github.io
         | 
| 15 | 
            +
             | 
| 16 | 
            +
             | 
| 17 | 
            +
            <p align="center">
         | 
| 18 | 
            +
                <img src="teaser.png">
         | 
| 19 | 
            +
            </p>
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            By distilling classifier-free guidance into the model's input, LCM can generate high-quality images in very short inference time. We compare the inference time at the setting of 768 x 768 resolution, CFG scale w=8, batchsize=4, using a A800 GPU. 
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            <p align="center">
         | 
| 24 | 
            +
                <img src="speed_fid.png">
         | 
| 25 | 
            +
            </p>
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            ## Usage
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            You can try out Latency Consistency Models directly on:
         | 
| 30 | 
            +
            [](https://huggingface.co/spaces/SimianLuo/Latent_Consistency_Model)
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            To run the model yourself, you can leverage the 🧨 Diffusers library:
         | 
| 33 | 
            +
            1. Install the library:
         | 
| 34 | 
            +
            ```
         | 
| 35 | 
            +
            pip install diffusers transformers accelerate
         | 
| 36 | 
            +
            ```
         | 
| 37 | 
            +
             | 
| 38 | 
            +
            2. Run the model:
         | 
| 39 | 
            +
            ```py
         | 
| 40 | 
            +
            from diffusers import DiffusionPipeline
         | 
| 41 | 
            +
            import torch
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            pipe = DiffusionPipeline.from_pretrained("SimianLuo/LCM_Dreamshaper_v7", custom_pipeline="latent_consistency_txt2img")
         | 
| 44 | 
            +
             | 
| 45 | 
            +
            # To save GPU memory, torch.float16 can be used, but it may compromise image quality.
         | 
| 46 | 
            +
            pipe.to(torch_device="cuda", torch_dtype=torch.float32)
         | 
| 47 | 
            +
             | 
| 48 | 
            +
            prompt = "Self-portrait oil painting, a beautiful cyborg with golden hair, 8k"
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            # Can be set to 1~50 steps. LCM support fast inference even <= 4 steps. Recommend: 1~8 steps.
         | 
| 51 | 
            +
            num_inference_steps = 4 
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            images = pipe(prompt=prompt, num_inference_steps=num_inference_steps, guidance_scale=8.0, lcm_origin_steps=50, output_type="pil", custom_revision=main).images
         | 
| 54 | 
            +
            ```
         | 
| 55 | 
            +
             | 
| 56 | 
            +
            ## BibTeX
         | 
| 57 | 
            +
             | 
| 58 | 
            +
            ```bibtex
         | 
| 59 | 
            +
            @misc{luo2023latent,
         | 
| 60 | 
            +
                  title={Latent Consistency Models: Synthesizing High-Resolution Images with Few-Step Inference}, 
         | 
| 61 | 
            +
                  author={Simian Luo and Yiqin Tan and Longbo Huang and Jian Li and Hang Zhao},
         | 
| 62 | 
            +
                  year={2023},
         | 
| 63 | 
            +
                  eprint={2310.04378},
         | 
| 64 | 
            +
                  archivePrefix={arXiv},
         | 
| 65 | 
            +
                  primaryClass={cs.CV}
         | 
| 66 | 
            +
            }
         | 
| 67 | 
            +
            ```
         | 
