PaddleX icon indicating copy to clipboard operation
PaddleX copied to clipboard

TypeError: Object of type BlockDesc is not JSON serializable

Open luxu1220 opened this issue 3 years ago • 5 comments

描述问题

使用 paddlejsconverter 对 paddlex 中的 PicoDet 模型(已转换为 inference)转换时报错

TypeError: Object of type BlockDesc is not JSON serializable

  1. 您使用的模型数据集是?

PicoDet 数据集是钢筋计数项目

  1. 请提供您出现的报错信息及相关log
aistudio@jupyter-64630-3486734:~$ paddlejsconverter --modelPath=work/code/output/inference_model_picodet_esnet_l/inference_model/model.pdmodel --paramPath=work/code/output/inference_model_picodet_esnet_l/inference_model/model.pdiparams --outputDir=js_picodet_esnet_l
============Convert Model Args=============
modelPath: work/code/output/inference_model_picodet_esnet_l/inference_model/model.pdmodel
paramPath: work/code/output/inference_model_picodet_esnet_l/inference_model/model.pdiparams
outputDir: js_picodet_esnet_l
enableOptimizeModel: 1
enableLogModelInfo: 0
sliceDataSize:4096
Starting...
Optimizing model...
python paddlelite version: 2.7.1
WARNING: Logging before InitGoogleLogging() is written to STDERR
E0216 14:54:28.724778  9078 opt_base.cc:448] Error: This model is not supported, because 10 ops are not supported on 'arm'. These unsupported ops are: 'flatten_contiguous_range, lod_array_length, matmul_v2, meshgrid, multiclass_nms3, nearest_interp_v2, select_input, strided_slice, tensor_array_to_tensor, top_k_v2'.

Optimizing model failed.

Converting model...
Organizing model operators info...
A fetal error occured. Failed to convert model.
Traceback (most recent call last):
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/convertModel.py", line 535, in main
    convertToPaddleJSModel(modelDir, modelName, paramsName, outputDir)
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/convertModel.py", line 451, in convertToPaddleJSModel
    organizeModelOpInfo()
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/convertModel.py", line 331, in organizeModelOpInfo
    jsonDumpsIndentStr = json.dumps(opInfo, indent=2)
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type BlockDesc is not JSON serializable

============ALL DONE============

环境

aistudio

luxu1220 avatar Feb 16 '22 07:02 luxu1220

你好,可以提供一下 paddle 模型文件吗

JingyuanZhang avatar Feb 17 '22 08:02 JingyuanZhang

inference_model_picodet_esnet_l.zip 模型文件已上传

luxu1220 avatar Mar 10 '22 02:03 luxu1220

@JingyuanZhang 麻烦有空的时候看看 谢谢

luxu1220 avatar Mar 10 '22 02:03 luxu1220

可能是 while 循环的问题? image

luxu1220 avatar Mar 10 '22 03:03 luxu1220

这个模型 有部分算子 paddle.js 还不支持~ 我们需要看一下

JingyuanZhang avatar Mar 10 '22 04:03 JingyuanZhang