ubuntu上训练yolov5时自适应锚框计算报错

YOLOv5训练时报错,怎么才能解决这个问题啊

autoanchor: Analyzing anchors... anchors/target = 0.41, Best Possible Recall (BPR) = 0.0799. Attempting to improve anchors, please wait...
autoanchor: Running kmeans for 16 anchors on 12386 points...
autoanchor: ERROR: Numpy is not available
Traceback (most recent call last):
  File "train.py", line 630, in <module>
    main(opt)
  File "train.py", line 527, in main
    train(opt.hyp, opt, device, callbacks)
  File "train.py", line 240, in train
    check_anchors(dataset, model=model, thr=hyp['anchor_t'], imgsz=imgsz)
  File "/home/lyy/yolov5/tph/utils/autoanchor.py", line 53, in check_anchors
    new_bpr = metric(anchors)[0]
  File "/home/lyy/yolov5/tph/utils/autoanchor.py", line 36, in metric
    r = wh[:, None] / k[None]
RuntimeError: The size of tensor a (12386) must match the size of tensor b (4) at non-singleton dimension 1

使用 pip 或 conda 安装Numpy模块以解决此问题。但请确保您已将其安装在当前工作环境中。

两个tensor维度有问题,代码 数据改动过吗

img


先看下你的numpy和torch版本是否能够匹配上,或者像楼上说的pip install --upgrade numpy更新下numpy版本。
然后除了data数据集的位置和类别数目之外,你还你改动了哪里的代码了?如果不知道的话重新git clone或者下载最新源码重新看下。