A framework to perform multiple processing passes on textures in order to upscale them. This makes it easy to add new passes or iterate development on pre- and post-processing stages.
git clone --recurse-submodules https://github.com/boristsr/TextureUpscalingPipeline.git
TextureUpscaler/ESRGAN/models
All images need to be in a format that pillow can read. Preferably this is PNG so it can be lossless.
Configure settings.json with the search path and extensions to search for.
{
"searchPath": "D:/gamedata",
"extensions": [".CACHE.PNG"]
}
Run the program
python UpscaleTextures.py
When the process has finished successfully all images will be saved alongside the originals with .HIRES.extension
The purpose of this program is to tie together many processing stages that can be performed before and after the upscaling step. The implementation of each stage is defined in a few modules under TextureUpscaler directory, and the order of steps is defined in UpscaleTextures.py
The simplest way to add a new step is to add a custom function which works on a single image and can be passed to
run_processing_stage(invert_texture, images, settings)
Any function passed to run_processing_stage should take 4 parameters:
When a function completes successfully it should return True so that run_processing_stage updates the paths correctly in the pipeline.
invert_texture is a simple example used for testing the pipeline and makes a good learning example. Below you can see it.
from PIL import Image
import PIL.ImageOps
def invert_texture(inpath, outpath, workingImage, settings):
"""Inverts the colors on the texture specified"""
print("Inverting texture: " + inpath)
image = Image.open(inpath)
inverted_image = None
try:
inverted_image = PIL.ImageOps.invert(image)
except IOError:
return False
inverted_image.save(outpath)
return True