8000 GitHub - djFatNerd/CityCraft: CityCraft: A Diffusion and LLM Powered Framework for Automatic Comprehensive Virtual City Generation
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

CityCraft: A Diffusion and LLM Powered Framework for Automatic Comprehensive Virtual City Generation

Notifications You must be signed in to change notification settings

djFatNerd/CityCraft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CityCraft

This is the official codebase for CityCraft: A Diffusion and LLM Powered Framework for Automatic Comprehensive Virtual City Generation.

System Requirements

Development environment:

  • OS: Ubuntu 22.04
  • CUDA: 11.7
  • PyTorch: 2.0.1

Environment Setup

Create a new environment and install the requirements:

conda create -n citycraft python=3.10
conda activate citycraft
pip install -r requirements.txt

Prepare Datasets

a. Layout Generation Dataset

Step 1: Download osm data from "https://huggingface.co/datasets/GearlessJ333/CityCraft/tree/main" and put it in the folder "CityCraft/dataset/CityCraft_OSM/"

cd dataset
unzip layouts.zip

After this step, you will the the following structure:

CityCraft/
    dataset/
        CityCraft_OSM/
            layouts/
                1.png
                2.png
                3.png
                ...

Step 2: prepare training features

cd dataset/extract_features
python extract_ratio_features.py

This will exract latent image features and ratio features for training. After this step, you will have the following structure:

CityCraft_OSM/
    layouts/
    features/
        image_ratio_features/

b. Assets Dataset

Step 1: Download assets data from "https://huggingface.co/datasets/GearlessJ333/CityCraft/tree/main" and put it in the folder "CityCraft/dataset/city_render/"

Step 2: Unzip data and features

cd dataset/CityCraft_Buildings
unzip assets.zip

This will extract the assets data and features. After this step, you will have the following structure:

CityCraft_Buildings/
    assets/
        assets_features/
        assets_filtered/
        assets_renders/

Stage 1: Layout Generation

Inference

Step 1: Download pretrained model from "https://huggingface.co/GearlessJ333/CityCraft/tree/main" and put it in the folder "CityCraft/pretrained_models/"

Step 2: Sample from pretrained models

cd layout_generation
python sample_uncondition.py

Step 3: Post-process the generated layouts

cd layout_generation
python utils/post_process.py

Stage 2: Urban Planning

step 1 (optional): put your selected layout images in the folder "urban_planning/layouts/", and modify llm_planning.sh to set planning target and requirements.

step 2: set API key in llm_planning.sh

api_key = 'your_api_key'

You need an API key for OpenAI models, you can get one from here.

step 3: start planning

cd urban_planning
sh llm_planning.sh

After step, the plan will be generated in the folder "urban_planning/planning_result/" at the output directory you set in llm_planning.sh.

step 4: select assets

In "select_buildings.sh", set the path to the planning result you want to select assets from, then run:

sh select_buildings.sh

After this step, .pkl file containing the selected assets will be generated in the folder, for example: CityCraft/urban_planning/planning_result/layout_1/selected_buildings.pkl.

Stage 3: Blender Rendering

step 1: Download Blender Installer

Go back to the root directory CityCraft/:

mkdir Blender

Download Blender from here, please select the version that matches your operating system, and put it in the folder "CityCraft/Blender/".

(For example, we used here to install Blender 4.0.0 for our Linux x86_64 system; You can put it anywhere but just remember to set the path later when you run the rendering script.)

step 2: Install Blender

cd Blender
tar -xJvf blender-4.0.2-linux-x64.tar.xz

step 3: Download extra assets and textures

Download extra assets and textures from "https://huggingface.co/GearlessJ333/CityCraft/tree/main" and put it in the folder "CityCraft/render_scene/"

cd render_scene
unzip extra_assets.zip
unzip textures.zip

After this step, you will have the following structure:

render_scene/
    extra_assets/
    textures/

step 4: Start Rendering

Note: You need to set the path to the layout image and the selected assets pkl file in the render_scene.sh file. You also need to set the path to the Blender executable file to where you installed it.

cd render_scene
sh render_scene.sh

After this step, you will have the rendered scenes in the folder "render_scene/rendered_scenes/".

If you feel our work is helpful, please consider citing our work:

@article{deng2024citycraft,
  title={CityCraft: A Real Crafter for 3D City Generation},
  author={Deng, Jie and Chai, Wenhao and Huang, Junsheng and Zhao, Zhonghan and Huang, Qixuan and Gao, Mingyan and Guo, Jianshu and Hao, Shengyu and Hu, Wenhao and Hwang, Jenq-Neng and others},
  journal={arXiv preprint arXiv:2406.04983},
  year={2024}
}

About

CityCraft: A Diffusion and LLM Powered Framework for Automatic Comprehensive Virtual City Generation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0