- Description
- Installing ESRGAN and/or SFTGAN
- Usage for inference/upscaling with ESRGAN and/or SFTGAN
- Usage for training ESRGAN and/or SFTGAN
- Troubleshooting
- Requirements
The included scripts are for preparing your images to be used by ESRGAN, SFTGAN etc. and ressassemble them (no seams)
Note: Will only work on power of 2 sized textures at the moment
Note: When .
is mentioned before a path, it means relative to the ctp-texture-upscale
directory
step1_create_tiles.sh
: Create tiles with overlap, separating the RGB and alpha, with optional rescaling
step2_copy_tiles.sh
: Copy tiles from one directory to the next, with optional rescaling while copying
step3_assemble_tiles.sh
: Reassemble tiles and use the overlap for blending (to remove seams), recombine the RGB and alpha, with optional rescaling
training/step1_create_tiles.sh
: Create equal size tiles (1 for HR/GT, 1 downscaled for LR), separating the RGB and alpha, use separate directories according to regexp
training/step2_cleanup_tiles.sh
: Cleanup tiles, remove tiles that have too little colors and/or that do not fit the required size for HR/GT and LR
training/step3_select_tiles.sh
: Select tiles according to a specified percentage to be used for training and validation
- Install ESRGAN to
./esrgan
- Follow the instructions for installing ESRGAN at: https://github.com/xinntao/ESRGAN
- Install SFTGAN to
./sftgan
- Follow the instructions for installing SFTGAN at: https://github.com/xinntao/SFTGAN
- Install BasicSR to
./basicsr
- Follow the instructions for installing BasicSR at: https://github.com/xinntao/BasicSR
- Put all the textures you want to process inside the
./input
directory ./step1_create_tiles.sh --output-dir="./esrgan/LR"
pushd ./esrgan/; python3 test.py ./models/RRDB_ESRGAN_x4.pth; popd
(Replace model path if you want)./step3_assemble_tiles.sh --input-dir="./esrgan/results" --input-postfix="_rlt"
- Results will be inside
./output
- Put all the textures you want to process inside the
./input
directory ./step1_create_tiles.sh --output-dir="sftgan/data/samples" --resize="200%"
(SFTGAN requires you to upscale first)pushd ./sftgan/pytorch_test/; python3 test_segmentation.py; popd
pushd ./sftgan/pytorch_test/; python3 test_sftgan.py; popd
./step3_assemble_tiles.sh --input-dir="./sftgan/data/samples_result" --input-postfix="_rlt"
- Results will be inside
./output
- Put all the textures you want to process inside the
./input
directory ./step1_create_tiles.sh --output-dir="./esrgan/LR"
pushd ./esrgan/; python3 test.py ./models/RRDB_ESRGAN_x4.pth; popd
(Replace model path if you want)./step2_copy_tiles.sh --input-dir="./esrgan/results" --output-dir"./sftgan/data/samples" --input-postfix="_rlt"
pushd ./sftgan/pytorch_test/; python3 test_segmentation.py; popd
pushd ./sftgan/pytorch_test/; python3 test_sftgan.py; popd
./step3_assemble_tiles.sh --input-dir="./sftgan/data/samples_result" --input-postfix="_rlt"
- Results will be inside
./output
- Put all the textures you want to process inside the
./input
directory ./step1_create_tiles.sh --output-dir="./sftgan/data/samples" --resize="200%"
(SFTGAN requires you to upscale first)pushd ./sftgan/pytorch_test/; python3 test_segmentation.py; popd
pushd ./sftgan/pytorch_test/; python3 test_sftgan.py; popd
./step2_copy_tiles.sh --input-dir="./sftgan/data/samples_result" --output-dir="./esrgan/LR" --input-postfix="_rlt"
pushd ./esrgan/; python3 test.py ./models/RRDB_ESRGAN_x4.pth; popd
(Replace model path if you want)./step3_assemble_tiles.sh --input-dir="./esrgan/results" --input-postfix="_rlt"
- Results will be inside
./output
Note: Try out different combinations of settings, use ./<script>.sh --help
Note: Upscaling the textures before running SFT may give better results
Note: Everything works much better on Linux
- Put all textures you want to use for training in
./training/input
- Go to the
./training
directory ./step1_create_tiles.sh
- Results will be inside
./training/output
./step2_cleanup_tiles.sh
./step3_select_tiles.sh
- End result will be inside
./training/output_training
and./training/output_validation
- Go to
<basicsr path>/codes
and modify theoptions/train/train_ESRGAN.json
file as follows:- Change the
name
to something else that has nodebug
in it. - In
train
you may want to decrease then_workers
andbatch_size
values to for ex.: 4 and 8 - In
train
point thedataroot_LR
to<path>/training/output_training/LR
- In
train
point thedataroot_HR
to<path>/training/output_training/HR
- In
val
point thedataroot_LR
to<path>/training/output_validation/LR
- In
val
point thedataroot_HR
to<path>/training/output_validation/HR
- In
path
changeroot
to the folder where BasicSR is installed - In
path
you may have to removeresume_state
for now
- Change the
- In
<basicsr path>/codes
run the following:python3 train.py -opt options/train/train_ESRGAN.json
- Results will be inside
<basicsr path>/experiments
, after every X iterations it will write some validation results - If you are happy with the validation results you can stop the training using Ctrl+C
- If you want to continue training make sure that in
train_ESRGAN.json
theresume_state
is set inpath
pointing to the state file<basicsr path>/experiments/<name>/training_state/<state file>.state
you want to continue training from
- You may have to increase some of the values in Image Magick's
policy.xml
file to allow for more memory to be used. - If Image Magick keeps complaining about memory limits you can comment out the
resource
lines inpolicy.xml
- Bash (if you do not have Linux you can try the Git for Window's Bash instead)
- Image Magick
- Cuda (optional, but recommended if you have an NVidia) (On Linux you can just install the latest NVidia drivers)
- ESRGAN: https://github.com/xinntao/ESRGAN
- SFTGAN: https://github.com/xinntao/SFTGAN
- Python 3 64-bit
- PyTorch
- Python modules: numpy opencv-python torchvision tensorboardX lmdb
- BasicSR: https://github.com/xinntao/BasicSR/