惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
量子位
C
Check Point Blog
B
Blog RSS Feed
Y
Y Combinator Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
A
About on SuperTechFans
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 聂微东
阮一峰的网络日志
阮一峰的网络日志
人人都是产品经理
人人都是产品经理
小众软件
小众软件
Last Week in AI
Last Week in AI
博客园 - 【当耐特】
GbyAI
GbyAI
The Cloudflare Blog
博客园 - 叶小钗
S
SegmentFault 最新的问题
博客园 - Franky
Engineering at Meta
Engineering at Meta
F
Fortinet All Blogs
B
Blog
Jina AI
Jina AI

Replicate's blog

How to make remarkable videos with Seedance 2.0 – Replicate blog How to prompt Seedream 5.0 – Replicate blog Recraft V4: image generation with design taste – Replicate blog Run Isaac 0.1 on Replicate – Replicate blog Run FLUX.2 on Replicate – Replicate blog How to prompt Nano Banana Pro – Replicate blog Retro Diffusion's pixel art models are now on Replicate – Replicate blog Replicate is joining Cloudflare – Replicate blog Extract text from documents and images with Datalab Marker and OCR – Replicate blog How to prompt Veo 3.1 – Replicate blog IBM's Granite 4.0 is now on Replicate – Replicate blog Which image editing model should I use? – Replicate blog Introducing our new search API – Replicate blog Torch compile caching for inference speed – Replicate blog Announcing Replicate's remote MCP server – Replicate blog How to prompt Veo 3 with images – Replicate blog Open source video is back – Replicate blog Generate consistent characters – Replicate blog Bria is now on Replicate – Replicate blog How we optimized FLUX.1 Kontext [dev] – Replicate blog Compare AI video models – Replicate blog The FLUX.1 Kontext hackathon – Replicate blog How to prompt Veo 3 for the best results – Replicate blog Get the most from Google Veo 3 – Replicate blog FLUX.1 Kontext from the community – Replicate blog Use FLUX.1 Kontext to edit images with words – Replicate blog Generate incredible images with Google's Imagen 4 – Replicate blog Run OpenAI’s latest models on Replicate – Replicate blog NVIDIA H100 GPUs are here – Replicate blog Run 30,000+ LoRAs on Hugging Face with Replicate – Replicate blog
Generate images in one second on your Mac using a latent ...
2023-10-25 · via Replicate's blog

Posted October 25, 2023 by

Latent consistency models (LCMs) are based on Stable Diffusion, but they can generate images much faster, needing only 4 to 8 steps for a good image (compared to 25 to 50 steps). By running an LCM on your M1 or M2 Mac you can generate 512x512 images at a rate of one per second.

Simian Luo et al released the first Stable Diffusion distilled model. It’s distilled from the Dreamshaper fine-tune by incorporating classifier-free guidance into the model’s input. Only one model has been distilled so far, but more will be released. Stable Diffusion 2.1 and SDXL are being worked on by the paper authors.

You can run the first latent consistency model in the cloud on Replicate, but it’s also possible to run it locally. As well as generating predictions, you can hack on it, modify it, and build new things.

We’ve written this guide to help you get started.

Prerequisites

You’ll need:

  • a Mac with an M1 or M2 chip
  • 16GB RAM or more
  • macOS 12.3 or higher
  • Python 3.10 or above

We’ve found that an M1 Max or M2 with 32GB RAM can generate images in 1 second. An M1 Pro with 16GB RAM can generate images in 2 to 4 seconds. Please share your benchmarks with us on our GitHub repository.

Set up Python

You need Python 3.10 or above. Run python -V to see what Python version you have installed:

$ python3 -V Python 3.10.6

If it’s 3.10 or above, like here, you’re good to go! Skip on over to the next step.

Otherwise, you’ll need to install Python 3.10. The easiest way to do that is with Homebrew. First, install Homebrew if you haven’t already.

Then, install the latest version of Python:

brew update brew install python

Now if you run python3 -V you should have 3.10 or above. You might need to reopen your console to make it work.

Clone the repository and install the dependencies

Run this to clone the LCM script from GitHub:

git clone https://github.com/replicate/latent-consistency-model.git cd latent-consistency-model

Then, set up a virtualenv to install the dependencies:

python3 -m pip install virtualenv python3 -m virtualenv venv

Activate the virtualenv:

source venv/bin/activate

(You’ll need to run this command again any time you want to run the script.)

Then, install the dependencies:

pip install -r requirements.txt

Run it!

Now, you can run your latent consistency model. The script will automatically download the SimianLuo/LCM_Dreamshaper_v7 (3.44 GB) and safety checker (1.22 GB) models from HuggingFace.

You’ll see an output like this:

We’ve also added a --continous flag, so you can keep on generating image after image until your harddrive is full. Generations after the first one will run a bit faster too.

That’s it!

Latent consistency model generation of a beautiful apple floating in outer space, like a planet

Next steps

Happy hacking!