Code Monkey home page Code Monkey logo

detector-guidance's Introduction

Detector Guidance for Multi-Object Text-to-Image Generation

This repo is the official PyTorch implementation for Detector Guidance for Multi-Object Text-to-Image Generation

by Luping Liu1, Zijian Zhang1, Yi Ren2, Rongjie Huang1, Zhou Zhao1.

1Zhejiang University, 2ByteDance

In this work, we introduce Detector Guidance (DG), which integrates a latent object detection model to separate different objects during the generation process. More precisely, DG first performs latent object detection on cross-attention maps (CAMs) to obtain object information. Based on this information, DG then masks conflicting prompts and enhances related prompts by manipulating the following CAMs. Human evaluations demonstrate that DG provides an 8-22% advantage in preventing the amalgamation of conflicting concepts and ensuring that each object possesses its unique region without any human involvement and additional iterations.

  • Compare with the existing large text-to-image models.

  • Compare with the existing training-free correction methods.

    Our detector guidance offers a superior global understanding. What's more, since DG is utilized in the last 80% timestep and A&E or D&B are mainly applied in the first 20% timestep, they can be seamlessly integrated together.

Sampling

Please first prepare the environment and download the checkpoints.

bash init.sh

We offer two versions of sampling code: stable diffusion and diffusers.

  • stable diffusion: please use sample_mto.py.
python3 sample_mto.py --sd_type 'sd2.1' --prompt 'a white cat and a brown dog'
  • Use diffusers: please use sample.py.
python3 sample.py --model 'dg' --prompt 'a white cat and a brown dog' --seed 666

training

We offer our training code in train_mto.py.

bash train_mto.sh

References

If you find this work useful for your research, please consider citing:

@misc{liu2023detector,
      title={Detector Guidance for Multi-Object Text-to-Image Generation}, 
      author={Luping Liu and Zijian Zhang and Yi Ren and Rongjie Huang and Zhou Zhao},
      year={2023},
      eprint={2306.02236},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

detector-guidance's People

Contributors

luping-liu avatar

Stargazers

nA1i avatar Enes Sadık Özbek avatar  avatar Lévy飞鸟 avatar Said avatar HYUN PARK avatar  avatar 猫猫爱吃小鱼 avatar  avatar 蜡笔小旧 avatar  avatar kai wang avatar  avatar Zhenhui Ye avatar

Watchers

Kostas Georgiou avatar  avatar  avatar

Forkers

peikalunci

detector-guidance's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.