Closed
Description
模型串并联问题,如下图,先目标检测,然后根据检测结果再对图片进行分割,分割之后进行图像分类;然后和另一个目标检测的结果进行结果组合。最后一个OP不进行模型预测,只进行前面input_ops的预测结果进行整合。
启动报错
组合模型的代码
class CombineOp(Op):
def preprocess(self, input_data, data_id, log_id):
out_data = {}
for op_name, data in input_data.items():
if 'bbox_result' in data.keys():
_LOGGER.info("{}: {}".format(op_name, data['bbox_result']))
out_data[op_name] = str(data['bbox_result'])
else:
data_str = json.dumps(data).replace('"', "'").replace("'[", "[").replace("]'", "]")
_LOGGER.info("{}: {}".format(op_name, data_str))
out_data[op_name] = data_str
return out_data, True, None, ""
当图像分类OP的input_ops中包含read_op也会报同样错误.
关键代码
if type == "start":
op_map[id] = read_op
# continue
elif type == "end":
input_ops = []
for input_id in inputIds:
input_ops.append(op_map[input_id])
res_op = CombineOp("combine", input_ops=input_ops)
op_map[id] = res_op
else:
modelId = op["modelId"]
input_ops = []
op_temp = None
if inputIds is None:
input_ops.append(read_op)
else:
for input_id in inputIds:
input_ops.append(op_map[input_id])
if type == "classification":
op_temp = ClassificationOp(name=modelId, input_ops=input_ops)
else:
op_temp = DetectionOp(name=modelId, input_ops=input_ops)
op_map[id] = op_temp
起始节点为read_op, 结束节点为CombineOp(组合OP,不进行模型预测)
目标检测OP根据前置OP组合input_ops
op_map为一个字典{OP的id: 对应OP}
Metadata
Assignees
Labels
No labels
Activity