Closed eeric closed 8 years ago
@eeric models.py is there in the root folder. It contains the methods needed to create the SRResNet and SRGAN networks.
I am able to execute the benchmark test in PyCharm without any problem. Try adding the path of the root directory to the Python path.
What does it include to val_images folder? In addition, there is a error when making the order, python models.py, detail following,
Traceback (most recent call last):
File "models.py", line 696, in
@eeric This code supports only Theano backend at the moment with Theano dim ordering. That's why it's showing that error.
For valimages folder, run the three scripts called download*.py in each of the 3 dataset directories. It will download the validation images of set 5, set 14, and BSD 100
models.py(323) build_srgan_model() -> ip = Input(shape=(3, self.img_width, self.img_height), name='x_generator') <tf.Tensor 'x_generator:0' shape=(?, 3, 32, 32) dtype=float32>
models.py(327) build_srgan_model() -> sr_output = self.generative_network.create_sr_model(ip)
TypeError: "moments() got an unexpected keyword argument 'shift'"
It isn't provided to SRGAN model, so benchmark_test.py occur error. Then how to run models.py? How to load training data?
@eeric As I said, this code is only for Theano backend with Python 3.4, tested on Keras 1.1.0. It's a work in progress. Calling python benchmark_test.py
should work to run the code.
Instructions to run model.py are given in the Usage portion of the readme. As to training data, simply providing the path to the image data set will be enough.
python benchmark_test.py error following
python benchmark_test.py File "benchmark_test.py", line 32 def test_set5(model : Model, img_width=32, img_height=32, batch_size=1): ^ SyntaxError: invalid syntax
As to training data, simply providing the path to the image data set will be enough.
where is it to providing the path of training data in model.py code?
@eeric inside model.py main declaration at the end of the file, there is a coco_path variable with an empty string. Put the path there. Also in the benchmark_test.py put the coco path at the end of the file in the coco_path variable.
For the invalid syntax, it may be due to the method definition. Remove : Model
from the line def test_set5(model : Model, img_width=32, img_height=32, batch_size=1):
Thanks, according your advice, coco_path variable has new path, but it occur a error, following
1.python model.py
Using TensorFlow backend.
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcurand.so locally
Traceback (most recent call last):
File "models.py", line 709, in
TypeError: moments() got an unexpected keyword argument 'shift'
2.> Remove : Model from the line def test_set5(model : Model, img_width=32, img_height=32, batch_size=1):
python benchmark_test.py File "benchmark_test.py", line 145 def build_model(self, load_weights=False) -> Model: ^ SyntaxError: invalid syntax
----python models.py
Using Theano backend.
Loaded Generator weights
Training SRGAN network
()
Epoch : 1
Found 0 images belonging to 0 classes.
Traceback (most recent call last):
File "models.py", line 710, in
ZeroDivisionError: integer division or modulo by zero
@eeric You need to have a sub folder containing the images.
Say the folders are at /home/data/images/*.jpg, then provide the path as : /home/data
@eeric Are you using image_dim_ordering="th" and not image_dim_ordering="th" in the ~/keras/keras.json file? As I said, this code does not work with Tensorflow and Tensorflow dim ordering.
It debugs successfully to model.py. Through readme is not very detailed, such as library is not clear, path of training data can't be know, thanks for your kind help.
----Remove : Model ----python benchmark_test.py
Traceback (most recent call last):
File "benchmark_test.py", line 1, in
@eeric Well this is by no means a finished project so readme is incomplete.
I updated the benchmark scripts to correctly setup the path and import the modules. Try with the latest version. It was a problem with the way python loads modules if they don't exist in the current working directory.
--Remove 'model :’ from the line def test_set5(model : Model, img_width=32, img_height=32, batch_size=1): ----Remove '-> Model’ from the line def build_model(self, load_weights=False) -> Model:
-- python benchmark_test.py
Using Theano backend. Training SR ResNet network () Epoch : 1 Found 1895 images belonging to 1 classes. Iter : 1 / 1895 | Improvement : -0.00 percent | Time required : 329.73 seconds | PSNR : -43.567 Iter : 2 / 1895 | Improvement : -2.43 percent | Time required : 24.05 seconds | PSNR : -44.628 Iter : 3 / 1895 | Improvement : 3.35 percent | Time required : 23.41 seconds | PSNR : -43.132
Run this code on the gpu. The SE ResNet is too large to train on the cpu efficiently.
Also, 2000 training images is far too small to train or pretrain the SE ResNet or SRGAN. It requires at least 5000 images to reach near +10 PSNR range, and a further 70000 images to hit the +20 PSNR range. This is mentioned in the readme. It's caused by blurred checkerboard artifacts.
I have already provided SR ResNet weights which have been pre trained on the MS COCO dataset, so you can just run validation on that.
In benchmark_test.py, As for 'coco_path' (= r"D:\Yue\Documents\Dataset\coco2014\train2014"), did it be use to train SR ResNet network? so if no training, how to used sr_resnet_weights.h5(that is SR ResNet weights provided ) to load 'sr_resnet_test.model' in line test_set5(sr_resnet_test.model, img_width=img_width, img_height=img_height)?
In benchnark_test.py, in the if main part, comment out the line sr_resnet_test.train_model(coco_path, nb_images=50000, nb_epochs=1)
.
The path that is there is the path I used to train the model. You don't need Coco path anymore.
To load the pre trained model, make load_weights=True
in the sr_resnet_test.build_model(load_weights=False)
line
Thank you,
Through your above advice, it occured below,
--python benchmark_test.py
Using Theano backend.
SR ResNet model weights loaded.
Testing model on Set 5 Validation images
Traceback (most recent call last):
File "benchmark_test.py", line 299, in
( from: img_width = img_height = 96 sr_resnet_test = SRResNetTest(img_width=img_width, img_height=img_height, batch_size=1) sr_resnet_test.build_model(load_weights=True)
#sr_resnet_test.train_model(coco_path, nb_images=1895, nb_epochs=1)
test_set5(sr_resnet_test.model, img_width=img_width, img_height=img_height)
)
In paper: Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network, the bicubic kernel is for bicubic interpolation when making the training data, does it?
python benchmark_test.py
Using Theano backend.
Using gpu device 0: GeForce GTX 980 Ti (CNMeM is disabled, cuDNN 4007)
SR ResNet model weights loaded.
Testing model on Set 5 Validation images
Traceback (most recent call last):
File "benchmark_test.py", line 299, in
Hi, I'm glad to appreciate your code, but I don't know that how to implement it. Such as benchmark_test.py, it occurs error, that is no module named 'models'. SRGAN model isn't provided, is it?