Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
zsdonghao committed Jun 18, 2017
1 parent 7433735 commit cf51300
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 41 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ TensorFlow Implementation of ["Photo-Realistic Single Image Super-Resolution Usi
</a>


#### Results
### Results

<a href="http://tensorlayer.readthedocs.io">
<div align="center">
<img src="img/SRGAN_Result2.png" width="80%" height="50%"/>
</div>
</a>

#### Prepare Data and Pre-trained VGG
### Prepare Data and Pre-trained VGG
- In this experiment, we used images from [DIV2K - bicubic downscaling x4 competition](http://www.vision.ee.ethz.ch/ntire17/), you can also use your own data by setting your image folder in `config.py`

- Download VGG model as [tutorial_vgg16.py](https://github.com/zsdonghao/tensorlayer/blob/master/example/tutorial_vgg16.py) show.



#### Run
### Run
- Set your image folder in `config.py`.

```python
Expand Down
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# config.TRAIN.decay_every_init = int(config.TRAIN.n_epoch_init / 2)

## adversarial learning (SRGAN)
config.TRAIN.n_epoch = 1000
config.TRAIN.n_epoch = 2000
config.TRAIN.lr_decay = 0.1
config.TRAIN.decay_every = int(config.TRAIN.n_epoch / 2)

Expand Down
76 changes: 39 additions & 37 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,59 +157,61 @@ def SRGAN_d(input_images, is_train=True, reuse=False):
b_init = None # tf.constant_initializer(value=0.0)
gamma_init=tf.random_normal_initializer(1., 0.02)
df_dim = 64
with tf.variable_scope("SRGAN_d2", reuse=reuse):
lrelu = lambda x: tl.act.lrelu(x, 0.2)
with tf.variable_scope("SRGAN_d", reuse=reuse):
tl.layers.set_name_reuse(reuse)
net_in = InputLayer(input_images, name='d_input/images')
net_h0 = Conv2d(net_in, df_dim, (4, 4), (2, 2), act=lambda x: tl.act.lrelu(x, 0.2),
padding='SAME', W_init=w_init, name='d_h0/conv2d')
net_in = InputLayer(input_images, name='input/images')
net_h0 = Conv2d(net_in, df_dim, (4, 4), (2, 2), act=lrelu,
padding='SAME', W_init=w_init, name='h0/c')

net_h1 = Conv2d(net_h0, df_dim*2, (4, 4), (2, 2), act=None,
padding='SAME', W_init=w_init, b_init=b_init, name='d_h1/conv2d')
net_h1 = BatchNormLayer(net_h1, act=lambda x: tl.act.lrelu(x, 0.2),
is_train=is_train, gamma_init=gamma_init, name='d_h1/batchnorm')
padding='SAME', W_init=w_init, b_init=b_init, name='h1/c')
net_h1 = BatchNormLayer(net_h1, act=lrelu, is_train=is_train,
gamma_init=gamma_init, name='h1/bn')
net_h2 = Conv2d(net_h1, df_dim*4, (4, 4), (2, 2), act=None,
padding='SAME', W_init=w_init, b_init=b_init, name='d_h2/conv2d')
net_h2 = BatchNormLayer(net_h2, act=lambda x: tl.act.lrelu(x, 0.2),
is_train=is_train, gamma_init=gamma_init, name='d_h2/batchnorm')
padding='SAME', W_init=w_init, b_init=b_init, name='h2/c')
net_h2 = BatchNormLayer(net_h2, act=lrelu, is_train=is_train,
gamma_init=gamma_init, name='h2/bn')
net_h3 = Conv2d(net_h2, df_dim*8, (4, 4), (2, 2), act=None,
padding='SAME', W_init=w_init, b_init=b_init, name='d_h3/conv2d')
net_h3 = BatchNormLayer(net_h3, act=lambda x: tl.act.lrelu(x, 0.2),
is_train=is_train, gamma_init=gamma_init, name='d_h3/batchnorm')
padding='SAME', W_init=w_init, b_init=b_init, name='h3/c')
net_h3 = BatchNormLayer(net_h3, act=lrelu, is_train=is_train,
gamma_init=gamma_init, name='h3/bn')
net_h4 = Conv2d(net_h3, df_dim*16, (4, 4), (2, 2), act=None,
padding='SAME', W_init=w_init, b_init=b_init, name='d_h4/conv2d')
net_h4 = BatchNormLayer(net_h4, act=lambda x: tl.act.lrelu(x, 0.2),
is_train=is_train, gamma_init=gamma_init, name='d_h4/batchnorm')
padding='SAME', W_init=w_init, b_init=b_init, name='h4/c')
net_h4 = BatchNormLayer(net_h4, act=lrelu, is_train=is_train,
gamma_init=gamma_init, name='h4/bn')
net_h5 = Conv2d(net_h4, df_dim*32, (4, 4), (2, 2), act=None,
padding='SAME', W_init=w_init, b_init=b_init, name='d_h5/conv2d')
net_h5 = BatchNormLayer(net_h5, act=lambda x: tl.act.lrelu(x, 0.2),
is_train=is_train, gamma_init=gamma_init, name='d_h5/batchnorm')
padding='SAME', W_init=w_init, b_init=b_init, name='h5/c')
net_h5 = BatchNormLayer(net_h5, act=lrelu, is_train=is_train,
gamma_init=gamma_init, name='h5/bn')
net_h6 = Conv2d(net_h5, df_dim*16, (1, 1), (1, 1), act=None,
padding='SAME', W_init=w_init, b_init=b_init, name='d_h6/conv2d')
net_h6 = BatchNormLayer(net_h6, act=lambda x: tl.act.lrelu(x, 0.2),
is_train=is_train, gamma_init=gamma_init, name='d_h6/batchnorm')
padding='SAME', W_init=w_init, b_init=b_init, name='h6/c')
net_h6 = BatchNormLayer(net_h6, act=lrelu, is_train=is_train,
gamma_init=gamma_init, name='h6/bn')
net_h7 = Conv2d(net_h6, df_dim*8, (1, 1), (1, 1), act=None,
padding='SAME', W_init=w_init, b_init=b_init, name='d_h7/conv2d')
net_h7 = BatchNormLayer(net_h7, #act=lambda x: tl.act.lrelu(x, 0.2),
is_train=is_train, gamma_init=gamma_init, name='d_h7/batchnorm')
padding='SAME', W_init=w_init, b_init=b_init, name='h7/c')
net_h7 = BatchNormLayer(net_h7, is_train=is_train,
gamma_init=gamma_init, name='h7/bn')

net = Conv2d(net_h7, df_dim*2, (1, 1), (1, 1), act=None,
padding='SAME', W_init=w_init, b_init=b_init, name='d_h8_res/conv2d')
net = BatchNormLayer(net, act=lambda x: tl.act.lrelu(x, 0.2),
is_train=is_train, gamma_init=gamma_init, name='d_h8_res/batchnorm')
padding='SAME', W_init=w_init, b_init=b_init, name='res/c')
net = BatchNormLayer(net, act=lrelu, is_train=is_train,
gamma_init=gamma_init, name='res/bn')
net = Conv2d(net, df_dim*2, (3, 3), (1, 1), act=None,
padding='SAME', W_init=w_init, b_init=b_init, name='d_h8_res/conv2d2')
net = BatchNormLayer(net, act=lambda x: tl.act.lrelu(x, 0.2),
is_train=is_train, gamma_init=gamma_init, name='d_h8_res/batchnorm2')
padding='SAME', W_init=w_init, b_init=b_init, name='res/c2')
net = BatchNormLayer(net, act=lrelu, is_train=is_train,
gamma_init=gamma_init, name='res/bn2')
net = Conv2d(net, df_dim*8, (3, 3), (1, 1), act=None,
padding='SAME', W_init=w_init, b_init=b_init, name='d_h8_res/conv2d3')
net = BatchNormLayer(net, #act=lambda x: tl.act.lrelu(x, 0.2),
is_train=is_train, gamma_init=gamma_init, name='d_h8_res/batchnorm3')
net_h8 = ElementwiseLayer(layer=[net_h7, net], combine_fn=tf.add, name='d_h8/add')
padding='SAME', W_init=w_init, b_init=b_init, name='res/c3')
net = BatchNormLayer(net, is_train=is_train,
gamma_init=gamma_init, name='res/bn3')
net_h8 = ElementwiseLayer(layer=[net_h7, net],
combine_fn=tf.add, name='res/add')
net_h8.outputs = tl.act.lrelu(net_h8.outputs, 0.2)

net_ho = FlattenLayer(net_h8, name='d_ho/flatten')
net_ho = FlattenLayer(net_h8, name='ho/flatten')
net_ho = DenseLayer(net_ho, n_units=1, act=tf.identity,
W_init = w_init, name='d_ho/dense')
W_init = w_init, name='ho/dense')
logits = net_ho.outputs
net_ho.outputs = tf.nn.sigmoid(net_ho.outputs)

Expand Down

0 comments on commit cf51300

Please sign in to comment.