How to make Tensorflow vid2depth inference works? - tensorflow

I tried to test Tensorflow's vid2depth inference (https://github.com/tensorflow/models/tree/master/research/vid2depth).
I followed the instruction of the README. However, I got the below error:
ValueError: Couldn't find 'checkpoint' file or checkpoints in given directory vid2depth/trained-model/model-119496
I test with tf 0.12, 1.0.0. 1.8 and 1.15.
I used the below command:
python3.6 inference.py --kitti_dir ~/vid2depth/kitti-raw-uncompressed --output_dir ~/vid2depth/inference --kitti_video 2011_09_26/2011_09_26_drive_0009_sync --model_ckpt ~/vid2depth/trained-model/model-119496/
The content of the checkpoint folder I downloaded is:
model-119496.data-00000-of-00001 model-119496.index model-119496.meta
It seems provided files are not in the correct format, but I followed the link of the README.
It seems to be an old checkpoint format (Loading older checkpoint in tensorflow).
Could anyone make vid2depth works?
Thank you.

Related

Grappler optimization failed. Error: Op type not registered 'FusedBatchNormV3' in Tensorflow Serving

I am serving a model using Tensorflow Serving.
TensorFlow ModelServer: 1.13.0-rc1+dev.sha.fd92d2f
TensorFlow Library: 1.13.0-rc1
I sanity tested with load_model and predict(...) in notebook and it is making the expected predictions. The model is a ResNet50 with custom head (fine tuned).
If i try to submit the request as instructed in:
https://www.tensorflow.org/tfx/tutorials/serving/rest_simple
I got error
2022-02-10 22:22:09.120103: W external/org_tensorflow/tensorflow/core/kernels/partitioned_function_ops.cc:197] Grappler optimization failed. Error: Op type not registered 'FusedBatchNormV3' in binary running on tensorflow-no-gpu-20191205-rec-eng. Make sure the Op and Kernel are registered in the binary running in this process. Note that if you are loading a saved graph which used ops from tf.contrib, accessing (e.g.) `tf.contrib.resampler` should be done before importing the graph, as contrib ops are lazily registered when the module is first accessed.
2022-02-10 22:22:09.137225: W external/org_tensorflow/tensorflow/core/framework/op_kernel.cc:1401] OP_REQUIRES failed at partitioned_function_ops.cc:118 : Not found: Op type not registered 'FusedBatchNormV3' in binary running on tensorflow-no-gpu-20191205-rec-eng. Make sure the Op and Kernel are registered in the binary running in this process. Note that if you are loading a saved graph which used ops from tf.contrib, accessing (e.g.) `tf.contrib.resampler` should be done before importing the graph, as contrib ops are lazily registered when the module is first accessed.
Any idea how to resolve? Will provide more details upon request.
I found out what's wrong. the tensorflow server version seemed wrong. Just ensure it is:
TensorFlow ModelServer: 2.8.0-rc1+dev.sha.9400ef1
TensorFlow Library: 2.8.0

OSError: [E053] Could not read config.cfg from C:\Users

I'm trying to run spaCY's lemmatizer on a text by running the command nlp = spacy.load("en_core_web_sm", disable=["parser", "ner"]), but then I get the following error:
OSError: [E053] Could not read config.cfg from C:\Users.
I'm using spaCy version 3.2.1, and I also installed en-core-web-sm-2.2.0.
I also get this warning, but I'm not sure what it means:
UserWarning: [W094] Model 'en_core_web_sm' (2.2.0) specifies an under-constrained spaCy version requirement: >=2.2.0. This can lead to compatibility problems with older versions, or as new spaCy versions are released, because the model may say it's compatible when it's not. Consider changing the "spacy_version" in your meta.json to a version range, with a lower and upper pin. For example: >=3.2.1,<3.3.0.
Hope someone can help me.
A v2 spaCy model won't work with spaCy v3 - you need to update your model. Do this:
spacy download en_core_web_sm
The error could be easier to understand, but it's not a situation that comes up much - usually you'd have to upgrade from spaCy v2 to v3 but not upgrade your models for that to happen. Not sure how you got in that state.

ValueError: GRU(reset_after=False) is not compatible with GRU(reset_after=True)

How to solve this error which is raised when loading the weights from h5 file?
ValueError: GRU(reset_after=False) is not compatible with
GRU(reset_after=True)
Github link : https://github.com/emilwallner/Screenshot-to-code
Colab link : https://colab.research.google.com/drive/106_QEi_Wp6mfDDE1E2lPSPh7S9CABk6B#revisionId=0Byh7i7xj0YHlMU0xaTJCWDA3ZzZNTlA1VFFRWU5xQWdtc2tFPQ
dataset drive link:
https://drive.google.com/drive/folders/1BTeUbXO7qBvOT4VkhOrr7SOcSocSZyeb?usp=sharing
set reset_after=True in your GRU layer
Probably the version of the TensorFlow is not compatible with other packages. Try using Tensorflow==1.15.0. You can install it by writing pip install TensorFlow==1.15.0

Is there any way to load FaceNet model as a tf.keras.layers.Layer using Tensorflow 2.3?

I want to use FaceNet as a embedding layer (which won't be trainable).
I tried loading FaceNet like so :
tf.keras.models.load_model('./path/tf_facenet')
where directory ./path/tf_facenet contains 4 files that can be downloaded at https://drive.google.com/file/d/0B5MzpY9kBtDVZ2RpVDYwWmxoSUk/edit
but a message error shows up :
OSError: SavedModel file does not exist at: ./path/tf_facenet/{saved_model.pbtxt|saved_model.pb}
And the h5 files downloaded from https://github.com/nyoki-mtl/keras-facenet doesn't seem to work either (they use tensorflow 1.3)
I had issued like you when load model facenet-keras. Maybe you python env missing h5py modules.
So you should install that conda install h5py
Hope you success!!!

Getting error on ML-Engine predict but local predict works fine

I have searched a lot here but unfortunately could not find an answer.
I am running TensorFlow 1.3 (installed via PiP on MacOS) on my local machine, and have created a model using the provided "ssd_mobilenet_v1_coco" checkpoints.
I managed to train locally and on the ML-Engine (Runtime 1.2), and successfully deployed my savedModel to the ML-Engine.
Local predictions (below code) work fine and I get the model results
gcloud ml-engine local predict --model-dir=... --json-instances=request.json
FILE request.json: {"inputs": [[[242, 240, 239], [242, 240, 239], [242, 240, 239], [242, 240, 239], [242, 240, 23]]]}
However when deploying the model and trying to run on the ML-ENGINE for remote predictions with the code below:
gcloud ml-engine predict --model "testModel" --json-instances request.json(SAME JSON FILE AS BEFORE)
I get this error:
{
"error": "Prediction failed: Exception during model execution: AbortionError(code=StatusCode.INVALID_ARGUMENT, details=\"NodeDef mentions attr 'data_format' not in Op<name=DepthwiseConv2dNative; signature=input:T, filter:T -> output:T; attr=T:type,allowed=[DT_FLOAT, DT_DOUBLE]; attr=strides:list(int); attr=padding:string,allowed=[\"SAME\", \"VALID\"]>; NodeDef: FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_1_depthwise/depthwise = DepthwiseConv2dNative[T=DT_FLOAT, _output_shapes=[[-1,150,150,32]], data_format=\"NHWC\", padding=\"SAME\", strides=[1, 1, 1, 1], _device=\"/job:localhost/replica:0/task:0/cpu:0\"](FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_0/Relu6, FeatureExtractor/MobilenetV1/Conv2d_1_depthwise/depthwise_weights/read)\n\t [[Node: FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_1_depthwise/depthwise = DepthwiseConv2dNative[T=DT_FLOAT, _output_shapes=[[-1,150,150,32]], data_format=\"NHWC\", padding=\"SAME\", strides=[1, 1, 1, 1], _device=\"/job:localhost/replica:0/task:0/cpu:0\"](FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_0/Relu6, FeatureExtractor/MobilenetV1/Conv2d_1_depthwise/depthwise_weights/read)]]\")"
}
I saw something similar here: https://github.com/tensorflow/models/issues/1581
About the problem being with the "data-format" parameter.
But unfortunately I could not use that solution since I am already on TensorFlow 1.3.
It also seems that it might be a problem with MobilenetV1: https:// github.com/ tensorflow/models/issues/2153
Any ideas?
I had a similar issue. This issue is due to mismatch in Tensorflow versions used for training and inference. I solved the issue by using Tensorflow - 1.4 for both training and inference.
Please refer to this answer.
If you're wondering how to ensure that your model version is running the correct tensorflow version that you need to run, first have a look at this model versions list page
You need to know which model version supports the Tensorflow version that you need. At the time of writing:
ML version 1.4 supports TensorFlow 1.4.0 and 1.4.1
ML version 1.2 supports TensorFlow 1.2.0 and
ML version 1.0 supports TensorFlow 1.0.1
Now that you know which model version you require, you need to create a new version from your model, like so:
gcloud ml-engine versions create <version name> \
--model=<Name of the model> \
--origin=<Model bucket link. It starts with gs://...> \
--runtime-version=1.4
In my case, I needed to predict using Tensorflow 1.4.1, so I used the runtime version 1.4.
Refer to this official MNIST tutorial page, as well as this ML Versioning Page