Code Monkey home page Code Monkey logo

yolov4-pytorch's Issues

训练问题请教

您好,使用您的代码,全部默认的参数配置,在VOC2007数据集上,训练到40+轮后,训练集的损失从20-30降至3附近,但是验证集的损失几乎没有变化,一直在8、9、10左右震荡,这似乎是过拟合的迹象,不知道大佬怎么看 ?
另外,您下图的仓库,到底实现的yolov4还是v3 ?
image

TypeError: cat() got an unexpected keyword argument 'axis'

遇到的一个bug
完整错误提示
Traceback (most recent call last):
File "C:/Users/zhq/Desktop/maskdect/yolov4-pytorch-master/train.py", line 178, in
fit_ont_epoch(net,yolo_losses,epoch,epoch_size,epoch_size_val,gen,gen_val,Freeze_Epoch,Cuda)
File "C:/Users/zhq/Desktop/maskdect/yolov4-pytorch-master/train.py", line 49, in fit_ont_epoch
outputs = net(images)
File "D:\Program_Files\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "D:\Program_Files\Anaconda3\lib\site-packages\torch\nn\parallel\data_parallel.py", line 150, in forward
return self.module(*inputs[0], **kwargs[0])
File "D:\Program_Files\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "C:\Users\zhq\Desktop\maskdect\yolov4-pytorch-master\nets\yolo4.py", line 129, in forward
P4 = torch.cat([P4,P5_upsample],axis=1)
TypeError: cat() got an unexpected keyword argument 'axis'

我查了一下,发现相关给出的建议都是针对tf的,还没有好的解决办法

在docker下报了一个错 求帮助

root@42f6601705a0:/workspace/yolov4-pytorch-master# python3 train.py
Loading weights into state dict...
Finished!
/workspace/yolov4-pytorch-master/utils/dataloader.py:251: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
bboxes = np.array(bboxes)

train时,遇到invalid load key, '\x00',怎么解决?谢谢大佬们

Loading weights into state dict...
Traceback (most recent call last):
File "train.py", line 141, in
pretrained_dict = torch.load(model_path, map_location=device)
File "/home/liupenglei/anaconda3/envs/pythorch/lib/python3.6/site-packages/torch/serialization.py", line 387, in load
return _load(f, map_location, pickle_module, **pickle_load_args)
File "/home/liupenglei/anaconda3/envs/pythorch/lib/python3.6/site-packages/torch/serialization.py", line 564, in _load
magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, '\x00'.

所需环境配置?

所需环境
tensorflow-gpu==1.13.1
keras==2.1.5?
这是一个pytorch的版本吗 :)

请问mask的loss影响模型的识别结果吗?

你好,我看训练过程的loss中有mask的参与,那么在最后进行目标识别时,会对结果造成影响吗?因为我理解的最后只进行识别,应该不会有mask的遮罩处理?

cuda问题请教

请问大佬,您使用的GPU驱动是什么版本,我的是NVIDIA 10.1,在使用您的代码时报错,驱动太老,请问这个问题怎么解决,必须要升级驱动吗

如何得到mAP

不好意思打扰了,如果想得到mAP,该怎么加一些代码呢?

预测类别错误

楼主好,我用这个模型正常训练完,收敛到20左右,进行预测时发现类别不对,而且最后显示的置信度值很低,0.03左右,但是框出来的确实是缺陷,估计是啥原因?

utils/utils.py中的yolo_correct_boxes函数的疑问

大佬代码非常优雅,值得我深入学习
在拜读您代码的时候,关于utils.py中的yolo_correct_boxes函数,感觉您实现的好像有问题吧?
scale是一个二元tuple,其中一个是1,另一个大于1,之前图片输入网络的时候,是将图片缩放到恰好可以粘贴到416*416的灰色背景上,而原图片的高宽比没有变化啊,为什么这里要对y,x坐标进行不同scale的放缩呢??

是我理解错了吗? 可以劳烦您检查一下吗,如果确认无误,我再慢慢琢磨,谢谢

偶尔会出现一些莫名其妙的大框

大佬,我用你的代码训练,效果确实不错,但是偶尔会在没有目标的帧中出现一些大框,我觉得原因就是昨天我说的没有加入不包括目标的训练样本导致的。我现在想加入不包括目标的训练样本,但是需要参考我之前的yolov3来魔改,我python能力不够,大佬,你能改改吗?

训练报错

你好博主,非常感谢分享。
我在按照提示的步骤进行训练时出现了如下的错误:
1 . Traceback (most recent call last):
File "yolov4-pytorch-master\nets\yolo4.py", line 129, in forward
P4 = torch.cat([P4,P5_upsample],axis=1)
TypeError: cat() got an unexpected keyword argument 'axis' (已将axis改成dim,请问这个是版本原因还是?)

2. Traceback (most recent call last):
File "yolov4-pytorch-master\nets\yolo_training.py", line 167, in forward
ciou = (1 - box_ciou( pred_boxes_for_ciou[mask.bool()], t_box[mask.bool()]))* box_loss_scale[mask.bool()]
AttributeError: 'Tensor' object has no attribute 'bool'(请问这个问题怎么进行修改呢?)

请问yolov4原论文提到的方法都在这里实现了吗?

下面是yolov4原论文中给出的方法,请问您的代码全部实现了这些功能吗?如果没有的话具体哪些还没有实现呢?谢谢!

YOLO v4 uses:
• Bag of Freebies (BoF) for backbone: CutMix and Mosaic data augmentation, DropBlock regularization,Class label smoothing
• Bag of Specials (BoS) for backbone: Mish activation, Cross-stage partial connections (CSP), Multi input weighted residual
connections (MiWRC)
• Bag of Freebies (BoF) for detector: CIoU-loss,CmBN, DropBlock regularization, Mosaic data augmentation, Self-Adversarial
Training, Eliminate grid sensitivity, Using multiple anchors for a single ground truth, Cosine annealing scheduler [52], Optimal
hyperparameters, Random training shapes
• Bag of Specials (BoS) for detector: Mish activation,SPP-block, SAM-block, PAN path-aggregation block,DIoU-NMS

VOC数据集,从零开始训练

没试过加载预训练权重,BD网盘太慢不想下。
VOC数据集,从零开始训练没有效果。
Cosine_lr = False
mosaic = False
尺寸为608x608
其它都是默认参数,训练20epoch后loss大约在25左右,然后手动测试图片发现没有框。请问从零开始训练参数大概如何调整呢?

c++环境下编译模型

你好,我想问下用该项目训练好的模型能用于C++环境下进行编译、预测吗?例如darknet编译

小改进,cpu与gpu加载模型

train.py与yolo.py中有使用torch.load()方法的建议加上map_location=xxx,防止gpu训练cpu预测或其它混用情况下报错。
比如可以改成这样:
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
pretrained_dict = torch.load(model_path, map_location=device)

数据集方面的问题

通过打印框的位置感觉有问题,请问大佬是不是验证过图像增强的过程?
image
image

训练问题

我用yolov4训练猫狗的模型时,效果非常好。但是我用yolov4训练人猫狗的模型时,训练了一个星期了,在验证集和训练集上的loss一直保持在一个较高的值,降不下去了。拿训练好的模型去做测试,效果很差,应该是还没训练好,但是loss一直降不下去了,不知道楼主与没遇见过这个情况。

注:猫狗的数据集有4万张,人猫狗的数据集有12万张。

一些疑问

感谢大佬的代码!
在自己改造数据集加载为pytorch的Dataset类时,用plt显示__getitem__()方法获取的图片时,发现mosaic为true获取的图片显示为黑色,经过调试发现:
get_random_data()方法的图片会经过>>除255再乘255
get_random_data_with_Mosaic()方法会经过>>除255再乘255又除255
最终mosaic显示为黑色,只要去掉mosaic方法内的最后一个除255就可以了。
请问这个是预期的嘛?

关于train.py冻结与解冻的问题

你好,我想请问如果在训练的过程中,首先进行冻结一定部分训练,也就是你咋注释中所说防止权值破坏;然后训练到一定的epoch后再进行解冻训练,但是这时候出现预测的准确率大幅下降,是什么原因呢?
那么请问可能是在冻结训练的时候出现已经过拟合现象,然后在基于已经过拟合的模型进行解冻后训练导致的?

Have you ever been in this situation?

Hello, big guy, may I ask, I use your training garbage classification, the label also changed to garbage, why the end of the training tag inside suddenly more people, cars, bicycles, etc., and the identification is quite accurate, but my training set does not have these pictures, what is this??

test.py

请问会更新test.py 吗 然后生成计算map所需的txt

数据集的处理能不能使用k折交叉验证的方法

楼主,我看你数据集按9:1分为训练集和验证集来训练,但是每个epoch都是一样的。能不能在每个epoch里把数据按9:1分为训练集和验证集来训练,这就是说每个epoch的训练集和验证集在变化。也就是说数据集的处理能不能使用k折交叉验证的方法。

数据集中为啥没负样本

voc_annotation.py这个脚本把没有目标的负样本全部过滤掉了。请问你这个训练代码能不能加负样本进行训练

检测速度问题

您好,我把yolov4-tiny的特征融合FPN网络改成了yolov4的PANet网络,检测精度有提高,但是速度降低了很多,FPS只有8~10,和yolov4差不多了,yolov4是8左右,明明我的模型都比yolov4少了一大半,请问下这是怎么回事啊?

将train.py训练得到的权重带入到yolo.py中,出现如下的问题,存在权重与架构不匹配的问题,您能帮忙看看怎么解决吗?谢谢!

RuntimeError: Error(s) in loading state_dict for YoloBody:
size mismatch for yolo_head3.1.weight: copying a param with shape torch.Size([18, 256, 1, 1]) from checkpoint, the shape in current model is torch.Size([255, 256, 1, 1]).
size mismatch for yolo_head3.1.bias: copying a param with shape torch.Size([18]) from checkpoint, the shape in current model is torch.Size([255]).
size mismatch for yolo_head2.1.weight: copying a param with shape torch.Size([18, 512, 1, 1]) from checkpoint, the shape in current model is torch.Size([255, 512, 1, 1]).
size mismatch for yolo_head2.1.bias: copying a param with shape torch.Size([18]) from checkpoint, the shape in current model is torch.Size([255]).
size mismatch for yolo_head1.1.weight: copying a param with shape torch.Size([18, 1024, 1, 1]) from checkpoint, the shape in current model is torch.Size([255, 1024, 1, 1]).
size mismatch for yolo_head1.1.bias: copying a param with shape torch.Size([18]) from checkpoint, the shape in current model is torch.Size([255]).

关于训练的疑问

您好,首先感谢您的分享。 我有几个疑问之处:

  1. 为什么先冻结25个epoch 的训练再解冻 再训练?
  2. 为什么我训练前 25个epoch时, 大概 显存 9个g左右, 第26个epoch就直接显存炸了? 我改小了 batchsize 也是不行。

anno的格式问题

yolov4-pytorch/train.py

Lines 73 to 76 in 8a0fd2f

targets_val = [Variable(torch.from_numpy(ann).type(torch.FloatTensor)) for ann in targets_val]
else:
images_val = Variable(torch.from_numpy(images_val).type(torch.FloatTensor))
targets_val = [Variable(torch.from_numpy(ann).type(torch.FloatTensor)) for ann in targets_val]

运行代码时,有时候会报错说输入应该是numpy格式而不是list格式。
建议将torch.from_numpy(ann)改为torch.from_numpy(np.array(ann))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.