问题描述:
TypeError: __init__() got an unexpected keyword argument 'serialized_options'
File "object_detection/builders/model_builder_test.py", line 24, in <module> from object_detection.builders import model_builder File "F:File_PythonPython_examplemodels-master esearchobject_detectionuildersmodel_builder.py", line 20, in <module> from object_detection.builders import anchor_generator_builder File "F:File_PythonPython_examplemodels-master esearchobject_detectionuildersanchor_generator_builder.py", line 21, in <module> from object_detection.protos import anchor_generator_pb2 File "F:File_PythonPython_examplemodels-master esearchobject_detectionprotosanchor_generator_pb2.py", line 15, in <module> from object_detection.protos import grid_anchor_generator_pb2 as object__detection_dot_protos_dot_grid__anchor__generator__pb2 File "F:File_PythonPython_examplemodels-master esearchobject_detectionprotosgrid_anchor_generator_pb2.py", line 22, in <module> serialized_pb=_b(' 3object_detection/protos/grid_anchor_generator.protox12x17object_detection.protos"xcdx01 x13GridAnchorGeneratorx12x13 x06heightx18x01 x01(x05:x03x32x35x36x12x12 x05widthx18x02 x01(x05:x03x32x35x36x12x19 height_stridex18x03 x01(x05:x02x31x36x12x18 x0cwidth_stridex18x04 x01(x05:x02x31x36x12x18 height_offsetx18x05 x01(x05:x01x30x12x17 x0cwidth_offsetx18x06 x01(x05:x01x30x12x0e x06scalesx18x07 x03(x02x12x15 aspect_ratiosx18x08 x03(x02') TypeError: __init__() got an unexpected keyword argument 'serialized_options'
解决方法:
类型错误:__init__()得到意外的关键字参数“serialized_options”
出现该问题,很有可能是,终端上的 protoc 版本 与python库内的protobuf版本不一样。
安装对应版本的库即可!比如我的执行下列命令
pip install -U protobuf
pip安装时-U参数是什么作用?
pip install -h
就有说明了,就是--upgrade
,意思是如果已安装就升级到最新版。-U 是升级 原来已经安装的包,如果有新版本,不带U不会装新版,带上才会更新到最新版本。
大功告成!完美解决!