Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
I

IF

> 编程语言
Open source

IF by DeepFloyd Lab at StabilityAI <p align="center" </p We introduce DeepFloyd IF, a novel state-of-the-art open-source text-to-image mode…

7.8K stars0 likes2 views
WebsiteGitHub

About

IF by DeepFloyd Lab at StabilityAI <p align="center" </p We introduce DeepFloyd IF, a novel state-of-the-art open-source text-to-image mode…

IF by DeepFloyd Lab at StabilityAI

We introduce DeepFloyd IF, a novel state-of-the-art open-source text-to-image model with a high degree of photorealism and language understanding. DeepFloyd IF is a modular composed of a frozen text encoder and three cascaded pixel diffusion modules: a base model that generates 64x64 px image based on text prompt and two super-resolution models, each designed to generate images of increasing resolution: 256x256 px and 1024x1024 px. All stages of the model utilize a frozen text encoder based on the T5 transformer to extract text embeddings, which are then fed into a UNet architecture enhanced with cross-attention and attention pooling. The result is a highly efficient model that outperforms current state-of-the-art models, achieving a zero-shot FID score of 6.66 on the COCO dataset. Our work underscores the potential of larger UNet architectures in the first stage of cascaded diffusion models and depicts a promising future for text-to-image synthesis.

Inspired by Photorealistic Text-to-Image Diffusion Models with Deep Language Understanding

Minimum requirements to use all IF models:

  • 16GB vRAM for IF-I-XL (4.3B text to 64x64 base module) & IF-II-L (1.2B to 256x256 upscaler module)
  • 24GB vRAM for IF-I-XL (4.3B text to 64x64 base module) & IF-II-L (1.2B to 256x256 upscaler module) & Stable x4 (to 1024x1024 upscaler)
  • xformers and set env variable FORCE_MEM_EFFICIENT_ATTN=1

Quick Start

bash
pip install deepfloyd_if==1.0.2rc0
pip install xformers==0.0.16
pip install git+https://github.com/openai/CLIP.git --no-deps

Local notebooks

The Dream, Style Transfer, Super Resolution or Inpainting modes are avaliable in a Jupyter Notebook here.

Integration with Diffusers

IF is also integrated with the Hugging Face Diffusers library.

Diffusers runs each stage individually allowing the user to customize the image generation process as well as allowing to inspect intermediate results easily.

Example

Before you can use IF, you need to accept its usage conditions. To do so:

  1. Make sure to have a Hugging Face account and be loggin in
  2. Accept the license on the model card of DeepFloyd/IF-I-XL-v1.0
  3. Make sure to login locally. Install huggingface_hub
bash
pip install huggingface_hub --upgrade

run the login function in a Python shell

python
from huggingface_hub import login

login()

and enter your Hugging Face Hub access token.

Next we install diffusers and dependencies:

bash
pip install diffusers accelerate transformers safetensors

And we can now run the model locally.

By default diffusers makes use of model cpu offloading to run the whole IF pipeline with as little as 14 GB of VRAM.

If you are using torch>=2.0.0, make sure to delete all enable_xformers_memory_efficient_attention() functions.

…

There are multiple ways to speed up the inference time and lower the memory consumption even more with diffusers. To do so, please have a look at the Diffusers docs:

  • Optimizing for inference time
  • ⚙️ Optimizing for low memory during inference

For more in-detail information about how to use IF, please have a look at the IF blog post and the documentation .

Diffusers dreambooth scripts also supports fine-tuning IF. With parameter efficient finetuning, you can add new concepts to IF with a single GPU and ~28 GB VRAM.

Run the code locally

Loading the models into VRAM

python
from deepfloyd_if.modules import IFStageI, IFStageII, StableStageIII
from deepfloyd_if.modules.t5 import T5Embedder

device = 'cuda:0'
if_I = IFStageI('IF-I-XL-v1.0', device=device)
if_II = IFStageII('IF-II-L-v1.0', device=device)
if_III = StableStageIII('stable-diffusion-x4-upscaler', device=device)
t5 = T5Embedder(device="cpu")

I. Dream

Dream is the text-to-image mode of the IF model

…

II. Zero-shot Image-to-Image Translation

In Style Transfer mode, the output of your prompt comes out at the style of the support_pil_img

…

III. Super Resolution

For super-resolution, users can run IF-II and IF-III or 'Stable x4' on an image that was not necessarely generated by IF (two cascades):

…

IV. Zero-shot Inpainting

…

Model Zoo

The link to download the weights as well as the model cards will be available soon on each model of the model zoo

Original

Name Cascade Params FID Batch size Steps
IF-I-M I 400M 8.86 3072 2.5M
IF-I-L I 900M 8.06 3200 3.0M
IF-I-XL* I 4.3B 6.66 3072 2.42M
IF-II-M II 450M - 1536 2.5M
IF-II-L* II 1.2B - 1536 2.5M
IF-III-L* (soon) III 700M - 3072 1.25M

*best modules

Quantitative Evaluation

FID = 6.66

License

The code in this repository is released under the bespoke license (see added point two).

The weights will be available soon via the DeepFloyd organization at Hugging Face and have their own LICENSE.

Disclaimer: The initial release of the IF model is under a restricted research-purposes-only license temporarily to gather feedback, and after that we intend to release a fully open-source model in line with other Stability AI models.

Limitations and Biases

The models available in this codebase have known limitations and biases. Please refer to the model card for more information.

DeepFloyd IF creators:

  • Alex Shonenkov GitHub | Linktr
  • Misha Konstantinov GitHub | Twitter
  • Daria Bakshandaeva GitHub | Twitter
  • Christoph Schuhmann GitHub | Twitter
  • Ksenia Ivanova GitHub | Twitter
  • Nadiia Klokova GitHub | Twitter

Research Paper (Soon)

Acknowledgements

Special thanks to StabilityAI and its CEO Emad Mostaque for invaluable support, providing GPU compute and infrastructure to train the models (our gratitude goes to Richard Vencu); thanks to LAION and Christoph Schuhmann in particular for contribution to the project and well-prepared datasets; thanks to Huggingface teams for optimizing models' speed and memory consumption during inference, creating demos and giving cool advice!

External Contributors

  • The Biggest Thanks @Apolinário, for ideas, consultations, help and support on all stages to make IF available in open-source; for writing a lot of documentation and instructions; for creating a friendly atmosphere in difficult moments ;
  • Thanks, @patrickvonplaten, for improving loading time of unet models by 80%; for integration Stable-Diffusion-x4 as native pipeline ;
  • Thanks, @williamberman and @patrickvonplaten for diffusers integration ;
  • Thanks, @hysts and @Apolinário for creating the best gradio demo with IF ;
  • Thanks, @Dango233, for adapting IF with xformers memory efficient attention ;

Issues· 104 open

View all issuesOpen on GitHub
  • #54

    How to get output of Zero Shot Image To Image to match input image size?

    Updated Dec 13, 2025
  • #156

    Russian Crown

    Updated Jul 29, 2025
  • #129

    ImportError: cannot import name 'CLIPImageProcessor' from 'transformers'

    Updated Apr 1, 2025
  • #155

    Absence Justification Platform

    Updated Jan 11, 2025
  • #147

    OOM appears using DeepFloyd_IF (I use 32G video memory)

    Updated Dec 13, 2024
  • #154

    Cute little girl.

    Updated Dec 8, 2024
  • #151

    when can correlated controlnet come out

    Updated Aug 8, 2024
  • #150

    Fine Tuning

    Updated Jun 17, 2024
  • #120

    IF-III-L Model Release?

    Updated Jun 6, 2024
  • #137

    Internal: unk is not defined

    Updated Jun 4, 2024

> Tags

Python

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 1, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言