Skip to content

  • 体验新版
    • 正在加载...
  • 登录
  • PaddlePaddle
  • models
  • Issue
  • #2241

M
models
  • 项目概览

PaddlePaddle / models
大约 2 年 前同步成功

通知 232
Star 6828
Fork 2962
  • 代码
    • 文件
    • 提交
    • 分支
    • Tags
    • 贡献者
    • 分支图
    • Diff
  • Issue 602
    • 列表
    • 看板
    • 标记
    • 里程碑
  • 合并请求 255
  • Wiki 0
    • Wiki
  • 分析
    • 仓库
    • DevOps
  • 项目成员
  • Pages
M
models
  • 项目概览
    • 项目概览
    • 详情
    • 发布
  • 仓库
    • 仓库
    • 文件
    • 提交
    • 分支
    • 标签
    • 贡献者
    • 分支图
    • 比较
  • Issue 602
    • Issue 602
    • 列表
    • 看板
    • 标记
    • 里程碑
  • 合并请求 255
    • 合并请求 255
  • Pages
  • 分析
    • 分析
    • 仓库分析
    • DevOps
  • Wiki 0
    • Wiki
  • 成员
    • 成员
  • 收起侧边栏
  • 动态
  • 分支图
  • 创建新Issue
  • 提交
  • Issue看板
已关闭
开放中
Opened 5月 15, 2019 by saxon_zh@saxon_zhGuest

yolov3 评估mAP出错

Created by: ellinyang

修改了yolov3的tran.py和yolov3的代码,以便在训练中评估测试集mAP。 yolov3 修改了几处: 1.在bulid_input中修改测试集的数据格式 self.test_py_reader = fluid.layers.py_reader( capacity=64, shapes=[[-1] + self.image_shape, [-1, 1], [-1, 2], [-1, 4], [-1, 1], [-1, 1]], lod_levels=[0, 0, 1, 1,1,1], dtypes=['float32'] + ['int32'] *2+ ['float32']+['int32']+ ['float32'], use_double_buffer=True) print("test_input")

        self.image,  self.im_id, self.im_shape,self.gtbox, self.gtlabel, self.gtscore = \
            fluid.layers.read_file(self.test_py_reader)

2.预测环节,添加mAP计算 def get_pred(self): yolo_boxes = fluid.layers.concat(self.boxes, axis=1) yolo_scores = fluid.layers.concat(self.scores, axis=2) nmsed_out=fluid.layers.multiclass_nms( bboxes=yolo_boxes, scores=yolo_scores, score_threshold=cfg.valid_thresh, nms_top_k=cfg.nms_topk, keep_top_k=cfg.nms_posk, nms_threshold=cfg.nms_thresh, background_label=-1, name="multiclass_nms") print("nmsed_out:{}".format(nmsed_out)) print("11111") print(" self.gtlabel:{}".format(self.gtlabel)) print(" self.gtbox:{}".format(self.gtbox)) map_eval = fluid.metrics.DetectionMAP( nmsed_out, self.gtlabel, self.gtbox, self.gtscore, class_num=self.class_num, overlap_threshold=0.5, evaluate_difficult=False, ap_version='integral') return [map_eval,nmsed_out]

train.py中关键测试代码 def test(epoc_id, best_map): cur_map, accum_map = map_eval.get_map_var() #print("accum_map:{}".format(accum_map)) fetch_test_list = [cur_map, accum_map] map_eval.reset(exe) every_epoc_map=[] # for CE accum_map_v=[0.] try: batch_id = 0 test_py_reader.start() while True: print("test batch :{}".format(batch_id)) _, accum_map_v= exe.run(test_prog, fetch_list=fetch_test_list,use_program_cache=True) print("batch_id:{},accM_map_v:{}".format(batch_id,accum_map_v)) if batch_id % 10 == 0: every_epoc_map.append(accum_map_v) print("Batch {0}, map {1}".format(batch_id, accum_map_v)) batch_id += 1 except fluid.core.EOFException: test_py_reader.reset() mean_map = np.mean(every_epoc_map) print("Epoc {0}, test map {1}".format(epoc_id, accum_map_v[0])) if accum_map_v[0] > best_map: best_map = accum_map_v[0] save_model('best_model', test_prog) return best_map, mean_map

一旦训练到 调用测试程序时 出现会出现如下问题: Traceback (most recent call last): File "train.py", line 313, in train() File "train.py", line 304, in train best_map, mean_map = test(epoch_id, best_map) File "train.py", line 230, in test , accum_map_v= exe.run(test_prog, fetch_list=fetch_list) File "/usr/local/lib/python2.7/dist-packages/paddle/fluid/executor.py", line 625, in run use_program_cache=use_program_cache) File "/usr/local/lib/python2.7/dist-packages/paddle/fluid/executor.py", line 702, in run exe.run(program.desc, scope, 0, True, True, fetch_var_name) paddle.fluid.core.EnforceNotMet: Invoke operator concat error. Python Callstacks: File "/usr/local/lib/python2.7/dist-packages/paddle/fluid/framework.py", line 1689, in append_op attrs=kwargs.get("attrs", None)) File "/usr/local/lib/python2.7/dist-packages/paddle/fluid/layer_helper.py", line 43, in append_op return self.main_program.current_block().append_op(args, kwargs) File "/usr/local/lib/python2.7/dist-packages/paddle/fluid/layers/tensor.py", line 203, in concat attrs={'axis': axis}) File "/usr/local/lib/python2.7/dist-packages/paddle/fluid/metrics.py", line 645, in init label = layers.concat([gt_label, gt_difficult, gt_box], axis=1) File "/home/yanglijuan/DLcode/models/PaddleCV/yolov3/models/yolov3.py", line 242, in get_pred ap_version='integral') File "train.py", line 87, in build_program map_eval,nmsed_out= model_test.get_pred() File "train.py", line 133, in train is_train=False) File "train.py", line 313, in train() C++ Callstacks: Enforce failed. Expected out_dims[j] == ins[i][j], but received out_dims[j]:1 != ins[i][j]:9. Input tensors should have the same elements except the specify axis. at [/paddle/paddle/fluid/operators/concat_op.cc:68] PaddlePaddle Call Stacks: 0 0x7f8638158268p void paddle::platform::EnforceNotMet::Initstd::string(std::string, char const, int) + 360 1 0x7f86381585b7p paddle::platform::EnforceNotMet::EnforceNotMet(std::string const&, char const, int) + 87 2 0x7f86385c62bbp paddle::operators::ConcatOp::InferShape(paddle::framework::InferShapeContext) const + 1275 3 0x7f8639e86b4ep paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void, boost::detail::variant::void, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&, paddle::framework::RuntimeContext*) const + 302 4 0x7f8639e86f71p paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&) const + 545 5 0x7f8639e845acp paddle::framework::OperatorBase::Run(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&) + 332 6 0x7f86382d52eep paddle::framework::Executor::RunPreparedContext(paddle::framework::ExecutorPrepareContext*, paddle::framework::Scope*, bool, bool, bool) + 382 7 0x7f86382d612fp paddle::framework::Executor::Run(paddle::framework::ProgramDesc const&, paddle::framework::Scope*, int, bool, bool, std::vector<std::string, std::allocatorstd::string > const&, bool) + 143 8 0x7f863814787ep 9 0x7f863818cfa6p 10 0x4c5326p PyEval_EvalFrameEx + 37958 11 0x4b9b66p PyEval_EvalCodeEx + 774 12 0x4c1f56p PyEval_EvalFrameEx + 24694 13 0x4b9b66p PyEval_EvalCodeEx + 774 14 0x4c17c6p PyEval_EvalFrameEx + 22758 15 0x4b9b66p PyEval_EvalCodeEx + 774 16 0x4c1f56p PyEval_EvalFrameEx + 24694 17 0x4b9b66p PyEval_EvalCodeEx + 774 18 0x4c1f56p PyEval_EvalFrameEx + 24694 19 0x4b9b66p PyEval_EvalCodeEx + 774 20 0x4eb69fp 21 0x4e58f2p PyRun_FileExFlags + 130 22 0x4e41a6p PyRun_SimpleFileExFlags + 390 23 0x4938cep Py_Main + 1358 24 0x7f86b3387830p __libc_start_main + 240 25 0x493299p _start + 41

指派人
分配到
无
里程碑
无
分配里程碑
工时统计
无
截止日期
无
标识: paddlepaddle/models#2241
渝ICP备2023009037号

京公网安备11010502055752号

网络110报警服务 Powered by GitLab CE v13.7
开源知识
Git 入门 Pro Git 电子书 在线学 Git
Markdown 基础入门 IT 技术知识开源图谱
帮助
使用手册 反馈建议 博客
《GitCode 隐私声明》 《GitCode 服务条款》 关于GitCode
Powered by GitLab CE v13.7