From ceb33d5d2c5d13e166fdf3496c52c3f6fa5f500b Mon Sep 17 00:00:00 2001 From: Andrew Sidhu Date: Sun, 19 Apr 2020 16:25:26 -0400 Subject: [PATCH] Fix model loading - Using tensorflow1.15@nv43 --- .gitattributes | 1 - models/dmonitoring_model.model.keras | 4 ++-- models/dmonitoring_model.weights.keras | 2 +- models/supercombo.keras | 4 ++-- models/supercombo.model.keras | 4 ++-- models/supercombo.weights.keras | 4 ++-- selfdrive/modeld/runners/keras_runner.py | 11 ++++------- 7 files changed, 13 insertions(+), 17 deletions(-) diff --git a/.gitattributes b/.gitattributes index 344099bbb2cd76..59daef89180f77 100644 --- a/.gitattributes +++ b/.gitattributes @@ -25,4 +25,3 @@ models/segnet2.keras filter=lfs diff=lfs merge=lfs -text external/opencl/*.deb filter=lfs diff=lfs merge=lfs -text phonelibs/zmq/aarch64-linux/lib/libzmq.a filter=lfs diff=lfs merge=lfs -text external/azcopy/azcopy filter=lfs diff=lfs merge=lfs -text -models/** filter=lfs diff=lfs merge=lfs -text diff --git a/models/dmonitoring_model.model.keras b/models/dmonitoring_model.model.keras index ad253ad5dda40a..03fdf4cc4191a4 100644 --- a/models/dmonitoring_model.model.keras +++ b/models/dmonitoring_model.model.keras @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:13856f9d455d59abe2a628e1c8b2ce4bc0d7edd09ef0d6f4282f0c5f306bb022 -size 17826 +oid sha256:96404515465ab0f99cbf52a926683328ab537b6f6431c2638b3ed5bea96ee4bf +size 18679 diff --git a/models/dmonitoring_model.weights.keras b/models/dmonitoring_model.weights.keras index f3bd414adbc12d..c7dff0f15950ff 100644 --- a/models/dmonitoring_model.weights.keras +++ b/models/dmonitoring_model.weights.keras @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b7ae5124600736da2ce9fcbb4c24cc5c7b253e5f1277eaf6c4d7be8ed3a1b88e +oid sha256:06b1fb45a130792df779a577dd176b2590fc526edafafec3d04bf9629cc09142 size 794160 diff --git a/models/supercombo.keras b/models/supercombo.keras index 28ff650039e9e7..75c4c4ac064e3c 100644 --- a/models/supercombo.keras +++ b/models/supercombo.keras @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a1117c34748527a18ef0e7f544d497b3644b2740b0edd546e38f44884e7bdc91 -size 70682708 +oid sha256:9a2110c9c13aa1aead362bea78497a9c3fca255deab5a324ac4e9a8f39d0cd23 +size 79200720 diff --git a/models/supercombo.model.keras b/models/supercombo.model.keras index e377716512e426..1d4d14fb2569fd 100644 --- a/models/supercombo.model.keras +++ b/models/supercombo.model.keras @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a707e53fc83cb7054620d2430fa0c4c9918b39d3163a7f2d0bb333fbfffa5ff2 -size 144609 +oid sha256:61cd41d0822557306fb8e159f589b4a83aa92bb82429d0a3c6ac08651894ccb0 +size 158389 diff --git a/models/supercombo.weights.keras b/models/supercombo.weights.keras index f11c21ab0252e3..be27134183e6ab 100644 --- a/models/supercombo.weights.keras +++ b/models/supercombo.weights.keras @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dbf0f692f28348c11b280defb11e2e6963619e891eb62621027d9f63e42fb34f -size 70538412 +oid sha256:73b0515f48f6f160a1bc8393318b9a4186cd501c9d2bf0fb25f7bd7e71d516e8 +size 79041128 diff --git a/selfdrive/modeld/runners/keras_runner.py b/selfdrive/modeld/runners/keras_runner.py index 42791722955c39..ffd49059f1eb65 100755 --- a/selfdrive/modeld/runners/keras_runner.py +++ b/selfdrive/modeld/runners/keras_runner.py @@ -42,15 +42,12 @@ def run_loop(m): if len(gpus) > 0: if os.path.splitext(os.path.basename(sys.argv[1]))[0]== "supercombo": tf.config.experimental.set_virtual_device_configuration(gpus[0], [tf.config.experimental.VirtualDeviceConfiguration(memory_limit=2548)]) - with open(f"{os.path.splitext(sys.argv[1])[0]}.model.keras", "r") as json_file: - m = model_from_json(json_file.read()) - m.load_weights(f"{os.path.splitext(sys.argv[1])[0]}.weights.keras") else: tf.config.experimental.set_virtual_device_configuration(gpus[0], [tf.config.experimental.VirtualDeviceConfiguration(memory_limit=256)]) - m = load_model(sys.argv[1], compile=False) - else: - m = load_model(sys.argv[1], compile=False) - + with open(f"{os.path.splitext(sys.argv[1])[0]}.model.keras", "r") as json_file: + m = model_from_json(json_file.read()) + m.load_weights(f"{os.path.splitext(sys.argv[1])[0]}.weights.keras") + bs = [int(np.product(ii.shape[1:])) for ii in m.inputs] ri = keras.layers.Input((sum(bs),)) tii = []