Tensorflow: Quantized graph not working for inception-resnet-v2 model - tensorflow

I did quantization on inception-resnet-v2 model using https://www.tensorflow.org/performance/quantization#how_can_you_quantize_your_models.
Size of freezed graph(input for quantization) is 224,6 MB and quantized graph is 58,6 MB. I ran accuracy test for certain dataset wherein, for freezed graph the accuracy is 97.4% whereas for quantized graph it is 0%.
Is there a different way to quantize the model for inception-resnet versions? or, for inception-resnet model, quantization is not support at all?

I think they transitioned from quantize_graph to graph_transforms. Try using this:
https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools/graph_transforms
And what did you use for the input nodes/output nodes when testing?

Related

Lower validation accuracy on ImageNet when evaluating Keras pre-trained models

I want to work with Keras models pre-trained on ImageNet. The models and information about their performance are here.
I downloaded ILSVRC 2012 (ImageNet) dataset and evaluated ResNet50 on the validation dataset. The top-1 accuracy should be 0.749 but I get 0.68. The top-5 accuracy should be 0.921, mine is 0.884. I also tried VGG16 and MobileNet with similar discrepancies.
I preprocess the images using built-in preprocess_input function (e.g. tensorflow.keras.applications.resnet50.preprocess_input()).
My guess is that the dataset is different. How can I make sure that the validation dataset that I use for evaluation is the same as the one that was used by the authors? Could there be any other reason why I get different results?

Adding Batch Dimension to tensorflow graph which was trained without batching support

I trained the network without batching, hence the input dimension of graph is (H,W,C) (not even [1,H,W,C]).
But during inference, I need predictions for multiple images (batched inference).
How can we achieve this

mobilenetv1 trained with custom dataset Quantization Size problem

I am working on an object detection software, basically i am using TensorFlow objet detection API on Python with MobileNetV1, i have trained the model with my own dataset.
The frozen_inference_graph.pb file resulting of the training with my dataset is like 22 Mo.
I tried to convert it to TFLite with quantization but it is still like 21.2 Mo.
Is it normal that these two sizes are 20+ Mo ? I have read from differents sources that MobileNet quantized models are around 5 Mo. It is because I trained it on my custom dataset with new objects ? And also, why quantizing it does not reduce size (up to 4 times smaller) ?
Thank you for your help

normalization image before using ssd_mobilenet

I try train ssd-mobilenet in my own dataset :
training image : 3400 with size :1600*1200
test set :800 with size :1600 *1200 tensorflow -gpu :1.13.1 gpu :4GB cuda 10.0 cudnn 7
object: road damage like aligator crack but after 197000 step my training loss cannot go down 2.
I have 2 questions
Should I normalize my training and set image before before using pretrained model like ssd_mobilenet?
If yes
Should I annotate images normalized or not ?
I need really helps. Thanks in advance
Should I normalize my training and set image before before using pretrained model like ssd_mobilenet?
No. Assuming you define your training pipeline correctly (see the examples in the TF Models repository), the Object detection API will take care of defining the appropriate image transformations (scaling, padding, normalization, etc) required in order to make the input compatible with the model.

Will tf.loadFrozenModel and tf.loadModel have different prediction time?

Assume that the model trained in tensorflow uses two methods to convert the models available to tensorflowjs:
1) Use the tf.saved_model.simple_save method to save the model in tensorflow, then use tf.loadFrozenModel to load the model in tensorflowjs and predict the result using model.predict
2) Use keras(sequence) to save the model in tensorflow, then use tf.loadModel to load the model in tensorflowjs and predict the result using model.predict
If you train the same model in tensorflow, but different save methods. In the tensorflowjs to use the above 2 load model method to predict the results, will the time difference?
If you have the same architecture in both tensorflowJs and keras, the inference time using tensorflowJs will be alike. tensorflowJs converter will just construct a graph of your topology and the weights. So in both cases the processing time is roughly the same