hukaixuan19970627 / yolov5_obb

yolov5 + csl_label.(Oriented Object Detection)(Rotation Detection)(Rotated BBox)基于yolov5的旋转目标检测
GNU General Public License v3.0
1.83k stars 427 forks source link

Typcasting float to long Runtime Error #539

Open gibotsgithub opened 1 year ago

gibotsgithub commented 1 year ago
 Epoch   gpu_mem       box       obj       cls     theta    labels  img_size

0%| | 0/4 [00:00<?, ?it/s]
Traceback (most recent call last): File "/home/server/scanning/python-server/ocri-python/app/test/harshal_yolo/yolov5_obb/train.py", line 633, in main(opt) File "/home/server/scanning/python-server/ocri-python/app/test/harshal_yolo/yolov5_obb/train.py", line 530, in main train(opt.hyp, opt, device, callbacks) File "/home/server/scanning/python-server/ocri-python/app/test/harshal_yolo/yolov5_obb/train.py", line 326, in train loss, loss_items = compute_loss(pred, targets.to(device)) # loss scaled by batch_size File "/home/server/scanning/python-server/ocri-python/app/test/harshal_yolo/yolov5_obb/utils/loss.py", line 135, in call tcls, tbox, indices, anchors, tgaussian_theta = self.build_targets(p, targets) # targets File "/home/server/scanning/python-server/ocri-python/app/test/harshal_yolo/yolov5_obb/utils/loss.py", line 265, in buildtargets indices.append((b, a, gj.clamp(0, featurewh[1] - 1), gi.clamp(0, feature_wh[0] - 1))) # image, anchor, grid indices RuntimeError: result type Float can't be cast to the desired output type long int

How do I fix this? It worked in colab, but not running on my laptop

ZHOU-ZHOU-YI commented 1 year ago

我遇到了相同的问题,解决方案看这个链接:https://blog.csdn.net/Thebest_jack/article/details/125649451

Stark-Bear commented 9 months ago

Needs to replace two lines in the file loss.py . 1、Replace “anchors = self.anchors[i] ” with "anchors, shape = self.anchors[i], p[i].shape" 2、Replace “indices.append((b, a, gj.clamp_(0, featurewh[1] - 1), gi.clamp(0, featurewh[0] - 1)))” with "indices.append((b, a, gj.clamp(0, shape[2] - 1), gi.clamp_(0, shape[3] - 1)))" .

In addition , after this has fixed , if anyone has the "AttributeError: 'FreeTypeFont' object has no attribute 'getsize' " , just tpye pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple Pillow==9.5 . Pillow >=10 has delete the attribute "getsize()"