mirror of
https://github.com/denshooter/gpu_colorization.git
synced 2026-01-21 12:32:57 +01:00
Add trainings stuff
This commit is contained in:
33
Plots/Layers/CreatePlot_layerStructure.py
Normal file
33
Plots/Layers/CreatePlot_layerStructure.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import tensorflow as tf
|
||||
|
||||
from EncoderLayers import *
|
||||
from DecoderLayers import *
|
||||
|
||||
import sys
|
||||
sys.path.append("../..")
|
||||
|
||||
from Colorful_Image_Colorization.model import *
|
||||
|
||||
def main():
|
||||
|
||||
encoder_layers = EncoderLayers()
|
||||
decoder_layers = DecoderLayers()
|
||||
|
||||
inputs = tf.keras.Input(shape=(256,256, 1), name="Grey image")
|
||||
encoder = tf.keras.Model(inputs=[inputs],outputs=encoder_layers.call(inputs))
|
||||
|
||||
embedding = tf.keras.Input(shape=(32,32, 3), name="Embedding")
|
||||
decoder = tf.keras.Model(inputs=[embedding],outputs=decoder_layers.call(embedding))
|
||||
|
||||
tf.keras.utils.plot_model(encoder,show_shapes=True, show_layer_names=True, to_file="EncoderLayer.png")
|
||||
tf.keras.utils.plot_model(decoder,show_shapes=True, show_layer_names=True, to_file="DecoderLayer.png")
|
||||
|
||||
ModelToCompare_layers = build_model()
|
||||
modelToCompare = tf.keras.Model(inputs=[inputs],outputs=ModelToCompare_layers.call(inputs))
|
||||
tf.keras.utils.plot_model(modelToCompare,show_shapes=True, show_layer_names=True, to_file="ModelToCompare.png")
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
main()
|
||||
except KeyboardInterrupt:
|
||||
print("KeyboardInterrupt received")
|
||||
BIN
Plots/Layers/DecoderLayer.png
Normal file
BIN
Plots/Layers/DecoderLayer.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 116 KiB |
31
Plots/Layers/DecoderLayers.py
Normal file
31
Plots/Layers/DecoderLayers.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import tensorflow as tf
|
||||
|
||||
class DecoderLayers(tf.keras.Model):
|
||||
def __init__(self):
|
||||
super(DecoderLayers, self).__init__()
|
||||
|
||||
self.layer_list = [
|
||||
tf.keras.layers.Conv2DTranspose(105, kernel_size=(3,3), strides=2, padding='same', name="Conv2D_Trans_0"),
|
||||
tf.keras.layers.BatchNormalization(name="BatchNormalization_0"),
|
||||
tf.keras.layers.Activation(tf.nn.tanh, name="tanh_0"),
|
||||
|
||||
tf.keras.layers.Conv2DTranspose(90, kernel_size=(3,3), strides=2, padding='same', name="Conv2D_Trans_1"),
|
||||
tf.keras.layers.BatchNormalization(name="BatchNormalization_1"),
|
||||
tf.keras.layers.Activation(tf.nn.tanh, name="tanh_1"),
|
||||
|
||||
tf.keras.layers.Conv2DTranspose(75, kernel_size=(3,3), strides=2, padding='same', name="Conv2D_Trans_2"),
|
||||
tf.keras.layers.BatchNormalization(name="BatchNormalization_2"),
|
||||
tf.keras.layers.Activation(tf.nn.tanh, name="tanh_2"),
|
||||
|
||||
# bottleneck to RGB
|
||||
|
||||
tf.keras.layers.Conv2DTranspose(2, kernel_size=(1,1), strides=1, padding='same', name="Conv2D_Trans_3"),
|
||||
tf.keras.layers.BatchNormalization(name="BatchNormalization_3"),
|
||||
tf.keras.layers.Activation(tf.nn.tanh, name="tanh_3"),
|
||||
]
|
||||
|
||||
|
||||
def call(self, x):
|
||||
for layer in self.layer_list:
|
||||
x = layer(x)
|
||||
return x
|
||||
BIN
Plots/Layers/EncoderLayer.png
Normal file
BIN
Plots/Layers/EncoderLayer.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 112 KiB |
29
Plots/Layers/EncoderLayers.py
Normal file
29
Plots/Layers/EncoderLayers.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import tensorflow as tf
|
||||
|
||||
class EncoderLayers(tf.keras.Model):
|
||||
def __init__(self):
|
||||
super(EncoderLayers, self).__init__()
|
||||
|
||||
self.layer_list = [
|
||||
tf.keras.layers.Conv2D(75, kernel_size=(3, 3), strides=2, padding='same', name="Conv2D_0"),
|
||||
tf.keras.layers.BatchNormalization(name="BatchNormalization_0"),
|
||||
tf.keras.layers.Activation(tf.nn.tanh, name="tanh_0"),
|
||||
|
||||
tf.keras.layers.Conv2D(90, kernel_size=(3, 3), strides=2, padding='same', name="Conv2D_1"),
|
||||
tf.keras.layers.BatchNormalization(name="BatchNormalization_1"),
|
||||
tf.keras.layers.Activation(tf.nn.tanh, name="tanh_1"),
|
||||
|
||||
tf.keras.layers.Conv2D(105, kernel_size=(3, 3), strides=2, padding='same',name="Conv2D_2"),
|
||||
tf.keras.layers.BatchNormalization(name="BatchNormalization_2"),
|
||||
tf.keras.layers.Activation(tf.nn.tanh, name="tanh_2"),
|
||||
|
||||
tf.keras.layers.Conv2D(3, kernel_size=(1, 1), strides=1, padding='same', name="Conv2D_3"),
|
||||
tf.keras.layers.BatchNormalization(name="BatchNormalization_3"),
|
||||
tf.keras.layers.Activation(tf.nn.tanh, name="tanh_3"),
|
||||
]
|
||||
|
||||
|
||||
def call(self, x):
|
||||
for layer in self.layer_list:
|
||||
x = layer(x)
|
||||
return x
|
||||
BIN
Plots/Layers/ModelToCompare.png
Normal file
BIN
Plots/Layers/ModelToCompare.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 329 KiB |
BIN
Plots/Layers/__pycache__/DecoderLayers.cpython-38.pyc
Normal file
BIN
Plots/Layers/__pycache__/DecoderLayers.cpython-38.pyc
Normal file
Binary file not shown.
BIN
Plots/Layers/__pycache__/EncoderLayers.cpython-38.pyc
Normal file
BIN
Plots/Layers/__pycache__/EncoderLayers.cpython-38.pyc
Normal file
Binary file not shown.
BIN
Plots/Layers/__pycache__/ModelToCompare.cpython-38.pyc
Normal file
BIN
Plots/Layers/__pycache__/ModelToCompare.cpython-38.pyc
Normal file
Binary file not shown.
Reference in New Issue
Block a user