first commit

This commit is contained in:
Guocheng Qian
2023-08-02 19:51:43 -07:00
parent c2891c38cc
commit 13e18567fa
202 changed files with 43362 additions and 17 deletions

View File

@@ -0,0 +1,6 @@
topdir=$1
imagename=$2 # rgba.png or image.png
for i in $topdir/*; do
echo preprocessing "$i"/$imagename ...
python scripts/preprocess_image.py "$i"/$imagename
done

75
scripts/magic123/run_2dprior.sh Executable file
View File

@@ -0,0 +1,75 @@
#! /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
RUN_ID2=$3
DATA_DIR=$4
IMAGE_NAME=$5
step1=$6
step2=$7
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 <token>" \
--sd_version 1.5 \
--image ${DATA_DIR}/${IMAGE_NAME} \
--learned_embeds_path ${DATA_DIR}/learned_embeds.bin \
--workspace out/magic123-2d/magic123-2d-${RUN_ID}-coarse/$dataset/magic123_2d_${FILENAME}_${RUN_ID}_coarse \
--optim adam \
--iters 5000 \
--guidance SD \
--lambda_guidance 1 \
--guidance_scale 100 \
--latent_iter_ratio 0 \
--normal_iter_ratio 0.2 \
--t_range 0.2 0.6 \
--bg_radius -1 \
--save_mesh \
${@:8}
fi
if (( ${step2} )); then
CUDA_VISIBLE_DEVICES=$1 python main.py -O \
--text "A high-resolution DSLR image of <token>" \
--sd_version 1.5 \
--image ${DATA_DIR}/${IMAGE_NAME} \
--learned_embeds_path ${DATA_DIR}/learned_embeds.bin \
--workspace out/magic123-2d/magic123-2d-${RUN_ID}-${RUN_ID2}/$dataset/magic123_2d_${FILENAME}_${RUN_ID}_${RUN_ID2} \
--dmtet --init_ckpt out/magic123-2d/magic123-2d-${RUN_ID}-coarse/$dataset/magic123_2d_${FILENAME}_${RUN_ID}_coarse/checkpoints/magic123_2d_${FILENAME}_${RUN_ID}_coarse.pth \
--iters 5000 \
--optim adam \
--latent_iter_ratio 0 \
--guidance SD \
--lambda_guidance 1e-3 \
--guidance_scale 100 \
--rm_edge \
--bg_radius -1 \
--save_mesh
fi

View File

@@ -0,0 +1,73 @@
#! /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
RUN_ID2=$3
DATA_DIR="data/demo/ironman"
IMAGE_NAME="rgba.png"
step1=$4
step2=$5
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 a full body ironman" \
--sd_version 1.5 \
--image ${DATA_DIR}/${IMAGE_NAME} \
--workspace out/magic123-2d-noinv/magic123-2d-noinv-${RUN_ID}-coarse/$dataset/magic123-2d-noinv_${FILENAME}_${RUN_ID}_coarse \
--optim adam \
--iters 5000 \
--guidance SD \
--lambda_guidance 1 \
--guidance_scale 100 \
--latent_iter_ratio 0 \
--normal_iter_ratio 0.2 \
--t_range 0.2 0.6 \
--bg_radius -1 \
--save_mesh \
${@:6}
fi
if (( ${step2} )); then
CUDA_VISIBLE_DEVICES=$1 python main.py -O \
--text "A high-resolution DSLR image of a full body ironman" \
--sd_version 1.5 \
--image ${DATA_DIR}/${IMAGE_NAME} \
--workspace out/magic123-2d-noinv/magic123-2d-noinv-${RUN_ID}-${RUN_ID2}/$dataset/magic123-2d-noinv_${FILENAME}_${RUN_ID}_${RUN_ID2} \
--dmtet --init_ckpt out/magic123-2d-noinv/magic123-2d-noinv-${RUN_ID}-coarse/$dataset/magic123-2d-noinv_${FILENAME}_${RUN_ID}_coarse/checkpoints/magic123-2d-noinv_${FILENAME}_${RUN_ID}_coarse.pth \
--iters 5000 \
--optim adam \
--latent_iter_ratio 0 \
--guidance SD \
--lambda_guidance 1e-3 \
--guidance_scale 100 \
--rm_edge \
--bg_radius -1 \
--save_mesh
fi

73
scripts/magic123/run_3dprior.sh Executable file
View File

@@ -0,0 +1,73 @@
#! /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
RUN_ID2=$3
DATA_DIR=$4
IMAGE_NAME=$5
step1=$6
step2=$7
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" \
--sd_version 1.5 \
--image ${DATA_DIR}/${IMAGE_NAME} \
--workspace out/magic123-3d/magic123-3d-${RUN_ID}/$dataset/magic123-3d_${FILENAME}_${RUN_ID}_5k \
--optim adam \
--iters 5000 \
--guidance zero123 \
--lambda_guidance 40 \
--guidance_scale 5 \
--latent_iter_ratio 0 \
--normal_iter_ratio 0.2 \
--t_range 0.2 0.6 \
--bg_radius -1 \
--save_mesh \
${@:8}
fi
if (( ${step2} )); then
CUDA_VISIBLE_DEVICES=$1 python main.py -O \
--text "A high-resolution DSLR image" \
--sd_version 1.5 \
--image ${DATA_DIR}/${IMAGE_NAME} \
--workspace out/magic123-3d/magic123-3d-${RUN_ID}-${RUN_ID2}/$dataset/magic123-3d_${FILENAME}_${RUN_ID}_${RUN_ID2} \
--dmtet --init_ckpt out/magic123-3d/magic123-3d-${RUN_ID}/$dataset/magic123-3d_${FILENAME}_${RUN_ID}_5k/checkpoints/magic123-3d_${FILENAME}_${RUN_ID}_5k.pth \
--iters 5000 \
--optim adam \
--latent_iter_ratio 0 \
--guidance zero123 \
--lambda_guidance 0.01 \
--guidance_scale 5 \
--bg_radius -1 \
--rm_edge \
--save_mesh
fi

View File

@@ -0,0 +1,76 @@
#! /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 # 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
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 <token>" \
--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 \
${@:8}
fi
if (( ${step2} )); then
CUDA_VISIBLE_DEVICES=$1 python main.py -O \
--text "A high-resolution DSLR image of <token>" \
--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
fi

View File

@@ -0,0 +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
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}
done

View File

@@ -0,0 +1,25 @@
device=$1
runid=$2 # jobname for the first stage
runid2=$3 # jobname for the second stage
imagename=$4
step1=$5
step2=$6
examples=(
'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'
)
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}
done