From de2a163363eb885dbfe7367d4c6349204d1641de Mon Sep 17 00:00:00 2001 From: Svetlana Dolinina Date: Tue, 8 Jun 2021 16:09:04 +0300 Subject: [PATCH] Error during Caffe model conversion with Python3.8 (#6056) * added one more possible reason for Caffe error during caffemodel parser in code + add error description to FAQ Also added MxNet error to FAQ based on Kate Generalova wording * review fixes * wording polishing * wording polishing * review fixes * review fixes * Update docs/MO_DG/prepare_model/Model_Optimizer_FAQ.md Co-authored-by: Tatiana Savina * Update docs/MO_DG/prepare_model/Model_Optimizer_FAQ.md Co-authored-by: Tatiana Savina * Update docs/MO_DG/prepare_model/Model_Optimizer_FAQ.md Co-authored-by: Tatiana Savina * Update docs/MO_DG/prepare_model/Model_Optimizer_FAQ.md Co-authored-by: Tatiana Savina * review fixes Co-authored-by: Tatiana Savina --- docs/MO_DG/prepare_model/Model_Optimizer_FAQ.md | 14 +++++++++++++- model-optimizer/mo/front/caffe/loader.py | 8 +++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/docs/MO_DG/prepare_model/Model_Optimizer_FAQ.md b/docs/MO_DG/prepare_model/Model_Optimizer_FAQ.md index f9aef04a0a9..bb599cf93b5 100644 --- a/docs/MO_DG/prepare_model/Model_Optimizer_FAQ.md +++ b/docs/MO_DG/prepare_model/Model_Optimizer_FAQ.md @@ -627,4 +627,16 @@ It means that you trying to convert the topology which contains '_contrib_box_nm }); -\endhtmlonly \ No newline at end of file +\endhtmlonly + +#### 103. What does the message "ModelOptimizer is not able to parse *.caffemodel" mean? + +If a '*.caffemodel' file exists and it is correct, the error possibly occured due to the use of Python protobuf implementation. In some cases, it shows error message during model parsing, for example: "'utf-8' codec can't decode byte 0xe0 in position 4: invalid continuation byte in field: mo_caffe.SpatialTransformerParameter.transform_type". You can either use Python 3.6/3.7 or build 'cpp' implementation of protobuf yourself for your version of Python. For the complete instructions about building `protobuf` from sources, see the appropriate section in [Converting a Model to Intermediate Representation](Config_Model_Optimizer.md). + +#### 104. What does the message "SyntaxError: 'yield' inside list comprehension" during MxNet\* model conversion mean? + +The issue "SyntaxError: 'yield' inside list comprehension" might occur during converting MXNet\* models (mobilefacedet-v1-mxnet, brain-tumor-segmentation-0001) on Windows* platform with Python* 3.8 environment. This issue is caused by API changes for `yield expression` in Python 3.8. +The following workarounds are suggested to resolve this issue: +1. Use Python 3.6/3.7 to convert MXNet\* models on Windows +2. Update MXNet: pip install mxnet=1.7.0.post2 +Note that you might have conflicts between previously installed PyPI dependencies. \ No newline at end of file diff --git a/model-optimizer/mo/front/caffe/loader.py b/model-optimizer/mo/front/caffe/loader.py index 2ffca364fb6..14497c6108d 100644 --- a/model-optimizer/mo/front/caffe/loader.py +++ b/model-optimizer/mo/front/caffe/loader.py @@ -130,10 +130,16 @@ def load_caffe_proto_model(caffe_pb2, proto_path: str, model_path: [str, None] = map = mmap.mmap(infile.fileno(), 0, access=mmap.ACCESS_READ) model.MergeFromString(map) except Exception as e: + third_point = '' + if api_implementation._implementation_type == 'python': + third_point = ' 3. Python protobuf implementation was used. Some models can\'t be converted ' + \ + ' in this configuration. Please, use Python version with existing cpp implementation of ' + \ + 'protobuf library or build it by yourself\n' + refer_to_faq_msg(103) log.error('Exception message: {}\n\n'.format(e) + ' Possible reasons:\n' + ' 1. {} does not exist\n'.format(model_path) + - ' 2. {} does not have a valid structure\n'.format(model_path), extra={'framework_error': True}) + ' 2. {} does not have a valid structure\n'.format(model_path) + third_point, + extra={'framework_error': True}) raise FrameworkError('Model Optimizer is not able to parse {}'.format(model_path)) from e return proto, model