forked from alex-suspicious/OctoTex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupscale.py
50 lines (39 loc) · 1.41 KB
/
upscale.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import ai.ESRGAN.upscaler
import ai.RealESRGAN.upscaler
import config
import shutil
import os
from tqdm import tqdm
def upscaleTextures():
if( "Real" in config.upscale_model ):
ai.RealESRGAN.upscaler.upscaleAll()
else:
ai.ESRGAN.upscaler.upscaleAll()
def upscaleTextures2X():
print("Upscaling First time")
if( "Real" in config.upscale_model ):
ai.RealESRGAN.upscaler.upscaleAll()
else:
ai.ESRGAN.upscaler.upscaleAll()
isExist = os.path.exists("textures/processing/lowres")
if not isExist:
os.makedirs("textures/processing/lowres")
dirList = os.listdir("textures/processing/diffuse/")
for x in tqdm( dirList, desc="Moving diffuse to lowres..." ):
if x.endswith(".png"):
shutil.move(f"textures/processing/diffuse/{x}", f"textures/processing/lowres/{x}")
dirList = os.listdir("textures/processing/diffuse/")
for x in tqdm( dirList, desc="Moving upscaled to diffuse..." ):
if x.endswith(".png"):
shutil.move(f"textures/processing/diffuse/{x}", f"textures/processing/diffuse/{x}")
print("Upscaling second time")
if( "Real" in config.upscale_model ):
ai.RealESRGAN.upscaler.upscaleAll()
else:
ai.ESRGAN.upscaler.upscaleAll()
dirList = os.listdir("textures/processing/lowres/")
for x in tqdm( dirList, desc="Moving lowres back to diffuse..." ):
if x.endswith(".png"):
shutil.move(f"textures/processing/lowres/{x}", f"textures/processing/diffuse/{x}")
if __name__ == '__main__':
upscaleTextures()