Closed ghost closed 5 years ago
I could not reproduce that situation. Could you tell me the command you executed and the size of the input image?
Source image:
For CPU:
ucok66@ucok66:~/waifu2x-chainer$ python waifu2x.py -e png -a 3 -m noise_scale -S 2000 -n 2 -t -T 2 -b 20 -l 256 -i /home/ucok66/2019-02-27_Flight-of-Spring_by-David-Revoy.jpg -o /home/ucok66/
2.0x upscaling... 0 1 OK
2.0x upscaling... 0 1 OK
Resizing... OK
Elapsed time: 611.125334 sec
Saved as '/home/ucok66/2019-02-27_Flight-of-Spring_by-David-Revoy.png'
for GPU
ucok66@ucok:~/waifu2x-chainer$ python waifu2x.py -g 0 -e png -a 3 -m noise_scale -S 2000 -n 2 -t -T 2 -b 20 -l 256 -i /home/ucok66/2019-02-27_Flight-of-Spring_by-David-Revoy.jpg -o /home/ucok66/
2.0x upscaling... 0 1 OK
2.0x upscaling... 0 1 OK
Resizing... OK
Elapsed time: 5.569068 sec
Saved as '/home/ucok66/2019-02-27_Flight-of-Spring_by-David-Revoy_(tta2)(noise2_scale3.0x)(upresnet10_rgb).png'
Hmm, I thought only GPU have this problem, but the CPU has this problem too. Initially, I wanted to enlarge my image with the size of 2000px for the smallest side, but both of them only produced 1923px
Maybe adding line from __future__ import division
to the beginning of waifu2x.py will solve this issue.
Could you try it?
hmm.
ucok66@ucok66:~/waifu2x-chainer$ python from __future__ import division waifu2x.py -e png -a 3 -m noise_scale -S 2000 -n 2 -t -T 2 -b 20 -l 256 -i /home/ucok66/2019-02-27_Flight-of-Spring_by-David-Revoy.jpg -o /home/ucok66/
python: can't open file 'from': [Errno 2] No such file or directory
ucok66@ucok66:~/waifu2x-chainer$ python waifu2x.py from __future__ import division -e png -a 3 -m noise_scale -S 2000 -n 2 -t -T 2 -b 20 -l 256 -i /home/ucok66/2019-02-27_Flight-of-Spring_by-David-Revoy.jpg -o /home/ucok66/
usage: waifu2x.py [-h] [--gpu GPU] [--input INPUT] [--output_dir OUTPUT_DIR]
[--extension EXTENSION] [--quality QUALITY]
[--arch {VGG7,0,UpConv7,1,ResNet10,2,UpResNet10,3}]
[--model_dir MODEL_DIR] [--method {noise,scale,noise_scale}]
[--scale_ratio SCALE_RATIO] [--noise_level {0,1,2,3}]
[--color {y,rgb}] [--tta] [--tta_level {2,4,8}]
[--batch_size BATCH_SIZE] [--block_size BLOCK_SIZE]
[--width WIDTH | --height HEIGHT | --shorter_side SHORTER_SIDE | --longer_side LONGER_SIDE]
waifu2x.py: error: unrecognized arguments: from __future__ import division
Which one works?
Oh, sorry. It means to open waifu2x.py
in a text editor and editing like this.
from __future__ import division # Add this line
import argparse
import os
import time
...
It is work What is happen?
In Python 2, the /
operator is integer division if inputs are integers.
So the scale_ratio
will be 2000 / 900 = 2
although it should be 2.22
.
In Python 3 or using from __future__ import division
in Python 2, the /
operator is float division.
If you use float division, scale_ratio
is correctly calculated to be 2.22
.
Usually when downscale image size using CPU is not a problem. But, when using GPU, image enlargement does not reach the size target.
Example: Enlarge the image with the smallest side of 900px targeting 3000px.
Is there something wrong with it?