{"id":13488788,"url":"https://cyberagentailab.github.io/layout-dm/","last_synced_at":"2025-03-28T01:37:54.548Z","repository":{"id":148382441,"uuid":"611164123","full_name":"CyberAgentAILab/layout-dm","owner":"CyberAgentAILab","description":"LayoutDM: Discrete Diffusion Model for Controllable Layout Generation [Inoue+, CVPR2023]","archived":false,"fork":false,"pushed_at":"2023-10-24T03:01:49.000Z","size":1001,"stargazers_count":228,"open_issues_count":2,"forks_count":26,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-11-15T07:57:44.504Z","etag":null,"topics":["cvpr2023","diffusion-models","generative-ai","layout","pytorch"],"latest_commit_sha":null,"homepage":"https://cyberagentailab.github.io/layout-dm","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CyberAgentAILab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-03-08T08:53:51.000Z","updated_at":"2024-11-13T03:21:17.000Z","dependencies_parsed_at":"2023-05-19T23:00:14.552Z","dependency_job_id":"867da5e8-6dae-4a4f-97c3-4d7ca4a4fd16","html_url":"https://github.com/CyberAgentAILab/layout-dm","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberAgentAILab%2Flayout-dm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberAgentAILab%2Flayout-dm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberAgentAILab%2Flayout-dm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberAgentAILab%2Flayout-dm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CyberAgentAILab","download_url":"https://codeload.github.com/CyberAgentAILab/layout-dm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245952957,"owners_count":20699566,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cvpr2023","diffusion-models","generative-ai","layout","pytorch"],"created_at":"2024-07-31T18:01:21.822Z","updated_at":"2025-03-28T01:37:54.543Z","avatar_url":"https://github.com/CyberAgentAILab.png","language":"Python","funding_links":[],"categories":["Layout Generation"],"sub_categories":[],"readme":"# LayoutDM: Discrete Diffusion Model for Controllable Layout Generation (CVPR2023)\nThis repository is an official implementation of the paper titled above.\nPlease refer to [project page](https://cyberagentailab.github.io/layout-dm/) or [paper](https://arxiv.org/abs/2303.08137) for more details.\n\n## Setup\nHere we describe the setup required for the model training and evaluation.\n\n### Requirements\nWe check the reproducibility under this environment.\n- Python3.7\n- CUDA 11.3\n- [PyTorch](https://pytorch.org/get-started/locally/) 1.10\n\nWe recommend using Poetry (all settings and dependencies in [pyproject.toml](pyproject.toml)).\nPytorch-geometry provides independent pre-build wheel for a *combination* of PyTorch and CUDA version (see [PyG:Installation](https://pytorch-geometric.readthedocs.io/en/latest/install/installation.html\n) for details). If your environment does not match the one above, please update the dependencies.\n\n\n### How to install\n1. Install poetry (see [official docs](https://python-poetry.org/docs/)). We recommend to make a virtualenv and install poetry inside it.\n\n```bash\ncurl -sSL https://install.python-poetry.org | python3 -\n```\n\n2. Install dependencies (it may be slow..)\n\n```bash\npoetry install\n```\n\n3. Download resources and unzip\n\n``` bash\nwget https://github.com/CyberAgentAILab/layout-dm/releases/download/v1.0.0/layoutdm_starter.zip\nunzip layoutdm_starter.zip\n```\n\nThe data is decompressed to the following structure:\n```\ndownload\n- clustering_weights\n- datasets\n- fid_weights\n- pretrained_weights\n```\n\n## Experiment\n**Important**: we find some critical errors that cannot be fixed quickly in using multiple GPUs. Please set `CUDA_VISIBLE_DEVICES=\u003cGPU_ID\u003e` to force the model use a single GPU.\n\nNote: our main framework is based on [hydra](https://hydra.cc/). It is convenient to handle dozens of arguments hierarchically but may require some additional efforts if one is new to hydra.\n\n### Demo\nPlease run a jupyter notebook in [notebooks/demo.ipynb](notebooks/demo.ipynb). You can get and render the results of six layout generation tasks on two datasets (Rico and PubLayNet).\n\n### Training\nYou can also train your own model from scratch, for example by\n\n```bash\nbash bin/train.sh rico25 layoutdm\n```\n\n, where the first and second argument specifies the dataset ([choices](src/trainer/trainer/config/dataset)) and the type of experiment ([choices](src/trainer/trainer/config/experiment)), respectively.\nNote that for training/testing, style of the arguments is `key=value` because we use hydra, unlike popular `--key value` (e.g., [argparse](https://docs.python.org/3/library/argparse.html)).\n\n### Testing\n\n```bash\npoetry run python3 -m src.trainer.trainer.test \\\n    cond=\u003cCOND\u003e \\\n    job_dir=\u003cJOB_DIR\u003e \\\n    result_dir=\u003cRESULT_DIR\u003e \\\n    \u003cADDITIONAL_ARGS\u003e\n```\n`\u003cCOND\u003e` can be: (unconditional, c, cwh, partial, refinement, relation)\n\nFor example, if you want to test the provided LayoutDM model on `C-\u003eS+P`, the command is as follows:\n```\npoetry run python3 -m src.trainer.trainer.test cond=c dataset_dir=./download/datasets job_dir=./download/pretrained_weights/layoutdm_rico result_dir=tmp/dummy_results\n```\n\nPlease refer to [TestConfig](src/trainer/trainer/hydra_configs.py#L12) for more options available.\nBelow are some popular options for \u003cADDITIONAL_ARGS\u003e\n- `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.\n- `sampling=top_p top_p=\u003cTOP_P\u003e`: use top-p sampling with p=\u003cTOP_P\u003e　instead of default sampling.\n\n### Evaluation\n```bash\npoetry run python3 eval.py \u003cRESULT_DIR\u003e\n```\n\n## Citation\n\nIf you find this code useful for your research, please cite our paper:\n\n```\n@inproceedings{inoue2023layout,\n  title={{LayoutDM: Discrete Diffusion Model for Controllable Layout Generation}},\n  author={Naoto Inoue and Kotaro Kikuchi and Edgar Simo-Serra and Mayu Otani and Kota Yamaguchi},\n  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},\n  year={2023},\n  pages={10167-10176},\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/cyberagentailab.github.io%2Flayout-dm%2F","html_url":"https://awesome.ecosyste.ms/projects/cyberagentailab.github.io%2Flayout-dm%2F","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/cyberagentailab.github.io%2Flayout-dm%2F/lists"}