bubbliiiing / yolov4-pytorch Goto Github PK
View Code? Open in Web Editor NEW这是一个YoloV4-pytorch的源码,可以用于训练自己的模型。
License: MIT License
这是一个YoloV4-pytorch的源码,可以用于训练自己的模型。
License: MIT License
遇到的一个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的,还没有好的解决办法
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)
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的版本吗 :)
你好,我看训练过程的loss中有mask的参与,那么在最后进行目标识别时,会对结果造成影响吗?因为我理解的最后只进行识别,应该不会有mask的遮罩处理?
请问大佬,您使用的GPU驱动是什么版本,我的是NVIDIA 10.1,在使用您的代码时报错,驱动太老,请问这个问题怎么解决,必须要升级驱动吗
不好意思打扰了,如果想得到mAP,该怎么加一些代码呢?
楼主好,我用这个模型正常训练完,收敛到20左右,进行预测时发现类别不对,而且最后显示的置信度值很低,0.03左右,但是框出来的确实是缺陷,估计是啥原因?
是拿的voc的预练模型
大佬代码非常优雅,值得我深入学习
在拜读您代码的时候,关于utils.py中的yolo_correct_boxes函数,感觉您实现的好像有问题吧?
scale是一个二元tuple,其中一个是1,另一个大于1,之前图片输入网络的时候,是将图片缩放到恰好可以粘贴到416*416的灰色背景上,而原图片的高宽比没有变化啊,为什么这里要对y,x坐标进行不同scale的放缩呢??
是我理解错了吗? 可以劳烦您检查一下吗,如果确认无误,我再慢慢琢磨,谢谢
大佬,我用你的代码训练,效果确实不错,但是偶尔会在没有目标的帧中出现一些大框,我觉得原因就是昨天我说的没有加入不包括目标的训练样本导致的。我现在想加入不包括目标的训练样本,但是需要参考我之前的yolov3来魔改,我python能力不够,大佬,你能改改吗?
大佬好,不懂有没有精力整个一个主流的目标检测的集合项目,简洁易懂又不像detectron2这种太庞大了,比如下面这个地址这种集合了主流的语义分割的项目就很好。
https://github.com/LikeLy-Journey/SegmenTron
你好,在改进的train中我看到了dataloader的使用,请问其目的是什么呢?
voc下训练,在测试模型的时候,发现在一些生成的检测结果文件中有负值存在
cow 0.2594 -21 6 358 431
person 0.8388 -2 19 335 478
你好博主,非常感谢分享。
我在按照提示的步骤进行训练时出现了如下的错误:
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'(请问这个问题怎么进行修改呢?)
def init(self, **kwargs):
self.dict.update(self._defaults)
self.dict.update(**kwargs) #感觉要加上这句,不然初始化参数就没意义了
yolo = YOLO(model_path='model_data/best.pth',cuda=False)
下面是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
没试过加载预训练权重,BD网盘太慢不想下。
VOC数据集,从零开始训练没有效果。
Cosine_lr = False
mosaic = False
尺寸为608x608
其它都是默认参数,训练20epoch后loss大约在25左右,然后手动测试图片发现没有框。请问从零开始训练参数大概如何调整呢?
loss降到20左右就降不下去了
你好,我想问下用该项目训练好的模型能用于C++环境下进行编译、预测吗?例如darknet编译
如果用户输入数据格式不是来源于xml,则用户还得自己去实现这个过程,代码复用性就降低了。
第一个epoch就出现这种问题,手动中断训练,再次运行train.py,还是相同的情况,不过每次停止的iter都不一样。
感谢UP的分享!
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)
请问文章中的Self-Adversarial Training这套代码有用到吗?
还有想请问一下有测过在coco上的mAP吗
楼主,你好,我用你的代码训练出来的模型调用video.py来做测试,会出现很多莫名其妙的大框,不知道你有没有遇见过
训练出的模型转为onnx时需要用到cfg文件,可这里没有对应的cfg文件,我使用官网的cfg修改了classes和batch等参数后,任然会报错:TypeError: buffer is too small for requested array ,我查询资料说是cfg文件不对应,请问如何获取到对应的cfg文件呢??
我用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就可以了。
请问这个是预期的嘛?
你好,我想请问如果在训练的过程中,首先进行冻结一定部分训练,也就是你咋注释中所说防止权值破坏;然后训练到一定的epoch后再进行解冻训练,但是这时候出现预测的准确率大幅下降,是什么原因呢?
那么请问可能是在冻结训练的时候出现已经过拟合现象,然后在基于已经过拟合的模型进行解冻后训练导致的?
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 吗 然后生成计算map所需的txt
楼主,我看你数据集按9:1分为训练集和验证集来训练,但是每个epoch都是一样的。能不能在每个epoch里把数据按9:1分为训练集和验证集来训练,这就是说每个epoch的训练集和验证集在变化。也就是说数据集的处理能不能使用k折交叉验证的方法。
voc_annotation.py这个脚本把没有目标的负样本全部过滤掉了。请问你这个训练代码能不能加负样本进行训练
您好,我把yolov4-tiny的特征融合FPN网络改成了yolov4的PANet网络,检测精度有提高,但是速度降低了很多,FPS只有8~10,和yolov4差不多了,yolov4是8左右,明明我的模型都比yolov4少了一大半,请问下这是怎么回事啊?
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]).
广告虽可耻,大家可以看看我复现的这版yolov4,精心设计了损失函数,训练了70000步就没出现过nan,mAP至少可达36%,欢迎点star:
Unable to download from baidu
您好,首先感谢您的分享。 我有几个疑问之处:
torchvision.ops.boxes.nms可有效加速nms处理速度
Lines 73 to 76 in 8a0fd2f
增加通用性
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.