Zzh-tju/CIoU

训练

yishunzhijian opened this issue · 17 comments

训练自己的数据集出现这个问题,请问怎么修改程序?
Traceback (most recent call last):
File "train.py", line 25, in
import eval as eval_script
File "/home/song/CIoU-master/eval.py", line 882
net.detect.use_cluster_nms = args.cluster_nms
^
TabError: inconsistent use of tabs and spaces in indentation

这个是对应位置的缩进不对齐所致,我上传的文件在我本地上都是对齐的,可能有些地方上传后不对齐了,你需要调整一下,再运行eval.py

这个是对应位置的缩进不对齐所致,我上传的文件在我本地上都是对齐的,可能有些地方上传后不对齐了,你需要调整一下,再运行eval.py

这修改好之后出现新问题,我觉得下面eval.py程序需要改一下:
if args.cross_class_nms = True:
nms='cross class'
else:
nms='not use cross class'
if args.fast_nms = True:
num_count = num_count + 1
if args.cluster_nms = True:
num_count = num_count + 1
if args.cluster_diounms = True:
num_count = num_count + 1
if args.spm = True:
num_count = num_count + 1
if args.spm_dist = True:
num_count = num_count + 1
if args.spm_dist_weighted = True:

改成
if args.cross_class_nms == True:
nms='cross class'
else:
nms='not use cross class'
if args.fast_nms == True:
num_count = num_count + 1
if args.cluster_nms == True:
num_count = num_count + 1
if args.cluster_diounms == True:
num_count = num_count + 1
if args.spm == True:
num_count = num_count + 1
if args.spm_dist == True:
num_count = num_count + 1
if args.spm_dist_weighted == True:
num_count = num_count + 1

训练出现了新的问题:
Traceback (most recent call last):
File "train.py", line 504, in
train()
File "train.py", line 371, in train
compute_validation_map(epoch, iteration, yolact_net, val_dataset, log if args.log else None)
File "train.py", line 492, in compute_validation_map
val_info = eval_script.evaluate(yolact_net, dataset, train_mode=True)
File "/home/song/CIoU-master/eval.py", line 964, in evaluate
preds = net(batch)
File "/home/song/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(*input, **kwargs)
File "/home/song/CIoU-master/yolact.py", line 676, in forward
return self.detect(pred_outs, self)
File "/home/song/CIoU-master/layers/functions/detection.py", line 76, in call
result = self.detect(batch_idx, conf_preds, decoded_boxes, mask_data, inst_data)
File "/home/song/CIoU-master/layers/functions/detection.py", line 122, in detect
boxes, masks, classes, scores = self.cluster_diounms(boxes, masks, scores, self.nms_thresh, self.top_k)
File "/home/song/CIoU-master/layers/functions/detection.py", line 347, in cluster_diounms
scores, idx = scores.sort(1, descending=True)
IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1)
请问这个怎么改?

eval.py中,换成其他的nms看看是否会报错,比如fast_nms

eval.py中,换成其他的nms看看是否会报错,比如fast_nms

fast_nms好使,可以训练,其他的有相同的问题

这就很奇怪了,因为我看你报错是cluster_diounms的第一步scores.sort(1, descending=True),而这一步对fast_nms也是一样的第一步。详情可查看layers/functions/detection.py

这就很奇怪了,因为我看你报错是cluster_diounms的第一步scores.sort(1, descending=True),而这一步对fast_nms也是一样的第一步。详情可查看layers/functions/detection.py

其他的nms都可以训练,就这个还是有问题 spm_dist_weighted
Traceback (most recent call last):
File "train.py", line 504, in
train()
File "train.py", line 371, in train
compute_validation_map(epoch, iteration, yolact_net, val_dataset, log if args.log else None)
File "train.py", line 492, in compute_validation_map
val_info = eval_script.evaluate(yolact_net, dataset, train_mode=True)
File "/home/song/CIoU-master/eval.py", line 964, in evaluate
preds = net(batch)
File "/home/song/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(*input, *kwargs)
File "/home/song/CIoU-master/yolact.py", line 676, in forward
return self.detect(pred_outs, self)
File "/home/song/CIoU-master/layers/functions/detection.py", line 76, in call
result = self.detect(batch_idx, conf_preds, decoded_boxes, mask_data, inst_data)
File "/home/song/CIoU-master/layers/functions/detection.py", line 128, in detect
boxes, masks, classes, scores = self.cluster_SPM_dist_weighted_nms(boxes, masks, scores, self.nms_thresh, self.top_k)
File "/home/song/CIoU-master/layers/functions/detection.py", line 489, in cluster_SPM_dist_weighted_nms
weights = (B
(B>0.8).float() + torch.eye(n).cuda().expand(80,n,n)) * (scores.unsqueeze(2).expand(80,n,n))
RuntimeError: The size of tensor a (4) must match the size of tensor b (80) at non-singleton dimension 0

detection.py的489行改成 weights = (B*(B>0.8).float() + torch.eye(n).cuda().expand(4,n,n)) * (scores.unsqueeze(2).expand(4,n,n))(scores.unsqueeze(2).expand(4,n,n))就可以训练了

请问加入ciou损失和Cluster-NMS后,为什么ap mask的值会提升?我的理解是ap box会提升,因为是对边界框的优化。yolact检测和分割是分开进行的,如何解释ap mask会提升呢?谢谢回复。

YOLACT是基于检测的实例分割算法,因此box会影响裁剪出的mask的效果

YOLACT是基于检测的实例分割算法,因此box会影响裁剪出的mask的效果

可以讲的具体一点嘛,因为分割分支直接产生mask,似乎和box没什么关系

你看NMS的代码,mask是根据box的结果来裁剪的。box越正确,mask的结果也就越正确

你看NMS的代码,mask是根据box的结果来裁剪的。box越正确,mask的结果也就越正确

谢谢,那ciou对ap mask的提升怎么理解呢

CIoU用于bbox regression,可以提升box的质量

CIoU用于bbox regression,可以提升box的质量

非常感谢

还有一个小问题,看了一下代码,还是不太清楚ap mask是如何计算的,是计算每个像素吗

我看到你论文中Balancing precision and recall by different values of β in Cluster-NMS S+D,并且让β等于0.6,但是代码中并没有β的设置

@yishunzhijianlayers/box_utils.py distance函数

cluster_nms 出现同样问题,请问您解决了吗