|
#!/bin/sh |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ls /usr/local/cuda* |
|
|
|
|
|
bg_scale=$1 |
|
bg_detemined=$2 |
|
hard=False |
|
if [ "$1" != "" ]; then |
|
if [ $1 > 0 ]; then |
|
hard=True |
|
fi |
|
fi |
|
|
|
|
|
size=$3 |
|
|
|
|
|
angle=$4 |
|
|
|
|
|
tot_steps=100 |
|
step=$5 |
|
skip_step=`expr $tot_steps - $step` |
|
|
|
|
|
num_of_Images=$6 |
|
|
|
|
|
cd object_removal/TFill/ |
|
python test.py \ |
|
--name imagenet \ |
|
--img_file ../../tmp/img/ \ |
|
--mask_file ../../tmp/mask/ \ |
|
--results_dir ../../results \ |
|
--model tc \ |
|
--coarse_or_refine refine \ |
|
--gpu_id 0 \ |
|
--no_shuffle \ |
|
--batch_size 1 \ |
|
--preprocess scale_shortside \ |
|
--mask_type 3 \ |
|
--load_size 512 \ |
|
--attn_G \ |
|
--add_noise |
|
|
|
cd ../../ |
|
mv results/imagenet/test_latest/img_ref_out/input_0.png results/object_removal.png |
|
rm -rf results/imagenet/ |
|
|
|
|
|
python resize_obj.py --img_path tmp/img/input.JPEG --mask_path tmp/mask/input.png --scale $size |
|
|
|
if [ "$2" != "" ]; then |
|
bg_path=$bg_detemined |
|
else |
|
bg_path="../results/object_removal.png" |
|
fi |
|
|
|
echo "Background path: " echo $bg_path |
|
echo "Steps: " echo $step |
|
echo "Object pixel rate: " echo $size |
|
echo "Object angle: " echo $angle |
|
|
|
|
|
cd editing_diffusion |
|
if [ $1 > 0 ]; then |
|
CUDA_VISIBLE_DEVICES=0 python main.py -p "test.JPEG" -i $bg_path -i2 "../results/img_rescaled.png" --mask "../results/mask_rescaled.png" --output_path "../tmp" --batch_size 1 --skip_timesteps $skip_step --invert_mask --clip_guidance_lambda 0 --classifier_scale 0. --y 0 --final_save_root "../results/" --rotate_obj --angle $angle --background_complex $bg_scale --hard --iterations_num $num_of_Images |
|
else |
|
CUDA_VISIBLE_DEVICES=0 python main.py -p "test.JPEG" -i $bg_path -i2 "../results/img_rescaled.png" --mask "../results/mask_rescaled.png" --output_path "../tmp" --batch_size 1 --skip_timesteps $skip_step --invert_mask --clip_guidance_lambda 0 --classifier_scale 0. --y 0 --final_save_root "../results/" --rotate_obj --angle $angle --background_complex $bg_scale --iterations_num $num_of_Images |
|
fi |
|
|
|
|
|
|
|
|