PaddlePaddle / PaddleX

All-in-One Development Tool based on PaddlePaddle(飞桨低代码开发工具)
Apache License 2.0
4.89k stars 958 forks source link

TypeError: Object of type BlockDesc is not JSON serializable #1390

Open luxu1220 opened 2 years ago

luxu1220 commented 2 years ago

描述问题

使用 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 
JingyuanZhang commented 2 years ago

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

luxu1220 commented 2 years ago

inference_model_picodet_esnet_l.zip 模型文件已上传

luxu1220 commented 2 years ago

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

luxu1220 commented 2 years ago

可能是 while 循环的问题? image

JingyuanZhang commented 2 years ago

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