-
Notifications
You must be signed in to change notification settings - Fork 0
/
w2x
executable file
·65 lines (51 loc) · 1.35 KB
/
w2x
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
#!/bin/bash
if [ -f /usr/bin/waifu2x ]; then
if [ "$1" == "--help" ] || [ "$#" -eq 0 ]; then
echo "w2x [noise] [scale] [image]"
exit 0
fi
METHOD="noise_scale"
NOISE=$1
SCALE=$2
IMAGE=$3
TTA=1
NOISE_CMD="-noise_level ${NOISE}"
NOISE_NAME="n${NOISE}_"
if [ "${NOISE}" == "0" ]; then
METHOD="scale"
NOISE_CMD=""
NOISE_NAME=""
fi
SCALE_CMD="-scale ${SCALE}"
SCALE_NAME="x${SCALE}"
if [ "${SCALE}" == "1" ]; then
METHOD="noise"
SCALE_CMD=""
fi
TTA_CMD=""
if [ "${TTA}" == "1" ]; then
TTA_CMD="-tta 1"
fi
OUT="${IMAGE%.*}_[${NOISE_NAME}${SCALE_NAME}].png"
waifu2x -m "${METHOD}" "${NOISE_CMD}" "${SCALE_CMD}" "${TTA_CMD}" -i "${IMAGE}" -o "${OUT}"
elif [ -f /usr/bin/waifu2x-ncnn-vulkan ]; then
if [ "$1" == "--help" ] || [ "$#" -eq 0 ]; then
echo "w2x [noise(-1..2)] [scale(1,2)] [image]"
exit 0
fi
NOISE=$1
SCALE=$2
IMAGE=$3
NOISE_CMD="-n ${NOISE}"
if [ "${NOISE}" == "-1" ]; then
NOISE_NAME=""
else
NOISE_NAME="n${NOISE}_"
fi
SCALE_CMD="-s ${SCALE}"
SCALE_NAME="x${SCALE}"
OUT="${IMAGE%.*}_[${NOISE_NAME}${SCALE_NAME}].png"
waifu2x-ncnn-vulkan -x "${NOISE_CMD}" "${SCALE_CMD}" -i "${IMAGE}" -o "${OUT}" -v
else
echo "waifu2x not found"
fi