Format pep8, include pass shaped to mobilenet

This commit is contained in:
Piv
2021-03-25 21:56:50 +10:30
parent 9449ddef01
commit 3325ea0c0c
2 changed files with 17 additions and 18 deletions

View File

@@ -22,7 +22,8 @@ def fix_windows_gpu():
for gpu in gpus:
tf.config.experimental.set_memory_growth(gpu, True)
logical_gpus = tf.config.experimental.list_logical_devices('GPU')
print(len(gpus), "Physical GPUs,", len(logical_gpus), "Logical GPUs")
print(len(gpus), "Physical GPUs,", len(
logical_gpus), "Logical GPUs")
except RuntimeError as e:
# Memory growth must be set before GPUs have been initialized
print(e)
@@ -47,7 +48,8 @@ def mobilenet_nnconv5(weights=None, shape=(224, 224, 3)):
:return: FastDepth keras Model
"""
input = keras.layers.Input(shape=shape)
mobilenet = keras.applications.MobileNet(input_tensor=input, include_top=False, weights=weights)
mobilenet = keras.applications.MobileNet(
input_shape=shape, input_tensor=input, include_top=False, weights=weights)
for layer in mobilenet.layers:
layer.trainable = True
@@ -57,13 +59,16 @@ def mobilenet_nnconv5(weights=None, shape=(224, 224, 3)):
x = keras.layers.UpSampling2D()(x)
x = FDDepthwiseBlock(x, 256, block_id=15)
x = keras.layers.UpSampling2D()(x)
x = keras.layers.Add()([x, mobilenet.get_layer(name="conv_pw_5_relu").output])
x = keras.layers.Add()(
[x, mobilenet.get_layer(name="conv_pw_5_relu").output])
x = FDDepthwiseBlock(x, 128, block_id=16)
x = keras.layers.UpSampling2D()(x)
x = keras.layers.Add()([x, mobilenet.get_layer(name="conv_pw_3_relu").output])
x = keras.layers.Add()(
[x, mobilenet.get_layer(name="conv_pw_3_relu").output])
x = FDDepthwiseBlock(x, 64, block_id=17)
x = keras.layers.UpSampling2D()(x)
x = keras.layers.Add()([x, mobilenet.get_layer(name="conv_pw_1_relu").output])
x = keras.layers.Add()(
[x, mobilenet.get_layer(name="conv_pw_1_relu").output])
x = FDDepthwiseBlock(x, 32, block_id=18)
x = keras.layers.UpSampling2D()(x)
@@ -163,8 +168,10 @@ def crop_and_resize(x):
def layer():
return keras.Sequential([
keras.layers.experimental.preprocessing.CenterCrop(shape[1], shape[2]),
keras.layers.experimental.preprocessing.Resizing(224, 224, interpolation='nearest')
keras.layers.experimental.preprocessing.CenterCrop(
shape[1], shape[2]),
keras.layers.experimental.preprocessing.Resizing(
224, 224, interpolation='nearest')
])
# Reshape label to 4d, can't use array unwrap as it's unsupported by tensorflow