I'm creating a simple model to test the transfer learning capabilities offered by hub.KerasLayer in this way:
m = tf.keras.Sequential([
hub.KerasLayer("https://tfhub.dev/google/tf2-preview/inception_v3/feature_vector/2", output_shape=[2048],
trainable=False),
tf.keras.layers.Dense(5)
])
The code runs correctly, but every time I build the model it freezes without giving any output until it downloads the module (I guess).
I guess it could be useful to add a progress bar (optional?) when the module is downloading and preparing the layer.
Info:
Hey @vbardiovskyg Can I work on this?
Hi Paolo and Adrish,
there is already a progress bar implemented and can be turned on by setting an environment variable defined here: https://github.com/tensorflow/hub/blob/d3de17ac3f7f82336a3812f58729676a46be22d7/tensorflow_hub/resolver.py#L47.
import os
os.environ['TFHUB_DOWNLOAD_PROGRESS'] = "1"
oh cool, thanks! It is something official enabling it in this way or it is a hack?
(asking because I'm writing a book and I'm writing about hub.KerasLayer and it would be nice to write something official about how to enable the progress bar)
oh cool, thanks! It is something official enabling it in this way or it is a hack?
(asking because I'm writing a book and I'm writing about
hub.KerasLayerand it would be nice to write something official about how to enable the progress bar)
I went through the resolver.py looks like it's official.
https://github.com/tensorflow/hub/blob/54a242de6e148d0836c4a58308b07bbe79c274b6/tensorflow_hub/resolver.py#L132-L144
It's a public API, although not part of the functional one and maybe not very well documented.
Perfect, thank you for the info!
Closing this issue as it has been resolved.
Most helpful comment
Hi Paolo and Adrish,
there is already a progress bar implemented and can be turned on by setting an environment variable defined here: https://github.com/tensorflow/hub/blob/d3de17ac3f7f82336a3812f58729676a46be22d7/tensorflow_hub/resolver.py#L47.