add settings for preview
This commit is contained in:
parent
099e49e0aa
commit
a557e636ea
@ -41,6 +41,7 @@ readonly RangesList="$OutputDir/ranges.list"
|
|||||||
|
|
||||||
readonly DepsConf="$SettingsDir/deps.conf"
|
readonly DepsConf="$SettingsDir/deps.conf"
|
||||||
readonly Waifu2xConf="$SettingsDir/waifu2x-caffe.conf"
|
readonly Waifu2xConf="$SettingsDir/waifu2x-caffe.conf"
|
||||||
|
readonly PreviewConf="$SettingsDir/preview.conf"
|
||||||
readonly FfmpegConf="$SettingsDir/ffmpeg.conf"
|
readonly FfmpegConf="$SettingsDir/ffmpeg.conf"
|
||||||
readonly RangeGenConf="$SettingsDir/range-gen.conf"
|
readonly RangeGenConf="$SettingsDir/range-gen.conf"
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
source "$Waifu2xConf"
|
source "$Waifu2xConf"
|
||||||
|
source "$PreviewConf"
|
||||||
|
|
||||||
readonly TmpFramesSrcDir="${PreviewDir}_tmpsrc"
|
readonly TmpFramesSrcDir="${PreviewDir}_tmpsrc"
|
||||||
readonly TmpFramesOutDir="${PreviewDir}_tmpout"
|
readonly TmpFramesOutDir="${PreviewDir}_tmpout"
|
||||||
@ -45,15 +46,26 @@ do
|
|||||||
EndFrame=$(png_num ${RangeInfo[1]})
|
EndFrame=$(png_num ${RangeInfo[1]})
|
||||||
TargetFrame=$((StartFrame + (EndFrame - StartFrame)/2))
|
TargetFrame=$((StartFrame + (EndFrame - StartFrame)/2))
|
||||||
|
|
||||||
CopyList+="$(printf "%06d" $TargetFrame).png "
|
CopyList+="$(printf "%06d" $TargetFrame).png " # faster than copying one by one
|
||||||
done < <(cat "$RangesList"; echo) # make bash not skip the last line (if there is no empty line at the end)
|
done < <(cat "$RangesList"; echo) # make bash not skip the last line (if there is no empty line at the end)
|
||||||
|
|
||||||
pushd "$FramesDir" > /dev/null
|
pushd "$FramesDir" > /dev/null
|
||||||
cp -f $CopyList "$TmpFramesSrcDir"
|
cp -f $CopyList "$TmpFramesSrcDir"
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
|
|
||||||
|
if echo "$UseRangeNumbers" | grep -qiF "True"; then
|
||||||
|
pushd "$TmpFramesSrcDir" > /dev/null
|
||||||
|
Index=0
|
||||||
|
while read File
|
||||||
|
do
|
||||||
|
((Index+=1))
|
||||||
|
mv "$File" "$(printf "%06d" $Index).png"
|
||||||
|
done < <(find "$TmpFramesSrcDir" -type f -name '*.png' -printf '%f\n')
|
||||||
|
popd > /dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
# Upscale (scale)
|
# Upscale (scale)
|
||||||
if [[ "$ScaleRatio" -ne 1 ]]; then
|
if echo "$Waifu2xScalePreview" | grep -qiF "True" && [[ "$ScaleRatio" -ne 1 ]]; then
|
||||||
echo "waifu2x scale"
|
echo "waifu2x scale"
|
||||||
waifu2x-caffe-cui \
|
waifu2x-caffe-cui \
|
||||||
--mode "scale" \
|
--mode "scale" \
|
||||||
@ -79,7 +91,7 @@ if [[ "$ScaleRatio" -ne 1 ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Upscale (noise_scale)
|
# Upscale (noise_scale)
|
||||||
for NoiseLevel in 0 1 2 3
|
for NoiseLevel in $Waifu2xNoiseScaleList
|
||||||
do
|
do
|
||||||
if [[ "$ScaleRatio" -eq 1 ]]; then
|
if [[ "$ScaleRatio" -eq 1 ]]; then
|
||||||
UpscaleMode="noise"
|
UpscaleMode="noise"
|
||||||
@ -112,10 +124,12 @@ do
|
|||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "scale original"
|
if echo "$ResizePreivew" | grep -qiF "True"; then
|
||||||
mogrify -scale $(echo "$ScaleRatio * 100" | bc)% "$TmpFramesSrcDir"/*.png
|
echo "scale original"
|
||||||
pushd "$TmpFramesSrcDir" > /dev/null
|
mogrify -scale $(echo "$ScaleRatio * 100" | bc)% "$TmpFramesSrcDir"/*.png
|
||||||
mv *.png "$PreviewDir"
|
pushd "$TmpFramesSrcDir" > /dev/null
|
||||||
popd > /dev/null
|
mv *.png "$PreviewDir"
|
||||||
|
popd > /dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
rm -rf "$TmpFramesSrcDir" "$TmpFramesOutDir"
|
rm -rf "$TmpFramesSrcDir" "$TmpFramesOutDir"
|
@ -22,4 +22,8 @@
|
|||||||
|
|
||||||
source "$RangeGenConf"
|
source "$RangeGenConf"
|
||||||
|
|
||||||
"$DepsDir/range-gen/range-gen.exe" -j "$Jobs" -n "$NoiseLevel" "$FramesDir" "$RangesList" "$Threshold"
|
if [[ -n "$NoiseLevel" ]]; then
|
||||||
|
"$DepsDir/range-gen/range-gen.exe" -j "$Jobs" -n "$NoiseLevel" "$FramesDir" "$RangesList" "$Threshold"
|
||||||
|
else
|
||||||
|
"$DepsDir/range-gen/range-gen.exe" -j "$Jobs" "$FramesDir" "$RangesList" "$Threshold"
|
||||||
|
fi
|
||||||
|
7
settings/preview.conf
Normal file
7
settings/preview.conf
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
### Preview gen settings ###
|
||||||
|
|
||||||
|
UseRangeNumbers="True" # (Instead of frame numbers)
|
||||||
|
|
||||||
|
ResizePreivew="False" # Resize original frames with ImageMagisk
|
||||||
|
Waifu2xScalePreview="False" # Generate preview for Waifu2x scale mode
|
||||||
|
Waifu2xNoiseScaleList="0 1 3" # Preview for Waifu2x noise_scale mode. Specify noise reduction levels in the list.
|
Loading…
Reference in New Issue
Block a user