Home

Awesome

InteractDiffusion: Interaction-Control for Text-to-Image Diffusion Model

Jiun Tian Hoe, Xudong Jiang, Chee Seng Chan, Yap Peng Tan, Weipeng Hu

Project Page | paper | arXiv | WebUI | Demo | Video | Diffuser | Colab

Paper Page Views Count Hugging Face Open In Colab

Teaser figure

<!-- [![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/Uunzufq8m6Y/0.jpg)](https://youtu.be/Uunzufq8m6Y) -->

News

Results

<table> <thead> <tr> <th rowspan="2">Model</th> <th colspan="2">Interaction Controllability</th> <th rowspan="2">FID</th> <th rowspan="2">KID</th> </tr> <tr> <th>Tiny</th> <th>Large</th> </tr> </thead> <tbody> <tr> <td>v1.0</td> <td>29.53</td> <td>31.56</td> <td>18.69</td> <td>0.00676</td> </tr> <tr> <td>v1.1</td> <td>30.20</td> <td>31.96</td> <td>17.90</td> <td>0.00635</td> </tr> <tr> <td>v1.2</td> <td>30.73</td> <td>33.10</td> <td>17.32</td> <td>0.00585</td> </tr> <tr> <td>XLv1.0</td> <td>--</td> <td>35.60</td> <td>16.65</td> <td>0.00560</td> </tr> </tbody> </table>

Interaction Controllability is measured using FGAHOI detection score. In this table, we measure the Full subset in Default setting on Swin-Tiny and Swin-Large backbone. More details on the protocol is in the paper.

Download InteractDiffusion models

We provide three checkpoints with different training strategies.

VersionDatasetSDDownload
v1.0HICO-DETv1.4HF Hub
v1.1HICO-DETv1.5HF Hub
v1.2HICO-DET + VisualGenomev1.5HF Hub
XLv1.0HICO-DETXLcoming soon

Note that the experimental results in our paper is referring to v1.0.

Extension for AutomaticA111's Stable Diffusion WebUI

We develop an AutomaticA111's Stable Diffuion WebUI extension to allow the use of InteractDiffusion over existing SD models. Check out the plugin at sd-webui-interactdiffusion. Note that it is still on alpha version.

Gallery

Some examples generated with InteractDiffusion, together with other DreamBooth and LoRA models.

    
image (7)image (5)image (6)image (4)
cuteyukimix_1cuteyukimix_7darksushimix_1toonyou_6
image (8)cuteyukimix_4darksushimix_5rcnzcartoon_1

Diffusers

from diffusers import DiffusionPipeline
import torch

pipeline = DiffusionPipeline.from_pretrained(
    "interactdiffusion/diffusers-v1-2",
    trust_remote_code=True,
    variant="fp16", torch_dtype=torch.float16
)
pipeline = pipeline.to("cuda")

images = pipeline(
    prompt="a person is feeding a cat",
    interactdiffusion_subject_phrases=["person"],
    interactdiffusion_object_phrases=["cat"],
    interactdiffusion_action_phrases=["feeding"],
    interactdiffusion_subject_boxes=[[0.0332, 0.1660, 0.3359, 0.7305]],
    interactdiffusion_object_boxes=[[0.2891, 0.4766, 0.6680, 0.7930]],
    interactdiffusion_scheduled_sampling_beta=1,
    output_type="pil",
    num_inference_steps=50,
    ).images

images[0].save('out.jpg')

Reproduce & Evaluate

  1. Change ckpt.pth in interence_batch.py to selected checkpoint.

  2. Made inference on InteractDiffusion to synthesis the test set of HICO-DET based on the ground truth.

    python inference_batch.py --batch_size 1 --folder generated_output --seed 489 --scheduled-sampling 1.0 --half
    
  3. Setup FGAHOI at ../FGAHOI. See FGAHOI repo on how to setup FGAHOI and also HICO-DET dataset in data/hico_20160224_det.

  4. Prepare for evaluate on FGAHOI. See id_prepare_inference.ipynb

  5. Evaluate on FGAHOI.

    python main.py --backbone swin_tiny --dataset_file hico --resume weights/FGAHOI_Tiny.pth --num_verb_classes 117 --num_obj_classes 80 --output_dir logs  --merge --hierarchical_merge --task_merge --eval --hoi_path data/id_generated_output --pretrain_model_path "" --output_dir logs/id-generated-output-t
    
  6. Evaluate for FID and KID. We recommend to resize hico_det dataset to 512x512 before perform image quality evaluation, for a fair comparison. We use torch-fidelity.

    fidelity --gpu 0 --fid --isc --kid --input2 ~/data/hico_det_test_resize  --input1 ~/FGAHOI/data/data/id_generated_output/images/test2015
    
  7. This should provide a brief overview of how the evaluation process works.

Training

  1. Prepare the necessary dataset and pretrained models, see DATA

  2. Run the following command:

    CUDA_VISIBLE_DEVICES=0,1 torchrun --nproc_per_node=2 main.py --yaml_file configs/hoi_hico_text.yaml --ckpt <existing_gligen_checkpoint> --name test --batch_size=4 --gradient_accumulation_step 2 --total_iters 500000 --amp true --disable_inference_in_training true --official_ckpt_name <existing SD v1.4/v1.5 checkpoint>
    

TODO

Citation

@InProceedings{Hoe_2024_CVPR,
    author    = {Hoe, Jiun Tian and Jiang, Xudong and Chan, Chee Seng and Tan, Yap-Peng and Hu, Weipeng},
    title     = {InteractDiffusion: Interaction Control in Text-to-Image Diffusion Models},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    month     = {June},
    year      = {2024},
    pages     = {6180-6189}
}

Acknowledgement

This work is developed based on the codebase of GLIGEN and LDM.