• Stars
    star
    214
  • Rank 184,678 (Top 4 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 1 year ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

LayoutDM: Discrete Diffusion Model for Controllable Layout Generation [Inoue+, CVPR2023]

LayoutDM: Discrete Diffusion Model for Controllable Layout Generation (CVPR2023)

This repository is an official implementation of the paper titled above. Please refer to project page or paper for more details.

Setup

Here we describe the setup required for the model training and evaluation.

Requirements

We check the reproducibility under this environment.

We recommend using Poetry (all settings and dependencies in pyproject.toml). Pytorch-geometry provides independent pre-build wheel for a combination of PyTorch and CUDA version (see PyG:Installation for details). If your environment does not match the one above, please update the dependencies.

How to install

  1. Install poetry (see official docs). We recommend to make a virtualenv and install poetry inside it.
curl -sSL https://install.python-poetry.org | python3 -
  1. Install dependencies (it may be slow..)
poetry install
  1. Download resources and unzip
wget https://github.com/CyberAgentAILab/layout-dm/releases/download/v1.0.0/layoutdm_starter.zip
unzip layoutdm_starter.zip

The data is decompressed to the following structure:

download
- clustering_weights
- datasets
- fid_weights
- pretrained_weights

Experiment

Important: we find some critical errors that cannot be fixed quickly in using multiple GPUs. Please set CUDA_VISIBLE_DEVICES=<GPU_ID> to force the model use a single GPU.

Note: our main framework is based on hydra. It is convenient to handle dozens of arguments hierarchically but may require some additional efforts if one is new to hydra.

Demo

Please run a jupyter notebook in notebooks/demo.ipynb. You can get and render the results of six layout generation tasks on two datasets (Rico and PubLayNet).

Training

You can also train your own model from scratch, for example by

bash bin/train.sh rico25 layoutdm

, where the first and second argument specifies the dataset (choices) and the type of experiment (choices), respectively. Note that for training/testing, style of the arguments is key=value because we use hydra, unlike popular --key value (e.g., argparse).

Testing

poetry run python3 -m src.trainer.trainer.test \
    cond=<COND> \
    job_dir=<JOB_DIR> \
    result_dir=<RESULT_DIR> \
    <ADDITIONAL_ARGS>

<COND> can be: (unconditional, c, cwh, partial, refinement, relation)

For example, if you want to test the provided LayoutDM model on C->S+P, the command is as follows:

poetry run python3 -m src.trainer.trainer.test cond=c dataset_dir=./download/datasets job_dir=./download/pretrained/layoutdm_rico result_dir=tmp/dummy_results

Please refer to TestConfig for more options available. Below are some popular options for <ADDITIONAL_ARGS>

  • is_validation=true: used to evaluate the generation performance on validation set instead of test set. This must be used when tuning the hyper-parameters.
  • sampling=top_p top_p=<TOP_P>: use top-p sampling with p=<TOP_P> instead of default sampling.

Evaluation

poetry run python3 eval.py <RESULT_DIR>

Citation

If you find this code useful for your research, please cite our paper:

@inproceedings{inoue2023layout,
  title={{LayoutDM: Discrete Diffusion Model for Controllable Layout Generation}},
  author={Naoto Inoue and Kotaro Kikuchi and Edgar Simo-Serra and Mayu Otani and Kota Yamaguchi},
  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
  year={2023},
  pages={10167-10176},
}

More Repositories

1

cmaes

Python library for CMA Evolution Strategy.
Python
353
star
2

SuperNormal

[CVPR 2024] Official implementation of "SuperNormal: Neural Surface Reconstruction via Multi-View Normal Integration"
Python
127
star
3

RALF

[CVPR24 Oral] Official repository for RALF: Retrieval-Augmented Layout Transformer for Content-Aware Layout Generation
Python
93
star
4

minituna

A toy hyperparameter optimization framework intended for understanding Optuna's internal design.
Python
83
star
5

derendering-text

Jupyter Notebook
77
star
6

pointcloud2gazebo

pointcloud2gazebo is a package that allows you to create a Gazebo World from a 3D point cloud.
Python
72
star
7

canvas-vae

Implementation of CanvasVAE: Learning to Generate Vector Graphic Documents, ICCV 2021
Python
59
star
8

flex-dm

Towards Flexible Multi-modal Document Models [Inoue+, CVPR2023]
Python
54
star
9

OpenCOLE

OpenCOLE: Towards Reproducible Automatic Graphic Design Generation [Inoue+, CVPRW2024 (GDUG)]
Python
41
star
10

EBPMDB

証拠に基づく政策のための研究成果データベース
TypeScript
29
star
11

sprite-decompose

Fast Sprite Decomposition from Animated Graphics [ECCV2024]
Python
25
star
12

nav2-keepout-zone-map-creator

nav2-keepout-zone-map-creator is a tool that allows you to create a Keepout Zone map from an Occupancy Grid Map and 3D point cloud.
Python
23
star
13

webcolor

Official implementation of Generative Colorization of Structured Mobile Web Pages, WACV 2023.
Python
21
star
14

camera

19
star
15

preferentialBO

(ICML2023) Towards Practical Preferential Bayesian Optimization with Skew Gaussian Processes
Python
10
star
16

filtered-dpo

Introducing Filtered Direct Preference Optimization (fDPO) that enhances language model alignment with human preferences by discarding lower-quality samples compared to those generated by the learning model
Python
9
star
17

multipalette

Implementation of Color Recommendation for Vector Graphic Documents based on Multi-Palette Representation, WACV 2023
Jupyter Notebook
8
star
18

regularized-bon

Code of "Regularized Best-of-N Sampling to Mitigate Reward Hacking for Language Model Alignment" (2024).
Python
7
star
19

text2palette

Implementation of "Multimodal Color Recommendation for Vector Graphic Documents" ACM MM'23
Python
7
star
20

thresholded-lasso-bandit

Python
5
star
21

LCTG-Bench

LCTG Bench: LLM Controlled Text Generation Benchmark
Python
5
star
22

japanese-nli-model

This repository provides the code for Japanese NLI model, a fine-tuned masked language model.
Jupyter Notebook
4
star
23

mbr-anomaly

Code for "On the True Distribution Approximation of Minimum Bayes-Risk Decoding," NAACL 2024
Python
4
star
24

annotation-efficient-po

Code of "Annotation-Efficient Preference Optimization for Language Model Alignment"
Python
4
star
25

CM-VQVAE

Research code for the WACV2024 paper "Complementary-Contradictory Feature Regularization against Multimodal Overfitting"
Python
4
star
26

cropping-design-constraints

codes for evaluating image cropping under design constraints
Python
4
star
27

mutant-ftrl

Python
3
star
28

mcts-capacity-expansion

Python
3
star
29

camera3

CAMERA3: An Evaluation Dataset for Controllable Ad Text Generation in Japanese
3
star
30

model-based-mbr

Code of "Model-Based Minimum Bayes Risk Decoding for Text Generation" 2024
Jupyter Notebook
3
star
31

tdc-typography-generation

This repository contains codes for https://arxiv.org/abs/2309.02099
Python
3
star
32

m2wu

Python
2
star
33

diverse-mbr

Code of "Generating Diverse and High-Quality Texts by Minimum Bayes Risk Decoding" 2024
Python
2
star
34

adaptively-perturbed-md

Python
2
star
35

AdTEC

The AdTEC dataset is designed to evaluate the quality of ad texts from multiple aspects, considering practical advertising operations.
2
star
36

CondLoRA

Code for our paper "A Single Linear Layer Yields Task-Adapted Low-Rank Matrices"
Python
1
star
37

dte-ml-adjustment

Code for "Estimating Distributional Treatment Effects in Randomized Experiments: Machine Learning for Variance Reduction"
R
1
star
38

python-dte-adjustment

Jupyter Notebook
1
star
39

text2traj2text

[INLG 2024] Official repository for Text2Traj2Text: Learning-by-Synthesis Framework for Contextual Captioning of Human Movement Trajectories
Python
1
star
40

adaptive-mbr

Code of "Hyperparameter-Free Approach for Faster Minimum Bayes Risk Decoding" 2024
Python
1
star
41

DaycareCP

Code for "Stable Matchings in Practice: A Constraint Programming Approach"(Zhaohong, Sun et al., AAAI2024, Paper)
Python
1
star