I am using the latest version of tensorflow hub, and wondering how one gets information on a model's expected input shape, as well as on what type of collection the model belongs to. For example, is there a way to get info on the expected image shape after having loaded a model in Python this way?
model = hub.load("https://tfhub.dev/tensorflow/faster_rcnn/inception_resnet_v2_640x640/1")
or this way?
model = hub.KerasLayer("https://tfhub.dev/tensorflow/faster_rcnn/inception_resnet_v2_640x640/1")
It seems that the model object in neither case knows what the expected shape is - both in terms of image height/width, and batch size. On the other hand, this info can be found through load_module_spec
for older TF models...
One more question: is there a way to get information programmatically on which "problem domain" the model belongs to? It can be looked up on https://tfhub.dev/, but what if one needed to access that info from model object itself or via tensorflow_hub
functions?
Thanks!
you can get shape of input which model expects, from accessing first layer of the model, and accessing input_shape attribute of that layer
layers = model.layers
first_layer = layers[0] # usually the first layer is the input layer
print(first_layer.input_shape)
output:
[(None, 100, 100, 3)] # sample output
None -> this specifies the size of batch size, inference is that batch size can be anything you specify
(100, 100, 3) -> height, width and channels, can vary and input data you give should be strictly the same.
finding the domain of the trained model is little bit tricky through programming, you can plot the model's graph using tensorflow.keras.util.plot_model and can infer domain from model's architecture.