On this page

Predict signature types from a numpy array of chips

from tensorflow import keras
import tensorflow as tf
import numpy
chips = numpy.load('../../chips/32_nw.npy')
model = keras.models.load_model("../../urbangrammar_samba/spatial_signatures/ai/gb_32_balanced_named_v2/model/efficientnet_pooling_256_12_best")
2022-03-24 14:21:22.658219: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1525] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 6460 MB memory:  -> device: 0, name: Quadro RTX 4000, pci bus id: 0000:21:00.0, compute capability: 7.5
inp = keras.layers.Input(shape=(32, 32, 3)) 
x = keras.layers.Resizing(224, 224, crop_to_aspect_ratio=True)(inp)
x = model(x, training=False)
model_pred = keras.Model(
        inp,
        x,
)
model_pred.compile()
proba = model_pred.predict(chips)
2022-03-24 14:21:49.000904: I tensorflow/stream_executor/cuda/cuda_dnn.cc:377] Loaded cuDNN version 8302
numpy.save("../../chips/32_nw_pred.npy", proba)
model = keras.models.load_model("../../urbangrammar_samba/spatial_signatures/ai/gb_32_multiclass/model/model_best")
2022-03-29 12:14:10.385140: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1525] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 6456 MB memory:  -> device: 0, name: Quadro RTX 4000, pci bus id: 0000:21:00.0, compute capability: 7.5
proba = model.predict(chips)
2022-03-29 12:14:38.568187: I tensorflow/stream_executor/cuda/cuda_dnn.cc:377] Loaded cuDNN version 8302
numpy.save("../../chips/32_nw_pred_multiclass.npy", proba)

64 MOR

chips = numpy.load('../../chips/64_nw.npy')
model = keras.models.load_model("../../urbangrammar_samba/spatial_signatures/ai/gb_64_multiclass/model/model_3_best")
2022-03-31 08:42:36.760482: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1525] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 6451 MB memory:  -> device: 0, name: Quadro RTX 4000, pci bus id: 0000:21:00.0, compute capability: 7.5
proba = model.predict(chips)
2022-03-31 08:42:57.412684: I tensorflow/stream_executor/cuda/cuda_dnn.cc:377] Loaded cuDNN version 8302
numpy.save("../../chips/64_nw_pred_multiclass.npy", proba)