0

I am following the procedures listed in the github, Quantization-aware training, https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/quantize. To quantize my own TF model, landing_retrained_graph.pb, I fed it into the instructions of quantizations.

freeze_graph \
  --input_graph=landing_retrained_graph.pb \
  --input_checkpoint=checkpoint \
  --output_graph=landing_frozen_eval_graph.pb --output_node_names=outputs

Then the error pops up like below.

(ztdl) Jisoos-MacBook-Pro:tf_files jisooyu$ freeze_graph \
>   --input_graph=landing_retrained_graph.pb \
>   --input_checkpoint=checkpoint \
>   --output_graph=landing_frozen_eval_graph.pb --output_node_names=outputs


Traceback (most recent call last):
  File "/Users/jisooyu/anaconda3/envs/ztdl/bin/freeze_graph", line 11, in <module>
    sys.exit(run_main())
  File "/Users/jisooyu/anaconda3/envs/ztdl/lib/python3.7/site-packages/tensorflow/python/tools/freeze_graph.py", line 487, in run_main
    app.run(main=my_main, argv=[sys.argv[0]] + unparsed)
  File "/Users/jisooyu/anaconda3/envs/ztdl/lib/python3.7/site-packages/tensorflow/python/platform/app.py", line 40, in run
    _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
  File "/Users/jisooyu/anaconda3/envs/ztdl/lib/python3.7/site-packages/absl/app.py", line 300, in run
    _run_main(main, args)
  File "/Users/jisooyu/anaconda3/envs/ztdl/lib/python3.7/site-packages/absl/app.py", line 251, in _run_main
    sys.exit(main(argv))
  File "/Users/jisooyu/anaconda3/envs/ztdl/lib/python3.7/site-packages/tensorflow/python/tools/freeze_graph.py", line 486, in <lambda>
    my_main = lambda unused_args: main(unused_args, flags)
  File "/Users/jisooyu/anaconda3/envs/ztdl/lib/python3.7/site-packages/tensorflow/python/tools/freeze_graph.py", line 378, in main
    flags.saved_model_tags, checkpoint_version)
  File "/Users/jisooyu/anaconda3/envs/ztdl/lib/python3.7/site-packages/tensorflow/python/tools/freeze_graph.py", line 338, in freeze_graph
    input_graph_def = _parse_input_graph_proto(input_graph, input_binary)
  File "/Users/jisooyu/anaconda3/envs/ztdl/lib/python3.7/site-packages/tensorflow/python/tools/freeze_graph.py", line 253, in _parse_input_graph_proto
    text_format.Merge(f.read(), input_graph_def)
  File "/Users/jisooyu/anaconda3/envs/ztdl/lib/python3.7/site-packages/tensorflow/python/lib/io/file_io.py", line 128, in read
    pywrap_tensorflow.ReadFromStream(self._read_buf, length))
  File "/Users/jisooyu/anaconda3/envs/ztdl/lib/python3.7/site-packages/tensorflow/python/lib/io/file_io.py", line 98, in _prepare_value
    return compat.as_str_any(val)
  File "/Users/jisooyu/anaconda3/envs/ztdl/lib/python3.7/site-packages/tensorflow/python/util/compat.py", line 117, in as_str_any
    return as_str(value)
  File "/Users/jisooyu/anaconda3/envs/ztdl/lib/python3.7/site-packages/tensorflow/python/util/compat.py", line 87, in as_text
    return bytes_or_text.decode(encoding)

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 55: invalid continuation byte

Any suggestions to fix the error are appreciated.

passion
  • 387
  • 4
  • 16
  • Hello Passion, did you tried post-training full integer quantization with a small calibration data-set? I quantized my .pb with that. – MMH Sep 30 '19 at 06:54
  • 1
    @MMH I will try that. Thank you. – passion Sep 30 '19 at 08:25
  • Hi Passion did it work? then I will write an answer here so that people get direction – MMH Oct 10 '19 at 04:53
  • Somehow it did not work. I took a completely different approach. 1. generating xml files of images using labelImg, 2. convert xml into csv using xml_to_csv.py, 3. producing TFRecord using generate_tfrecord.py, 4. making pb using export_tflite_ssd_graph.py – passion Oct 10 '19 at 06:38
  • cool, then you should post your approach in the answer, it will help many people – MMH Oct 10 '19 at 07:07
  • First of all, I should ensure whether my approach is correct. The conversion from the grap file to the tflite model was successful. But when I compile the tflite model for the edgetpu, the error pops up. I don't know why. The conversion from the graph to the tflite could be the source of the problem. When I fix the issue, I will post it. Thank you for your advice. – passion Oct 10 '19 at 09:38

0 Answers0