From 6bfbbbf6a25ef9353e2ad9d3b0b9d806ca136283 Mon Sep 17 00:00:00 2001 From: Guocheng Qian Date: Thu, 10 Aug 2023 15:30:39 +0000 Subject: [PATCH] add ablation study cfgs --- .gitignore | 3 +- requirements.txt | 2 +- scripts/magic123/run_2dprior.sh | 8 +- scripts/magic123/run_3dprior.sh | 8 +- scripts/magic123/run_both_priors.sh | 8 +- scripts/magic123/run_both_priors_angle60.sh | 82 +++++++++++++++++ scripts/magic123/run_both_priors_camera.sh | 80 +++++++++++++++++ scripts/magic123/run_both_priors_nodepth.sh | 87 +++++++++++++++++++ scripts/magic123/run_both_priors_noinv.sh | 74 ++++++++++++++++ scripts/magic123/run_both_priors_nonorm.sh | 87 +++++++++++++++++++ scripts/magic123/run_both_priors_noreg.sh | 82 +++++++++++++++++ scripts/magic123/run_folder_both_priors.sh | 12 +-- scripts/magic123/run_list_both_priors.sh | 16 ++-- .../textual_inversion.sh} | 2 +- .../textual_inversion_list.sh | 13 +++ .../textural_inversion_list.sh | 13 --- 16 files changed, 536 insertions(+), 41 deletions(-) create mode 100755 scripts/magic123/run_both_priors_angle60.sh create mode 100755 scripts/magic123/run_both_priors_camera.sh create mode 100755 scripts/magic123/run_both_priors_nodepth.sh create mode 100755 scripts/magic123/run_both_priors_noinv.sh create mode 100755 scripts/magic123/run_both_priors_nonorm.sh create mode 100755 scripts/magic123/run_both_priors_noreg.sh rename scripts/{texural_inversion/textural_inversion.sh => textual_inversion/textual_inversion.sh} (96%) create mode 100644 scripts/textual_inversion/textual_inversion_list.sh delete mode 100644 scripts/texural_inversion/textural_inversion_list.sh diff --git a/.gitignore b/.gitignore index aceb1df..267f54e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,8 @@ shap_e_model_cache/* slurm_logs/ debug/ notinclude/ -scripts/snap/yamls +scripts/snap +scripts/paper # */validataion *csv diff --git a/requirements.txt b/requirements.txt index 3e6bf59..55d2c1c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -26,7 +26,7 @@ dearpygui # for stable-diffusion huggingface_hub diffusers >= 0.9.0 -accelerate # required by textural inversion +accelerate # required by textual inversion transformers # for dmtet diff --git a/scripts/magic123/run_2dprior.sh b/scripts/magic123/run_2dprior.sh index 996dc99..5a00604 100755 --- a/scripts/magic123/run_2dprior.sh +++ b/scripts/magic123/run_2dprior.sh @@ -28,9 +28,9 @@ echo "number of gpus:" $NUM_GPU_AVAILABLE RUN_ID=$2 RUN_ID2=$3 DATA_DIR=$4 -IMAGE_NAME=$5 -step1=$6 -step2=$7 +IMAGE_NAME=rgba.png +step1=$5 +step2=$6 FILENAME=$(basename $DATA_DIR) dataset=$(basename $(dirname $DATA_DIR)) echo reconstruct $FILENAME under dataset $dataset from folder $DATA_DIR ... @@ -52,7 +52,7 @@ if (( ${step1} )); then --t_range 0.2 0.6 \ --bg_radius -1 \ --save_mesh \ - ${@:8} + ${@:7} fi if (( ${step2} )); then diff --git a/scripts/magic123/run_3dprior.sh b/scripts/magic123/run_3dprior.sh index b77a9aa..b576241 100755 --- a/scripts/magic123/run_3dprior.sh +++ b/scripts/magic123/run_3dprior.sh @@ -28,9 +28,9 @@ echo "number of gpus:" $NUM_GPU_AVAILABLE RUN_ID=$2 RUN_ID2=$3 DATA_DIR=$4 -IMAGE_NAME=$5 -step1=$6 -step2=$7 +IMAGE_NAME=rgba.png +step1=$5 +step2=$6 FILENAME=$(basename $DATA_DIR) dataset=$(basename $(dirname $DATA_DIR)) echo reconstruct $FILENAME under dataset $dataset from folder $DATA_DIR ... @@ -51,7 +51,7 @@ if (( ${step1} )); then --t_range 0.2 0.6 \ --bg_radius -1 \ --save_mesh \ - ${@:8} + ${@:7} fi if (( ${step2} )); then diff --git a/scripts/magic123/run_both_priors.sh b/scripts/magic123/run_both_priors.sh index e39a1ca..b6bdd74 100755 --- a/scripts/magic123/run_both_priors.sh +++ b/scripts/magic123/run_both_priors.sh @@ -28,9 +28,9 @@ echo "number of gpus:" $NUM_GPU_AVAILABLE RUN_ID=$2 # jobname for the first stage RUN_ID2=$3 # jobname for the second stage DATA_DIR=$4 # path to the directory containing the images, e.g. data/nerf4/chair -IMAGE_NAME=$5 # name of the image file, e.g. rgba.png -step1=$6 # whether to use the first stage -step2=$7 # whether to use the second stage +IMAGE_NAME=rgba.png # name of the image file, e.g. rgba.png +step1=$5 # whether to use the first stage +step2=$6 # whether to use the second stage FILENAME=$(basename $DATA_DIR) dataset=$(basename $(dirname $DATA_DIR)) @@ -53,7 +53,7 @@ if (( ${step1} )); then --t_range 0.2 0.6 \ --bg_radius -1 \ --save_mesh \ - ${@:8} + ${@:7} fi if (( ${step2} )); then diff --git a/scripts/magic123/run_both_priors_angle60.sh b/scripts/magic123/run_both_priors_angle60.sh new file mode 100755 index 0000000..773410c --- /dev/null +++ b/scripts/magic123/run_both_priors_angle60.sh @@ -0,0 +1,82 @@ +#! /bin/bash +#SBATCH -N 1 +#SBATCH --array=0 +#SBATCH -J magic123 +#SBATCH -o slurm_logs/%x.%3a.%A.out +#SBATCH -e slurm_logs/%x.%3a.%A.err +#SBATCH --time=3:00:00 +#SBATCH --gres=gpu:v100:1 +#SBATCH --cpus-per-gpu=6 +#SBATCH --mem=30G +##SBATCH --gpus=1 + +module load gcc/7.5.0 + + +#source ~/.bashrc +#source activate magic123 +source venv_magic123/bin/activate +which python + +nvidia-smi +nvcc --version + +hostname +NUM_GPU_AVAILABLE=`nvidia-smi --query-gpu=name --format=csv,noheader | wc -l` +echo "number of gpus:" $NUM_GPU_AVAILABLE + +RUN_ID=$2-p60 # jobname for the first stage +RUN_ID2=$3-p60 # jobname for the second stage +DATA_DIR=$4 # path to the directory containing the images, e.g. data/nerf4/chair +IMAGE_NAME=rgba.png # name of the image file, e.g. rgba.png +step1=$5 # whether to use the first stage +step2=$6 # whether to use the second stage + +FILENAME=$(basename $DATA_DIR) +dataset=$(basename $(dirname $DATA_DIR)) +echo reconstruct $FILENAME under dataset $dataset from folder $DATA_DIR ... + +if (( ${step1} )); then + CUDA_VISIBLE_DEVICES=$1 python main.py -O \ + --text "A high-resolution DSLR image of " \ + --sd_version 1.5 \ + --image ${DATA_DIR}/${IMAGE_NAME} \ + --learned_embeds_path ${DATA_DIR}/learned_embeds.bin \ + --workspace out/magic123-${RUN_ID}-coarse/$dataset/magic123_${FILENAME}_${RUN_ID}_coarse \ + --optim adam \ + --iters 5000 \ + --guidance SD zero123 \ + --lambda_guidance 1.0 40 \ + --guidance_scale 100 5 \ + --latent_iter_ratio 0 \ + --normal_iter_ratio 0.2 \ + --t_range 0.2 0.6 \ + --bg_radius -1 \ + --radius_range 1.0 1.5 \ + --fovy_range 40 70 \ + --default_polar 60 \ + --save_mesh \ + ${@:7} +fi + +if (( ${step2} )); then + CUDA_VISIBLE_DEVICES=$1 python main.py -O \ + --text "A high-resolution DSLR image of " \ + --sd_version 1.5 \ + --image ${DATA_DIR}/${IMAGE_NAME} \ + --learned_embeds_path ${DATA_DIR}/learned_embeds.bin \ + --workspace out/magic123-${RUN_ID}-${RUN_ID2}/$dataset/magic123_${FILENAME}_${RUN_ID}_${RUN_ID2} \ + --dmtet --init_ckpt out/magic123-${RUN_ID}-coarse/$dataset/magic123_${FILENAME}_${RUN_ID}_coarse/checkpoints/magic123_${FILENAME}_${RUN_ID}_coarse.pth \ + --iters 5000 \ + --optim adam \ + --latent_iter_ratio 0 \ + --guidance SD zero123 \ + --lambda_guidance 1e-3 0.01 \ + --guidance_scale 100 5 \ + --rm_edge \ + --bg_radius -1 \ + --radius_range 1.0 1.5 \ + --fovy_range 40 70 \ + --default_polar 60 \ + --save_mesh +fi \ No newline at end of file diff --git a/scripts/magic123/run_both_priors_camera.sh b/scripts/magic123/run_both_priors_camera.sh new file mode 100755 index 0000000..756790f --- /dev/null +++ b/scripts/magic123/run_both_priors_camera.sh @@ -0,0 +1,80 @@ +#! /bin/bash +#SBATCH -N 1 +#SBATCH --array=0 +#SBATCH -J magic123 +#SBATCH -o slurm_logs/%x.%3a.%A.out +#SBATCH -e slurm_logs/%x.%3a.%A.err +#SBATCH --time=3:00:00 +#SBATCH --gres=gpu:v100:1 +#SBATCH --cpus-per-gpu=6 +#SBATCH --mem=30G +##SBATCH --gpus=1 + +module load gcc/7.5.0 + + +#source ~/.bashrc +#source activate magic123 +source venv_magic123/bin/activate +which python + +nvidia-smi +nvcc --version + +hostname +NUM_GPU_AVAILABLE=`nvidia-smi --query-gpu=name --format=csv,noheader | wc -l` +echo "number of gpus:" $NUM_GPU_AVAILABLE + +RUN_ID=$2-camera # jobname for the first stage +RUN_ID2=$3-camera # jobname for the second stage +DATA_DIR=$4 # path to the directory containing the images, e.g. data/nerf4/chair +IMAGE_NAME=rgba.png # name of the image file, e.g. rgba.png +step1=$5 # whether to use the first stage +step2=$6 # whether to use the second stage + +FILENAME=$(basename $DATA_DIR) +dataset=$(basename $(dirname $DATA_DIR)) +echo reconstruct $FILENAME under dataset $dataset from folder $DATA_DIR ... + +if (( ${step1} )); then + CUDA_VISIBLE_DEVICES=$1 python main.py -O \ + --text "A high-resolution DSLR image of " \ + --sd_version 1.5 \ + --image ${DATA_DIR}/${IMAGE_NAME} \ + --learned_embeds_path ${DATA_DIR}/learned_embeds.bin \ + --workspace out/magic123-${RUN_ID}-coarse/$dataset/magic123_${FILENAME}_${RUN_ID}_coarse \ + --optim adam \ + --iters 5000 \ + --guidance SD zero123 \ + --lambda_guidance 1.0 40 \ + --guidance_scale 100 5 \ + --latent_iter_ratio 0 \ + --normal_iter_ratio 0.2 \ + --t_range 0.2 0.6 \ + --bg_radius -1 \ + --radius_range 1.0 1.5 \ + --fovy_range 40 70 \ + --save_mesh \ + ${@:7} +fi + +if (( ${step2} )); then + CUDA_VISIBLE_DEVICES=$1 python main.py -O \ + --text "A high-resolution DSLR image of " \ + --sd_version 1.5 \ + --image ${DATA_DIR}/${IMAGE_NAME} \ + --learned_embeds_path ${DATA_DIR}/learned_embeds.bin \ + --workspace out/magic123-${RUN_ID}-${RUN_ID2}/$dataset/magic123_${FILENAME}_${RUN_ID}_${RUN_ID2} \ + --dmtet --init_ckpt out/magic123-${RUN_ID}-coarse/$dataset/magic123_${FILENAME}_${RUN_ID}_coarse/checkpoints/magic123_${FILENAME}_${RUN_ID}_coarse.pth \ + --iters 5000 \ + --optim adam \ + --latent_iter_ratio 0 \ + --guidance SD zero123 \ + --lambda_guidance 1e-3 0.01 \ + --guidance_scale 100 5 \ + --rm_edge \ + --bg_radius -1 \ + --radius_range 1.0 1.5 \ + --fovy_range 40 70 \ + --save_mesh +fi \ No newline at end of file diff --git a/scripts/magic123/run_both_priors_nodepth.sh b/scripts/magic123/run_both_priors_nodepth.sh new file mode 100755 index 0000000..54c0ca4 --- /dev/null +++ b/scripts/magic123/run_both_priors_nodepth.sh @@ -0,0 +1,87 @@ +#! /bin/bash +#SBATCH -N 1 +#SBATCH --array=0 +#SBATCH -J magic123 +#SBATCH -o slurm_logs/%x.%3a.%A.out +#SBATCH -e slurm_logs/%x.%3a.%A.err +#SBATCH --time=3:00:00 +#SBATCH --gres=gpu:v100:1 +#SBATCH --cpus-per-gpu=6 +#SBATCH --mem=30G +##SBATCH --gpus=1 + +module load gcc/7.5.0 + + +#source ~/.bashrc +#source activate magic123 +source venv_magic123/bin/activate +which python + +nvidia-smi +nvcc --version + +hostname +NUM_GPU_AVAILABLE=`nvidia-smi --query-gpu=name --format=csv,noheader | wc -l` +echo "number of gpus:" $NUM_GPU_AVAILABLE + +RUN_ID=$2-nodepth # jobname for the first stage +RUN_ID2=$3-nodepth # jobname for the second stage +DATA_DIR=$4 # path to the directory containing the images, e.g. data/nerf4/chair +IMAGE_NAME=rgba.png # name of the image file, e.g. rgba.png +step1=$5 # whether to use the first stage +step2=$6 # whether to use the second stage + +FILENAME=$(basename $DATA_DIR) +dataset=$(basename $(dirname $DATA_DIR)) +echo reconstruct $FILENAME under dataset $dataset from folder $DATA_DIR ... + +if (( ${step1} )); then + CUDA_VISIBLE_DEVICES=$1 python main.py -O \ + --text "A high-resolution DSLR image of " \ + --sd_version 1.5 \ + --image ${DATA_DIR}/${IMAGE_NAME} \ + --learned_embeds_path ${DATA_DIR}/learned_embeds.bin \ + --workspace out/magic123-${RUN_ID}-coarse/$dataset/magic123_${FILENAME}_${RUN_ID}_coarse \ + --optim adam \ + --iters 5000 \ + --guidance SD zero123 \ + --lambda_guidance 1.0 40 \ + --guidance_scale 100 5 \ + --latent_iter_ratio 0 \ + --normal_iter_ratio 0.2 \ + --t_range 0.2 0.6 \ + --bg_radius -1 \ + --save_mesh \ + --lambda_entropy 1.0e-3 \ + --lambda_orient 1.0e-2 \ + --lambda_normal_smooth 0.5 \ + --lambda_normal_smooth2d 0.5 \ + --lambda_depth 0 \ + ${@:7} +fi + +if (( ${step2} )); then + CUDA_VISIBLE_DEVICES=$1 python main.py -O \ + --text "A high-resolution DSLR image of " \ + --sd_version 1.5 \ + --image ${DATA_DIR}/${IMAGE_NAME} \ + --learned_embeds_path ${DATA_DIR}/learned_embeds.bin \ + --workspace out/magic123-${RUN_ID}-${RUN_ID2}/$dataset/magic123_${FILENAME}_${RUN_ID}_${RUN_ID2} \ + --dmtet --init_ckpt out/magic123-${RUN_ID}-coarse/$dataset/magic123_${FILENAME}_${RUN_ID}_coarse/checkpoints/magic123_${FILENAME}_${RUN_ID}_coarse.pth \ + --iters 5000 \ + --optim adam \ + --latent_iter_ratio 0 \ + --guidance SD zero123 \ + --lambda_guidance 1e-3 0.01 \ + --guidance_scale 100 5 \ + --rm_edge \ + --bg_radius -1 \ + --save_mesh \ + --lambda_entropy 1.0e-3 \ + --lambda_orient 1.0e-2 \ + --lambda_normal_smooth 0.5 \ + --lambda_normal_smooth2d 0.5 \ + --dataset_size_test 8 \ + --lambda_depth 0 +fi \ No newline at end of file diff --git a/scripts/magic123/run_both_priors_noinv.sh b/scripts/magic123/run_both_priors_noinv.sh new file mode 100755 index 0000000..26cd236 --- /dev/null +++ b/scripts/magic123/run_both_priors_noinv.sh @@ -0,0 +1,74 @@ +#! /bin/bash +#SBATCH -N 1 +#SBATCH --array=0 +#SBATCH -J magic123 +#SBATCH -o slurm_logs/%x.%3a.%A.out +#SBATCH -e slurm_logs/%x.%3a.%A.err +#SBATCH --time=3:00:00 +#SBATCH --gres=gpu:v100:1 +#SBATCH --cpus-per-gpu=6 +#SBATCH --mem=30G +##SBATCH --gpus=1 + +module load gcc/7.5.0 + + +#source ~/.bashrc +#source activate magic123 +source venv_magic123/bin/activate +which python + +nvidia-smi +nvcc --version + +hostname +NUM_GPU_AVAILABLE=`nvidia-smi --query-gpu=name --format=csv,noheader | wc -l` +echo "number of gpus:" $NUM_GPU_AVAILABLE + +RUN_ID=$2-noinv # jobname for the first stage +RUN_ID2=$3-noinv # jobname for the second stage +DATA_DIR=$4 # path to the directory containing the images, e.g. data/nerf4/chair +IMAGE_NAME=rgba.png # name of the image file, e.g. rgba.png +step1=$5 # whether to use the first stage +step2=$6 # whether to use the second stage + +FILENAME=$(basename $DATA_DIR) +dataset=$(basename $(dirname $DATA_DIR)) +echo reconstruct $FILENAME under dataset $dataset from folder $DATA_DIR ... + +if (( ${step1} )); then + CUDA_VISIBLE_DEVICES=$1 python main.py -O \ + --text "A high-resolution DSLR image of " \ + --sd_version 1.5 \ + --image ${DATA_DIR}/${IMAGE_NAME} \ + --workspace out/magic123-${RUN_ID}-coarse/$dataset/magic123_${FILENAME}_${RUN_ID}_coarse \ + --optim adam \ + --iters 5000 \ + --guidance SD zero123 \ + --lambda_guidance 1.0 40 \ + --guidance_scale 100 5 \ + --latent_iter_ratio 0 \ + --normal_iter_ratio 0.2 \ + --t_range 0.2 0.6 \ + --bg_radius -1 \ + --save_mesh \ + ${@:7} +fi + +if (( ${step2} )); then + CUDA_VISIBLE_DEVICES=$1 python main.py -O \ + --text "A high-resolution DSLR image of " \ + --sd_version 1.5 \ + --image ${DATA_DIR}/${IMAGE_NAME} \ + --workspace out/magic123-${RUN_ID}-${RUN_ID2}/$dataset/magic123_${FILENAME}_${RUN_ID}_${RUN_ID2} \ + --dmtet --init_ckpt out/magic123-${RUN_ID}-coarse/$dataset/magic123_${FILENAME}_${RUN_ID}_coarse/checkpoints/magic123_${FILENAME}_${RUN_ID}_coarse.pth \ + --iters 5000 \ + --optim adam \ + --latent_iter_ratio 0 \ + --guidance SD zero123 \ + --lambda_guidance 1e-3 0.01 \ + --guidance_scale 100 5 \ + --rm_edge \ + --bg_radius -1 \ + --save_mesh +fi \ No newline at end of file diff --git a/scripts/magic123/run_both_priors_nonorm.sh b/scripts/magic123/run_both_priors_nonorm.sh new file mode 100755 index 0000000..f30fa0f --- /dev/null +++ b/scripts/magic123/run_both_priors_nonorm.sh @@ -0,0 +1,87 @@ +#! /bin/bash +#SBATCH -N 1 +#SBATCH --array=0 +#SBATCH -J magic123 +#SBATCH -o slurm_logs/%x.%3a.%A.out +#SBATCH -e slurm_logs/%x.%3a.%A.err +#SBATCH --time=3:00:00 +#SBATCH --gres=gpu:v100:1 +#SBATCH --cpus-per-gpu=6 +#SBATCH --mem=30G +##SBATCH --gpus=1 + +module load gcc/7.5.0 + + +#source ~/.bashrc +#source activate magic123 +source venv_magic123/bin/activate +which python + +nvidia-smi +nvcc --version + +hostname +NUM_GPU_AVAILABLE=`nvidia-smi --query-gpu=name --format=csv,noheader | wc -l` +echo "number of gpus:" $NUM_GPU_AVAILABLE + +RUN_ID=$2-nonorm # jobname for the first stage +RUN_ID2=$3-nonorm # jobname for the second stage +DATA_DIR=$4 # path to the directory containing the images, e.g. data/nerf4/chair +IMAGE_NAME=rgba.png # name of the image file, e.g. rgba.png +step1=$5 # whether to use the first stage +step2=$6 # whether to use the second stage + +FILENAME=$(basename $DATA_DIR) +dataset=$(basename $(dirname $DATA_DIR)) +echo reconstruct $FILENAME under dataset $dataset from folder $DATA_DIR ... + +if (( ${step1} )); then + CUDA_VISIBLE_DEVICES=$1 python main.py -O \ + --text "A high-resolution DSLR image of " \ + --sd_version 1.5 \ + --image ${DATA_DIR}/${IMAGE_NAME} \ + --learned_embeds_path ${DATA_DIR}/learned_embeds.bin \ + --workspace out/magic123-${RUN_ID}-coarse/$dataset/magic123_${FILENAME}_${RUN_ID}_coarse \ + --optim adam \ + --iters 5000 \ + --guidance SD zero123 \ + --lambda_guidance 1.0 40 \ + --guidance_scale 100 5 \ + --latent_iter_ratio 0 \ + --normal_iter_ratio 0.2 \ + --t_range 0.2 0.6 \ + --bg_radius -1 \ + --save_mesh \ + --lambda_entropy 1.0e-3 \ + --lambda_orient 1.0e-2 \ + --lambda_normal_smooth 0 \ + --lambda_normal_smooth2d 0 \ + ${@:7} +fi + +if (( ${step2} )); then + CUDA_VISIBLE_DEVICES=$1 python main.py -O \ + --text "A high-resolution DSLR image of " \ + --sd_version 1.5 \ + --image ${DATA_DIR}/${IMAGE_NAME} \ + --learned_embeds_path ${DATA_DIR}/learned_embeds.bin \ + --workspace out/magic123-${RUN_ID}-${RUN_ID2}/$dataset/magic123_${FILENAME}_${RUN_ID}_${RUN_ID2} \ + --dmtet --init_ckpt out/magic123-${RUN_ID}-coarse/$dataset/magic123_${FILENAME}_${RUN_ID}_coarse/checkpoints/magic123_${FILENAME}_${RUN_ID}_coarse.pth \ + --iters 5000 \ + --optim adam \ + --latent_iter_ratio 0 \ + --guidance SD zero123 \ + --lambda_guidance 1e-3 0.01 \ + --guidance_scale 100 5 \ + --rm_edge \ + --bg_radius -1 \ + --save_mesh \ + --lambda_entropy 1.0e-3 \ + --lambda_orient 1.0e-2 \ + --lambda_normal_smooth 0 \ + --lambda_normal_smooth2d 0 \ + --lambda_mesh_normal 1.0e-10 \ + --dataset_size_test 8 \ + --lambda_mesh_lap 0 +fi \ No newline at end of file diff --git a/scripts/magic123/run_both_priors_noreg.sh b/scripts/magic123/run_both_priors_noreg.sh new file mode 100755 index 0000000..de79be4 --- /dev/null +++ b/scripts/magic123/run_both_priors_noreg.sh @@ -0,0 +1,82 @@ +#! /bin/bash +#SBATCH -N 1 +#SBATCH --array=0 +#SBATCH -J magic123 +#SBATCH -o slurm_logs/%x.%3a.%A.out +#SBATCH -e slurm_logs/%x.%3a.%A.err +#SBATCH --time=3:00:00 +#SBATCH --gres=gpu:v100:1 +#SBATCH --cpus-per-gpu=6 +#SBATCH --mem=30G +##SBATCH --gpus=1 + +module load gcc/7.5.0 + + +#source ~/.bashrc +#source activate magic123 +source venv_magic123/bin/activate +which python + +nvidia-smi +nvcc --version + +hostname +NUM_GPU_AVAILABLE=`nvidia-smi --query-gpu=name --format=csv,noheader | wc -l` +echo "number of gpus:" $NUM_GPU_AVAILABLE + +RUN_ID=$2-noreg # jobname for the first stage +RUN_ID2=$3-noreg # jobname for the second stage +DATA_DIR=$4 # path to the directory containing the images, e.g. data/nerf4/chair +IMAGE_NAME=rgba.png # name of the image file, e.g. rgba.png +step1=$5 # whether to use the first stage +step2=$6 # whether to use the second stage + +FILENAME=$(basename $DATA_DIR) +dataset=$(basename $(dirname $DATA_DIR)) +echo reconstruct $FILENAME under dataset $dataset from folder $DATA_DIR ... + +if (( ${step1} )); then + CUDA_VISIBLE_DEVICES=$1 python main.py -O \ + --text "A high-resolution DSLR image of " \ + --sd_version 1.5 \ + --image ${DATA_DIR}/${IMAGE_NAME} \ + --learned_embeds_path ${DATA_DIR}/learned_embeds.bin \ + --workspace out/magic123-${RUN_ID}-coarse/$dataset/magic123_${FILENAME}_${RUN_ID}_coarse \ + --optim adam \ + --iters 5000 \ + --guidance SD zero123 \ + --lambda_guidance 1.0 40 \ + --guidance_scale 100 5 \ + --latent_iter_ratio 0 \ + --normal_iter_ratio 0.2 \ + --t_range 0.2 0.6 \ + --bg_radius -1 \ + --save_mesh \ + --lambda_entropy 0 \ + --lambda_orient 1.0e-10 \ + ${@:7} +fi + +if (( ${step2} )); then + CUDA_VISIBLE_DEVICES=$1 python main.py -O \ + --text "A high-resolution DSLR image of " \ + --sd_version 1.5 \ + --image ${DATA_DIR}/${IMAGE_NAME} \ + --learned_embeds_path ${DATA_DIR}/learned_embeds.bin \ + --workspace out/magic123-${RUN_ID}-${RUN_ID2}/$dataset/magic123_${FILENAME}_${RUN_ID}_${RUN_ID2} \ + --dmtet --init_ckpt out/magic123-${RUN_ID}-coarse/$dataset/magic123_${FILENAME}_${RUN_ID}_coarse/checkpoints/magic123_${FILENAME}_${RUN_ID}_coarse.pth \ + --iters 5000 \ + --optim adam \ + --latent_iter_ratio 0 \ + --guidance SD zero123 \ + --lambda_guidance 1e-3 0.01 \ + --guidance_scale 100 5 \ + --rm_edge \ + --bg_radius -1 \ + --save_mesh \ + --lambda_entropy 0 \ + --lambda_orient 1.0e-10 \ + --lambda_normal_smooth 0 \ + --lambda_normal_smooth2d 0 +fi \ No newline at end of file diff --git a/scripts/magic123/run_folder_both_priors.sh b/scripts/magic123/run_folder_both_priors.sh index f7f3bcf..648c9fd 100755 --- a/scripts/magic123/run_folder_both_priors.sh +++ b/scripts/magic123/run_folder_both_priors.sh @@ -1,13 +1,13 @@ -device=$1 -runid=$2 # jobname for the first stage -runid2=$3 # jobname for the second stage -topdir=$4 # path to the directory containing the images, e.g. data/nerf4 -imagename=$5 +script_name=$1 +device=$2 +runid=$3 # jobname for the first stage +runid2=$4 # jobname for the second stage +topdir=$5 # path to the directory containing the images, e.g. data/nerf4 step1=$6 step2=$7 for i in $topdir/*; do echo "$i" [ -d "$i" ] && echo "$i exists." - bash scripts/magic123/run_both_priors.sh $device $runid "$i" $imagename $step1 $step2 ${@:8} + bash ${script_name} $device $runid "$i" $step1 $step2 ${@:8} done diff --git a/scripts/magic123/run_list_both_priors.sh b/scripts/magic123/run_list_both_priors.sh index c4e4e64..0f95936 100755 --- a/scripts/magic123/run_list_both_priors.sh +++ b/scripts/magic123/run_list_both_priors.sh @@ -1,18 +1,18 @@ -device=$1 -runid=$2 # jobname for the first stage -runid2=$3 # jobname for the second stage -imagename=$4 +script_name=$1 +device=$2 +runid=$3 # jobname for the first stage +runid2=$4 # jobname for the second stage step1=$5 step2=$6 examples=( + 'data/nerf4/chair' + 'data/realfusion15/colorful_teapot/' 'data/realfusion15/teddy_bear/' 'data/realfusion15/mental_dragon_statue/' - 'data/realfusion15/colorful_teapot/' 'data/realfusion15/fish_real_nemo/' 'data/realfusion15/two_cherries' 'data/realfusion15/watercolor_horse/' - 'data/nerf4/chair' 'data/nerf4/drums' 'data/nerf4/ficus' 'data/nerf4/mic' @@ -21,5 +21,7 @@ examples=( for i in "${examples[@]}"; do echo "$i" [ -d "$i" ] && echo "$i exists." - bash scripts/magic123/run_both_priors.sh $device $runid "$i" $imagename $step1 $step2 ${@:7} + bash ${script_name} $device $runid $runid2 "$i" $step1 $step2 ${@:7} done + +# usage: bash scripts/magic123/run_list_both_priors.sh scripts/magic123/run_both_priors.sh 0 coarse fine 1 1 \ No newline at end of file diff --git a/scripts/texural_inversion/textural_inversion.sh b/scripts/textual_inversion/textual_inversion.sh similarity index 96% rename from scripts/texural_inversion/textural_inversion.sh rename to scripts/textual_inversion/textual_inversion.sh index 3c4c0e9..f39985d 100644 --- a/scripts/texural_inversion/textural_inversion.sh +++ b/scripts/textual_inversion/textual_inversion.sh @@ -48,5 +48,5 @@ CUDA_VISIBLE_DEVICES=$1 python textual-inversion/textual_inversion.py \ --use_augmentations \ ${@:7} -# test textural inversion +# test textual inversion CUDA_VISIBLE_DEVICES=$1 python guidance/sd_utils.py --text "A high-resolution DSLR image of " --learned_embeds_path $OUTPUT_DIR --workspace $OUTPUT_DIR \ No newline at end of file diff --git a/scripts/textual_inversion/textual_inversion_list.sh b/scripts/textual_inversion/textual_inversion_list.sh new file mode 100644 index 0000000..4d468ed --- /dev/null +++ b/scripts/textual_inversion/textual_inversion_list.sh @@ -0,0 +1,13 @@ + + +examples=( + 'data/nerf4/chair' + 'data/nerf4/drums' + 'data/nerf4/ficus' + 'data/nerf4/mic' +) + +for i in "${examples[@]}"; do + filename=$(basename "$i") + bash scripts/texural_inversion/textual_inversion.sh 0 runwayml/stable-diffusion-v1-5 "$i"/rgba.png out/texural_inversion/${filename} _nerf_${filename}_ ${filename} --max_train_steps 3000 +done \ No newline at end of file diff --git a/scripts/texural_inversion/textural_inversion_list.sh b/scripts/texural_inversion/textural_inversion_list.sh deleted file mode 100644 index da287a9..0000000 --- a/scripts/texural_inversion/textural_inversion_list.sh +++ /dev/null @@ -1,13 +0,0 @@ - - -examples=( - 'data/nerf4/chair' - 'data/nerf4/drums' - 'data/nerf4/ficus' - 'data/nerf4/mic' -) - -for i in "${examples[@]}"; do - filename=$(basename "$i") - bash scripts/texural_inversion/textural_inversion.sh 0 runwayml/stable-diffusion-v1-5 "$i"/rgba.png out/texural_inversion/${filename} _nerf_${filename}_ ${filename} --max_train_steps 3000 -done \ No newline at end of file