-
Notifications
You must be signed in to change notification settings - Fork 0
/
png_denoiser.bat
110 lines (97 loc) · 2.73 KB
/
png_denoiser.bat
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
@ECHO off
REM win_batch_DN png_denoiser.bat v1.0.1
REM Created by jackjt8
REM https://github.com/jackjt8/win_batch_DN
REM ~~~~
REM Get and setup
REM
REM IntelOIDenoiser (CPU must support SSE4.1)
REM https://github.com/DeclanRussell/IntelOIDenoiser
REM OR
REM NvidiaAIDenoiser (Maxwell GPU or newer architecture with 418.xx or newer driver)
REM https://github.com/DeclanRussell/NvidiaAIDenoiser
REM
REM Change dn_path to the location of the denoiser.exe
REM uncomment dn_path2 if you wish to compare both denoisers.
REM
REM Drag and drop one or more .pngs onto this .bat file to denoise them.
SET dn_path="D:\Programs\oidn-Denoiser_v1.2\Denoiser.exe"
REM SET dn_path2="D:\Programs\NvAIDN_v2.4\Denoiser.exe"
:Loop
IF "%1"=="" GOTO Break
:loop
IF NOT "%~x1"==".png" GOTO PNGerror
ECHO ===
ECHO Input %~n1%~x1
ECHO Output %~n1_dn%~x1
ECHO ===
REM check input
ECHO %~n1 | FINDSTR /C:".albedo" >nul && (
ECHO ### ERROR Wrong input - expected png but got albedo
GOTO Break
)
ECHO %~n1 | FINDSTR /C:".normal" >nul && (
ECHO ### ERROR Wrong input - expected png but got normal
GOTO Break
)
ECHO %~n1 | FINDSTR /C:".denoised" >nul && (
ECHO ### ERROR Wrong input - expected png but got a denoised image
GOTO Break
)
REM check input done
DIR /b /a-d %~dp1%~n1*%~x1 > %temp%\pngFileList
FIND %temp%\pngFileList ".albedo.">nul
if errorlevel 1 (
REM missing albedo
FIND %temp%\pngFileList ".normal.">nul
if errorlevel 1 (
REM missing normal
GOTO denoise_h
) else (
REM found normal
GOTO denoise_hn
)
) else (
REM found albedo
FIND %temp%\pngFileList ".normal.">nul
if errorlevel 1 (
REM missing normal
GOTO denoise_ha
) else (
REM found normal
GOTO denoise_han
)
)
REM %dn_path% -i "%1" -o "%~n1_dn%~x1"
REM %dn_path2% -i %1 -o %~n1_dn%~x1
:postdenoise
DEL %temp%\pngFileList
SHIFT
IF NOT "%1"=="" (GOTO loop) ELSE (GOTO Break)
REM you should not end up here. If the following message shows I messed up.
ECHO ### ERROR missed postdenoise and loop/break point
GOTO Break
:denoise_h
ECHO Found png
%dn_path% -i "%1" -o "%~dp1%~n1.denoised%~x1"
GOTO postdenoise
:denoise_ha
ECHO Found png and Albedo
%dn_path% -i "%1" -o "%~dp1%~n1.denoised%~x1" -a "%~dp1%~n1.albedo%~x1"
GOTO postdenoise
:denoise_hn
ECHO ### ERROR %~1 Found normal but missing albedo?
PAUSE
GOTO Break
:denoise_han
ECHO Found png, Albedo, and Normal
%dn_path% -i "%1" -o "%~dp1%~n1.denoised%~x1" -a "%~dp1%~n1.albedo%~x1" -n "%~dp1%~n1.normal%~x1"
GOTO postdenoise
:PNGerror
ECHO ### ERROR %1
ECHO ### Is not a .png (or this script broke)
:Break
ECHO .
ECHO == END ==
ECHO .
PAUSE