MCPcopy Create free account
hub / github.com/SystemErrorWang/White-box-Cartoonization / unet_generator

Function unet_generator

test_code/network.py:22–57  ·  view source on GitHub ↗
(inputs, channel=32, num_blocks=4, name='generator', reuse=False)

Source from the content-addressed store, hash-verified

20
21
22def unet_generator(inputs, channel=32, num_blocks=4, name='generator', reuse=False):
23 with tf.variable_scope(name, reuse=reuse):
24
25 x0 = slim.convolution2d(inputs, channel, [7, 7], activation_fn=None)
26 x0 = tf.nn.leaky_relu(x0)
27
28 x1 = slim.convolution2d(x0, channel, [3, 3], stride=2, activation_fn=None)
29 x1 = tf.nn.leaky_relu(x1)
30 x1 = slim.convolution2d(x1, channel*2, [3, 3], activation_fn=None)
31 x1 = tf.nn.leaky_relu(x1)
32
33 x2 = slim.convolution2d(x1, channel*2, [3, 3], stride=2, activation_fn=None)
34 x2 = tf.nn.leaky_relu(x2)
35 x2 = slim.convolution2d(x2, channel*4, [3, 3], activation_fn=None)
36 x2 = tf.nn.leaky_relu(x2)
37
38 for idx in range(num_blocks):
39 x2 = resblock(x2, out_channel=channel*4, name='block_{}'.format(idx))
40
41 x2 = slim.convolution2d(x2, channel*2, [3, 3], activation_fn=None)
42 x2 = tf.nn.leaky_relu(x2)
43
44 h1, w1 = tf.shape(x2)[1], tf.shape(x2)[2]
45 x3 = tf.image.resize_bilinear(x2, (h1*2, w1*2))
46 x3 = slim.convolution2d(x3+x1, channel*2, [3, 3], activation_fn=None)
47 x3 = tf.nn.leaky_relu(x3)
48 x3 = slim.convolution2d(x3, channel, [3, 3], activation_fn=None)
49 x3 = tf.nn.leaky_relu(x3)
50
51 h2, w2 = tf.shape(x3)[1], tf.shape(x3)[2]
52 x4 = tf.image.resize_bilinear(x3, (h2*2, w2*2))
53 x4 = slim.convolution2d(x4+x0, channel, [3, 3], activation_fn=None)
54 x4 = tf.nn.leaky_relu(x4)
55 x4 = slim.convolution2d(x4, 3, [7, 7], activation_fn=None)
56
57 return x4
58
59if __name__ == '__main__':
60

Callers

nothing calls this directly

Calls 1

resblockFunction · 0.70

Tested by

no test coverage detected