BlogsReplicateImage Generation Optimization

Image Generation Optimization

Image Generation Optimization

26
posts
2022–2026

Replicate has introduced support for Stable Diffusion 3 (SD3) and provides instructions for running it locally using ComfyUI. This involves installing Cog, cloning a ComfyUI repository, and running ComfyUI with specific commands to download weights and load an SD3 workflow. The post details the prerequisites and step-by-step process for users to generate images with SD3 on their own machines. This post extends this by showing how to push a custom version of SD3 to Replicate using Cog, enabling users to leverage models with specific aesthetic qualities like Krea 2, which offers distinct styles for portraits, cinematic frames, illustrations, and product shots with minimal prompting.

2026

Krea 2 is your model for aesthetics

6/23/2026

This post introduces Krea 2, a new image generation model available on Replicate, highlighting its strong built-in aesthetic and ease of use with short prompts. It details the model's capabilities across portraits, photorealism, cinematic frames, illustrations, and product/ad creatives, providing examples and prompt guidance. It also differentiates between Krea 2 Large, Medium, and Medium Turbo models based on their characteristics and use cases. Additionally, it provides integration examples for running Krea 2 on Replicate via JavaScript and on Cloudflare AI Gateway using both JavaScript and cURL.

2025

How to prompt Nano Banana Pro

11/20/2025

This post introduces Nano Banana Pro, a new image generation model. It highlights the model's advanced capabilities in understanding and responding to text within images, summarizing documents into visual formats, and accurately rendering code. The post also details its strong text adherence, even when combined with various styles, and its ability to maintain character consistency across multiple reference images for complex scene generation and storytelling.

Which image editing model should I use?

9/23/2025

This post provides a comparative analysis of several image editing models available on Replicate, evaluating their performance across object removal, perspective transformation, background editing, text editing, and style transfer. It includes cost and inference time data for each model and offers qualitative assessments of their output quality for each task, identifying specific models that excel in different areas. This contributes to understanding the practical application and comparative strengths of various image editing AI models.

Generate consistent characters

7/21/2025

This post evaluates and compares several state-of-the-art image generation models (gpt-image-1, Gen-4 Image, FLUX.1 Kontext, SeedEdit 3, Ideogram's Character, Gen-4 Image Turbo) for their ability to generate consistent characters from a single reference image. It details the speed, cost, and output quality of each model across various use cases, including photographic accuracy and creative transformations. The post also references previous methods like training LoRAs and using ComfyUI workflows, positioning the new models as simpler alternatives. A comparison model is introduced to facilitate side-by-side evaluation.

How we optimized FLUX.1 Kontext [dev]

7/15/2025

This post details the implementation of TaylorSeer for optimizing the FLUX.1 Kontext image generation model. It explains the mathematical basis of Taylor Series approximation for predicting intermediate image states, the caching mechanism for derivatives, and the step-by-step logic within the `denoise()` function. The post outlines two paths: full computation and approximation using Taylor Series, and describes how the latent image is updated in each case. It also discusses the `generate_compute_step_map()` function for controlling the acceleration level and provides code snippets for the caching state, derivative approximation, and latent update.

FLUX.1 Kontext from the community

6/2/2025

This post introduces FLUX.1 Kontext, a new image editing model, and showcases community use cases such as hair color swaps, professional headshots, image restoration, and aspect ratio changes. It also announces Kontext Chat, a conversational interface for image editing, and the availability of Kontext apps for direct use.

Use FLUX.1 Kontext to edit images with words

5/29/2025

This post introduces FLUX.1 Kontext, a new image editing model from Black Forest Labs, as an addition to the FLUX.1 family. It details the model's capabilities in editing images using text prompts, highlighting its performance, prompt adherence, and consistency. The post also provides examples of its use in style transfer, text editing, and character consistency, along with API usage examples and commercial use guidelines. It also mentions the existence of three models: pro, max, and dev, with pro and max available now.

Ideogram 3.0 on Replicate

5/7/2025

This post introduces Ideogram 3.0, a major update to a text-to-image model, highlighting its improvements in realism, style control, and layout generation. It details three variants: Turbo, Balanced, and Quality, and provides JavaScript code examples for their usage on Replicate. The post showcases Ideogram 3.0's enhanced typography, layout generation capabilities, and style transfer features using reference images. It also emphasizes the model's increased realism and its top performance in human evaluations.

2024

FLUX fine-tunes are now fast

11/26/2024

This post details optimizations for FLUX fine-tunes, making them as fast as base models. This is achieved by quantizing LoRAs to fp8, merging weights into the base model, and automatically increasing `lora_scale` by 1.5x when `go_fast=true`. Additionally, support has been added to load LoRAs from Hugging Face, Civitai, and arbitrary HTTP URLs. The underlying optimizations for the base models utilize `torch.compile` and fast CuDNN attention kernels.

Ideogram v2 is an outstanding new inpainting model

10/22/2024

This post introduces Ideogram v2, a new inpainting model available on Replicate, with two variants: ideogram-ai/ideogram-v2 (high quality) and ideogram-ai/ideogram-v2-turbo (faster). It demonstrates API usage for inpainting with Python and JavaScript clients, provides a live demo via inpainter.app, and offers tips for achieving the best inpainting results. It also highlights Ideogram v2's capability in generating text within images and suggests related projects like 'Inpainter' and 'Outpainter'.

Stable Diffusion 3.5 is here

10/22/2024

This post announces the availability of Stable Diffusion 3.5 on Replicate, detailing its three variants (Large, Large Turbo, Medium) and their respective strengths. It provides code examples for using the models via the Replicate API and highlights key improvements such as enhanced image quality, greater output variety through query-key normalization, and improved prompt adherence. Pricing and licensing information are also included, along with a preview of future fine-tuning support.

FLUX1.1 [pro] is here

10/3/2024

This post announces FLUX1.1 [pro], a new, faster, and more powerful version of FLUX.1 [pro], generating images six times faster with higher quality and better prompt adherence. It also introduces a prompt upsampling feature that uses an LLM to expand prompts. The existing FLUX.1 [pro] model has also been upgraded to be twice as fast.

Fine-tune FLUX.1 with an API

9/9/2024

This post details the technical process of programmatically fine-tuning FLUX.1 models using Replicate's HTTP API. It outlines the steps involved: gathering and zipping training images, setting up the `REPLICATE_API_TOKEN` environment variable, creating a destination model using the `models.create` API endpoint, uploading training data via the Files API, and initiating the training job by making a POST request to the `versions/d995297071a44dcb72244e6c19462111649ec86a9646c32df56daa7f14801944/trainings` endpoint with `input_images` and `trigger_word` as parameters. It also explains how to monitor training status and retrieve the output weights URL.

Fine-tune FLUX.1 to create images of yourself

8/30/2024

This post details the process of fine-tuning the FLUX.1 image generation model on Replicate using user-provided images. It outlines the steps involved: gathering training images (format, resolution, quantity), selecting a unique trigger word, and using the web-based training form or API to create and train a model. The post also explains how to generate images using the fine-tuned model via the web playground or API, and provides guidance on using language models to craft more effective prompts for image generation. It highlights the ease of fine-tuning and the ability to create personalized image generation capabilities.

Replicate Intelligence #11

8/16/2024

This post introduces the ability to fine-tune the FLUX.1 image generation model on Replicate. Users can upload 12-20 diverse images, choose a trigger word, and train a custom model in approximately 30 minutes. This enables the generation of images featuring unique styles or specific subjects.

Replicate Intelligence #10

8/9/2024

This post details the addition of image-to-image generation capabilities for the FLUX.1 model on Replicate. It explains that this is achieved by using the starter image's pixels instead of random noise, allowing for better style transfer and composition control. It also notes potential weaknesses, such as difficulty in generating black-and-white line art from color images.

FLUX.1: First Impressions

8/2/2024

This post introduces FLUX.1, a new AI model for image generation that uses "flow matching" instead of diffusion. It details the model's capabilities through various prompt examples, highlighting its strengths in text rendering, light and texture, artistic style interpretation, scene composition, and its unique "flow" aesthetic. The post also mentions FLUX.1 [schnell], an optimized version for speed and local execution, and encourages users to try it on Replicate.

How to get the best results from Stable Diffusion 3

6/18/2024

This post details how to achieve optimal results with Stable Diffusion 3, focusing on prompt engineering, understanding different model versions (including text encoder configurations like fp8, fp16, and CLIP-only), and recommended settings for width, height, steps, and guidance scale. It highlights SD3's improved prompt adherence with longer prompts and advises against negative prompts, comparing its behavior to Midjourney v6 and DALL-E 3. Specific recommendations are provided for resolutions, steps (around 28), and CFG scale (3.5-4.5), along with observations on how steps affect image coherence and subject details. The post also touches on the potential for using different prompts for each of SD3's three text encoders.

Run Stable Diffusion 3 on your Apple Silicon Mac

6/18/2024

This post details how to run Stable Diffusion 3 locally on Apple Silicon Macs using a provided repository and Python environment, as well as an alternative method using DiffusionKit with MLX. It includes performance comparisons between the two methods and discusses various parameters for customization, such as seed, prompt, dimensions, inference steps, and guidance scale. It also mentions optimizations like float16 precision and the use of T5 for longer prompts.

Push a custom version of Stable Diffusion 3

6/14/2024

This post details the process of pushing a custom version of Stable Diffusion 3 (SD3) to Replicate. It outlines the prerequisites (Git, Docker, Replicate account), the steps to create a model on Replicate, install Cog, clone the `cog-stable-diffusion-3` repository, and finally push the model using `cog push`. It also suggests iteration ideas such as adding inpainting support, an upscaler, or modifying the prediction interface.

Run Stable Diffusion 3 on your own machine with ComfyUI

6/14/2024

This post details how to run Stable Diffusion 3 locally using ComfyUI, building upon existing image generation capabilities. It provides a technical guide including installation of Cog, cloning a specific ComfyUI repository, and executing commands to set up and run the environment. It also includes instructions for loading a pre-defined SD3 workflow and generating images.

2023

Generate images in one second on your Mac using a latent consistency model

10/25/2023

This post details the local setup and execution of Latent Consistency Models (LCMs) on Mac hardware (M1/M2 chips). It explains the underlying principle of LCMs being distilled from Stable Diffusion to achieve faster image generation with fewer steps (4-8 vs 25-50). The post provides prerequisites, Python setup instructions, repository cloning, dependency installation within a virtual environment, and command-line examples for generating images. It also includes performance benchmarks based on RAM and chip configurations and encourages community sharing of benchmarks.

Run SDXL with an API

7/26/2023

This post details how to run SDXL 1.0, a new text-to-image model by Stability AI, via an API. It covers generating images from prompts, image-to-image transformations, inpainting using masks, and utilizing a refiner model for enhanced detail. The post provides code examples using Replicate's client libraries for Node.js and highlights the cost-effectiveness compared to self-hosting GPUs. It also explains different refiner modes ('expert_ensemble_refiner' and 'base_image_refiner') and parameters like `prompt_strength` for image-to-image generation and `mask` for inpainting.

2022

Run Stable Diffusion on your M1 Mac’s GPU

8/31/2022

This post provides a technical guide for running Stable Diffusion locally on M1/M2 Macs, detailing prerequisites, Python setup, repository cloning, dependency installation (including necessary Homebrew packages like Cmake, protobuf, and rust), and downloading model weights. It also includes instructions on how to execute the model and points to further resources for advanced usage and integration with Replicate's API.

Exploring text to image models

7/18/2022

This post details how Replicate allows users to programmatically generate images from text using their API. It covers generating an image from a text prompt, enhancing an existing image with a super-resolution model, and creating variations of an image by using an init image and prompt. It also covers API usage details such as installing the Python client, logging in with an API token, and using the `.predict` method with various parameters like `seed`, `guidance_scale`, `total_steps`, `init_skip_fraction`, and `batch_size`.

Constraining CLIPDraw

5/27/2022

This post details an engineer's journey adapting the CLIPDraw model to constrain its output to the center of the canvas. The core technical contributions include: 1. Understanding and debugging PyTorch gradient flow issues when implementing custom loss functions. 2. Implementing vectorized operations on tensors for efficient distance calculations from the canvas center. 3. Iteratively refining the loss function to balance prompt similarity with spatial constraints, including introducing a differentiable approximation of a piecewise function to penalize points outside a defined radius, moving from a procedural to a differentiable approach.