main.py— training / full-pipeline entry (class:DQNindqn.py)inference.py— inference engine (class:InferenceEngine)env_fixed_state_length.py— environment / layout generator (class:LayoutGenerator)model.py— neural network model (class:DQN_Agent_Transformer_GAT_PRE)dqn.py— RL agent implementation and training loopdataset/— place training / evaluation datasets herebase_model/— small pretrained base models used by the environmentparam/— trained model parameter fileslogs/— logs are written here during runshuman_voting_data/— human evaluation data and results
- Python 3.8+
- PyTorch (matching your CUDA if using GPU)
- Other Python packages listed in
requirements.txt
- Create and activate a new Python environment using conda:
conda create -n drl_env python=3.12
conda activate drl_env- Install pytorch. See https://pytorch.org/get-started/previous-versions/ for the correct command based on your system and CUDA version. Example for CUDA 12.4:
pip install torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cu124or for CPU-only:
pip install torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cpu- Install other dependencies:
pip install -r requirements.txt- Switch to the repository root and install fonts for generate image:
cd path/to/DRIP
conda activate drl_env
python utils/install_fonts.pyNote: torch-geometric installation may require additional platform-specific steps. See the official instructions at https://pytorch-geometric.readthedocs.io.
All commands assume you are inside the repository root on a Windows/Linux machine and have a Python environment activated.
- Training
-
Edit configuration in
main.pyor pass your own config before running.Important: adjust
worker_numinmain.pyto match your CPU/GPU parallel capabilities. Largerworker_numincreases parallelism but also memory/CPU usage. -
Run training:
python main.pyTraining will create log folders under the configured log_dir and save model parameters under the configured parameter path (see CONFIG in main.py).
- Inference
There are two ways to run inference:
- Set
modeto"predict"in theCONFIGdictionary inmain.py(default is"train") - Run inference:
python main.py-
Logs and results are written under the configured
log_dir(default:"./logs/<timestamp>/") -
(Optional) Configure the following parameters in
CONFIG:dataset_path: Path to your input dataset (default:"./dataset/data_eval/")para_path: Path to your trained model parameters (default:"net_param")base_model_path: Path to the base model folder (default:"./base_model")worker_num: Number of parallel workers for faster inference (default:8)
- Run inference:
python inference.py-
Results are written under
./logs/<timestamp>/ -
(Optional) Update the
model_pathandbase_model_pathvariables near the bottom ofinference.py
Note: Method 1 (main.py) supports multi-threaded inference with configurable worker_num, which is significantly faster on large datasets. Method 2 (inference.py) is single-threaded and suitable for small datasets.
-
main.py
CONFIG:worker_num: number of parallel workers for environment simulation. Increase on systems with more CPU cores and sufficient memory.lr_max,lr_min,batch_size, etc.: hyperparameters for training.log_dirandpara_path: control where logs and parameters are saved.
-
inference.py:
model_path: path to the saved model weights (change to your trained.pthfile).base_model_path: path to thebase_modelfolder used by the environment.
The QwenVL baseline inference uses QwenVL 7B model with LoRA adapter for architectural layout generation. This is an optional feature that requires a separate conda environment. The main DRIP inference pipeline works independently without QwenVL dependencies.
The QwenVL baseline is designed to be completely decoupled from the main codebase:
Main DRIP Environment QwenVL Baseline Environment (Optional)
├── Main inference pipeline ├── generator_VLM.py
├── env_fixed_state_length.py ├── utils/make_dataset.py
│ └── Core methods └── Qwen2.5-VL model
└── No QwenVL imports required
conda create -n qwenvl python=3.12
conda activate qwenvlSee https://pytorch.org/get-started/previous-versions/ for the correct command based on your system and CUDA version. Example for CUDA 12.4:
pip install torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cu124pip install -r requirements_qwen.txtThe requirements_qwen.txt file includes:
- All main DRIP_NCv0 dependencies
- QwenVL-specific dependencies:
transformers- For Qwen2.5-VL model loadingpeft- For LoRA adapter supportqwen-vl-utils- For vision processing utilitiestqdm- Progress barsPillow- For image processing
Download the Qwen2.5-VL-7B-Instruct model weights from Hugging Face:
# Download the model using huggingface-cli
huggingface-cli download Qwen/Qwen2.5-VL-7B-Instruct --local-dir ./base_model/Qwen2.5-VL-7B-Instruct --local-dir-use-symlinks False --resume-downloadAlternatively, you can manually download the model from https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct or mirror website and place it in ./base_model/Qwen2.5-VL-7B-Instruct/.
Place the finetuned model files in the following structure:
DRIP_NCv0/
└── base_model/
├── Qwen2.5-VL-7B-Instruct/
│ ├── config.json
│ ├── model-00001-of-00003.safetensors
│ └── ...
└── lora_model/
├── adapter_config.json
└── adapter_model.safetensors
The inference mode is controlled by the inference_mode variable in generator_VLM.py:
"single": Run inference on a single file"full": Run inference on all Excel files in the dataset directory (default)
Set inference_mode = "single" and configure the input file path:
inference_mode = "single"
path_in = "./dataset/data_eval/" # Dataset path
file = "0.xlsx" # Input file nameThen run:
python generator_VLM.pySet inference_mode = "full" (default) to run inference on all Excel files in the dataset directory and its subdirectories:
inference_mode = "full"
path_in = "./dataset/data_eval/" # Dataset pathThen run:
python generator_VLM.pyResults will be saved to ./logs/YYYY_MM_DD_HH_MM_SS/.
-
Chinese Prompts: The prompt text remains in Chinese as it was used during model fine-tuning. Only code comments are in English.
-
GPU Required: QwenVL inference requires CUDA-enabled GPU.
See LICENSE file for details.
This repository contains code for training and inference, with a minimal dataset to reproduce key results. Full dataset and training pipeline will be released after further IP protection.
For issues, please open an issue in this repository with reproducible steps and the relevant log files found under logs/.