prath commited on
Commit
745a6b9
·
1 Parent(s): c4e19e5

Upload model.py

Browse files
Files changed (1) hide show
  1. model.py +36 -0
model.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tensorflow as tf
2
+
3
+ def residual_block(inputs, filters):
4
+ x = tf.keras.layers.Conv2D(filters, (3, 3), padding='same', activation='relu')(inputs)
5
+ x = tf.keras.layers.Conv2D(filters, (3, 3), padding='same')(x)
6
+ x = tf.keras.layers.add([inputs, x])
7
+ x = tf.keras.layers.Activation('relu')(x)
8
+ return x
9
+
10
+ def get_model():
11
+ inputs = tf.keras.layers.Input(shape=(None, None, 3))
12
+ batch_size = tf.shape(inputs)[0]
13
+
14
+ conv1 = tf.keras.layers.Conv2D(32, (3, 3), padding='same', activation='relu')(inputs)
15
+ conv1 = tf.keras.layers.Conv2D(32, (3, 3), padding='same', activation='relu')(conv1)
16
+
17
+ conv2 = tf.keras.layers.Conv2D(64, (3, 3), padding='same', activation='relu')(conv1)
18
+ conv2 = tf.keras.layers.Conv2D(64, (3, 3), padding='same', activation='relu')(conv2)
19
+
20
+ conv3 = tf.keras.layers.Conv2D(128, (3, 3), padding='same', activation='relu')(conv2)
21
+ conv3 = tf.keras.layers.Conv2D(128, (3, 3), padding='same', activation='relu')(conv2)
22
+
23
+ res1 = residual_block(conv3, 128)
24
+ res2 = residual_block(res1, 128)
25
+ res3 = residual_block(res2, 128)
26
+ res4 = residual_block(res3, 128)
27
+ res5 = residual_block(res4, 128)
28
+
29
+ deconv1 = tf.keras.layers.Conv2DTranspose(64, (3, 3), padding='same', activation='relu')(res5)
30
+ deconv2 = tf.keras.layers.Conv2DTranspose(32, (3, 3), padding='same', activation='relu')(deconv1)
31
+
32
+ outputs = tf.keras.layers.Conv2D(3, (3, 3), padding='same', activation='sigmoid')(deconv2)
33
+ outputs=tf.keras.layers.add([inputs, outputs])
34
+
35
+ model = tf.keras.models.Model(inputs=inputs, outputs=outputs)
36
+ return model