wuzhihao7788 / yolodet-pytorch Goto Github PK
View Code? Open in Web Editor NEWreproduce the YOLO series of papers in pytorch, including YOLOv4, PP-YOLO, YOLOv5,YOLOv3, etc.
reproduce the YOLO series of papers in pytorch, including YOLOv4, PP-YOLO, YOLOv5,YOLOv3, etc.
您好,非常感谢您能够提供这么好的yolo框架。但是我在使用yolov4_coco_100e的cfg文集训练时,计算map的过程特别慢,计算一次map要花费6分钟的时间。我使用的batch_size=8,subdivisions=4,使用的数据集共2500张,测试集有600张,gpu是1080的。我在u版的yolo上使用yolov4训练我的数据相同的设置计算map只需要30秒的时间,请问这里面是哪里出了问题?
https://github.com/wuzhihao7788/yolodet-pytorch/blob/master/docs/MODEL_ZOO_cn.md
比如
网络 | 预训练数据集 | 输入尺寸 | epoch | 显卡类型 | 推理时间(fps) | cocotools APval | AP50 | 百度网盘 | 谷歌网盘 | 配置文件 | 日志 |
---|---|---|---|---|---|---|---|---|---|---|---|
YOLOv5-l | MSCOCO | 640 | 24 | 2070 | 19ms | 32.5 | 37.5 |
这里的32.5 根据 日志 实际上是mAP50的指标,APval 应该是0.193
感觉好像只有resnet可以加载预训练权值
感谢您这么棒的工作,不过有个疑问,cfg中没看到yolov3的工作目录,故有此一问。
你的代码结构很好,如果有mAP性能分析就更好了
期待您的回复
期待在模型输出后,可进行模型加速,枝剪和部署等内容
请问mixup增广在没加进去,我直接用,精度下降;把mixup的分数加到qfl的weight上好像也没提升
If you have good tricks or advices, you can leave a message in the issue! pelease!
Traceback (most recent call last):
File "tools/train.py", line 144, in <module>
main()
File "tools/train.py", line 140, in main
train_detector(model,datasets,cfg,validate=args.validate,timestamp=timestamp,meta=meta)
File "/home/wenchi/projects/yolodet-pytorch-2/yolodet/apis/train.py", line 161, in train_detector
runner.run(data_loaders, cfg.workflow, cfg.total_epochs)
File "/home/wenchi/projects/yolodet-pytorch-2/yolodet/apis/runner.py", line 331, in run
epoch_runner(data_loaders[i], **kwargs)
File "/home/wenchi/projects/yolodet-pytorch-2/yolodet/apis/runner.py", line 214, in train
for i, data_batch in enumerate(data_loader):
File "/home/wenchi/miniconda3/envs/yolodet-2/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 521, in __next__
data = self._next_data()
File "/home/wenchi/miniconda3/envs/yolodet-2/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1203, in _next_data
return self._process_data(data)
File "/home/wenchi/miniconda3/envs/yolodet-2/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1229, in _process_data
data.reraise()
File "/home/wenchi/miniconda3/envs/yolodet-2/lib/python3.7/site-packages/torch/_utils.py", line 425, in reraise
raise self.exc_type(msg)
TypeError: Caught TypeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/home/wenchi/miniconda3/envs/yolodet-2/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop
data = fetcher.fetch(index)
File "/home/wenchi/miniconda3/envs/yolodet-2/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/wenchi/miniconda3/envs/yolodet-2/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/wenchi/projects/yolodet-pytorch-2/yolodet/dataset/custom.py", line 112, in __getitem__
data = self.prepare_train_img(idx)
File "/home/wenchi/projects/yolodet-pytorch-2/yolodet/dataset/custom.py", line 106, in prepare_train_img
return self.pipeline(results)
File "/home/wenchi/projects/yolodet-pytorch-2/yolodet/dataset/pipelines/compose.py", line 47, in __call__
data = t(data)
File "/home/wenchi/projects/yolodet-pytorch-2/yolodet/dataset/pipelines/transforms.py", line 139, in __call__
hsv[1] *= dsat
TypeError: 'tuple' object does not support item assignment
Hey guys, when I try to run the model on both COCO and my own custom dataset, I ran into the above error. I am sure that the annotation format is correct. Do you have some idea how to fix it?
One more thing that I am not clear is the label.names. Could you show me the format of the label.names? Could the above error caused by the label.names when doing data loading?
Thank you very much!
Wenchi
请问这个字段要怎么生成呢?
感谢开源此项目!
yolov5项目模型结构有问题
没有仔细看你的代码构建,就算最终结果没问题,但是代码可读性变差了
期待您的回复
train words:python tools/train.py --work_dir results cfg/yolov5_coco_100e.py --device 0 --validate
Traceback (most recent call last):
File "tools/train.py", line 144, in
main()
File "tools/train.py", line 140, in main
train_detector(model,datasets,cfg,validate=args.validate,timestamp=timestamp,meta=meta)
File "/home/tongyu/develop-project/yolodet-pytorch-master/yolodet/apis/train.py", line 161, in train_detector
runner.run(data_loaders, cfg.workflow, cfg.total_epochs)
File "/home/tongyu/develop-project/yolodet-pytorch-master/yolodet/apis/runner.py", line 331, in run
epoch_runner(data_loaders[i], **kwargs)
File "/home/tongyu/develop-project/yolodet-pytorch-master/yolodet/apis/runner.py", line 230, in train
self.call_hook('after_train_epoch')
File "/home/tongyu/develop-project/yolodet-pytorch-master/yolodet/apis/runner.py", line 205, in call_hook
getattr(hook, fn_name)(self)
File "/home/tongyu/develop-project/yolodet-pytorch-master/yolodet/models/hooks/eval_hook.py", line 52, in after_train_epoch
results = single_gpu_test(model, self.dataloader)
File "/home/tongyu/develop-project/yolodet-pytorch-master/yolodet/apis/test.py", line 93, in single_gpu_test
output = non_max_suppression(inf_out, conf_thres=conf_thres, iou_thres=iou_thres, merge=merge)
File "/home/tongyu/develop-project/yolodet-pytorch-master/yolodet/models/heads/base.py", line 355, in non_max_suppression
i = torchvision.ops.boxes.nms(boxes, scores, iou_thres)
File "/home/tongyu/.conda/envs/yolodet/lib/python3.6/site-packages/torchvision/ops/boxes.py", line 40, in nms
return torch.ops.torchvision.nms(boxes, scores, iou_threshold)
RuntimeError: Trying to create tensor with negative dimension -1203535890: [-1203535890]
你好,请问后续会考虑添加YOLOv4-tiny模型吗?
感觉这位置应该为True,是我理解错了吗?
还有如果目标类别和预训练模型不一样可以加载预训练模型吗?
首先感谢作者的分享!
使用yolov5的小伙伴注意,里面有一些bug和一些不完善的地方,直接使用即使训练300轮的mAP依然非常底!!!比如config配置,model,loss单分类的计算,数据增强等。建议自己用yolo5源码实现,不然bug都不知道在哪。
Traceback (most recent call last):
File "tools/train.py", line 144, in
main()
File "tools/train.py", line 69, in main
cfg = Config.fromfile(args.config)
File "/home/tongyu/develop-project/yolodet-pytorch-master/yolodet/utils/config.py", line 174, in fromfile
cfg_dict, cfg_text = Config._file2dict(filename)
File "/home/tongyu/develop-project/yolodet-pytorch-master/yolodet/utils/config.py", line 113, in _file2dict
mod = import_module('_tempconfig')
File "/home/tongyu/.conda/envs/yolodet/lib/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 674, in exec_module
File "", line 781, in get_code
File "", line 741, in source_to_code
File "", line 219, in _call_with_frames_removed
File "/tmp/tmpwcunctkd/_tempconfig.py", line 37
bbox_loss=dict(type='IOU_Loss', iou_type='GIOU',loss_weight=0.05),
^
SyntaxError: invalid syntax
是否有onnx转换支持。
错误:show_result(img, result, model.CLASSES)
File "yolodet-pytorch/yolodet/apis/inference.py", line 168, in show_result
label = rslt['label']
IndexError: too many indices for tensor of dimension 3
代码:
from yolodet.apis.inference import inference_detector,init_detector,show_result
import os
config_file ='cfg/yolov4_gpu.py'
checkpoint_file ='work_dirs/yolov4/latest.pth'
model = init_detector(config_file, checkpoint_file, device='cuda:0')
img ='test.jpg' # or img = mmcv.imread(img), which will only load it once
result,t = inference_detector(model, img)
print('%s Done , object num : %s .time:(%.3fs)' % (img,len(result), t))
show_result(img, result, model.CLASSES)
你好,我想问下在ppyolo中添加的iou-aware分支,在inference时,原论文中的iou confidence是通过α=0.4次方的形式与class的confidence的0.6次方相乘,得到inference时的confidence。
但是在代码中,yolodet/models/heads/ppyolo.py中的get_eval_bboxes函数:
new_obj = torch.pow(obj, (1 - self.iou_aware_factor)) * torch.pow(ioua, self.iou_aware_factor)
实现论文的new_obj以后还进行了-log(1/new_obj-1)的操作。
我这边实现了iou-aware后假设原new_obj为0.9,但是经过-log(1/new_obj-1)后续操作得到的confidence数值是2.19,造成了识别的confidence的范围不在0到1以内。
想请教下为什么代码中这样实现,还是说在其他地方有将其重新约束到(0,1)的操作?
希望导出模型能在onnxruntime进行部署推断。
Any experiments?
我在mac上训练报错,
Traceback (most recent call last):
File "tools/train.py", line 144, in
main()
File "tools/train.py", line 69, in main
cfg = Config.fromfile(args.config)
File "/Users/youyin/Documents/人工智能研究项目/keypoint/yolodet-pytorch/yolodet/utils/config.py", line 173, in fromfile
cfg_dict, cfg_text = Config._file2dict(filename)
File "/Users/youyin/Documents/人工智能研究项目/keypoint/yolodet-pytorch/yolodet/utils/config.py", line 113, in _file2dict
mod = import_module('_tempconfig')
File "/Users/youyin/anaconda3/envs/yolodet/lib/python3.7/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "", line 724, in exec_module
File "", line 860, in get_code
File "", line 791, in source_to_code
File "", line 219, in _call_with_frames_removed
File "/var/folders/l8/b9v1kgkd6nz9hl__21wh79hm0000gn/T/tmp0dmyw5s2/_tempconfig.py", line 37
bbox_loss=dict(type='IOU_Loss', iou_type='GIOU',loss_weight=0.05),
^
SyntaxError: invalid syntax
请问您有没有用yolov4训练过voc数据集,我训了100轮之后mAP只有60%是正常的吗?
Traceback (most recent call last):
File "tools/train.py", line 144, in
main()
File "tools/train.py", line 140, in main
train_detector(model,datasets,cfg,validate=args.validate,timestamp=timestamp,meta=meta)
File "/data1/xieyangyang/yolodet-pytorch/yolodet/apis/train.py", line 161, in train_detector
runner.run(data_loaders, cfg.workflow, cfg.total_epochs)
File "/data1/xieyangyang/yolodet-pytorch/yolodet/apis/runner.py", line 331, in run
epoch_runner(data_loaders[i], **kwargs)
File "/data1/xieyangyang/yolodet-pytorch/yolodet/apis/runner.py", line 220, in train
self.model, data_batch, train_mode=True, **kwargs)
File "/data1/xieyangyang/yolodet-pytorch/yolodet/apis/train.py", line 116, in batch_processor
losses = model(**data)
File "/data4/xieyangyang/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in call
result = self.forward(*input, **kwargs)
File "/data4/xieyangyang/anaconda3/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py", line 155, in forward
outputs = self.parallel_apply(replicas, inputs, kwargs)
File "/data4/xieyangyang/anaconda3/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py", line 165, in parallel_apply
return parallel_apply(replicas, inputs, kwargs, self.device_ids[:len(replicas)])
File "/data4/xieyangyang/anaconda3/lib/python3.7/site-packages/torch/nn/parallel/parallel_apply.py", line 85, in parallel_apply
output.reraise()
File "/data4/xieyangyang/anaconda3/lib/python3.7/site-packages/torch/_utils.py", line 395, in reraise
raise self.exc_type(msg)
RuntimeError: Caught RuntimeError in replica 0 on device 0.
Original Traceback (most recent call last):
File "/data4/xieyangyang/anaconda3/lib/python3.7/site-packages/torch/nn/parallel/parallel_apply.py", line 60, in _worker
output = module(*input, **kwargs)
File "/data4/xieyangyang/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in call
result = self.forward(*input, **kwargs)
File "/data1/xieyangyang/yolodet-pytorch/yolodet/models/detectors/base.py", line 55, in forward
return self.forward_train(img, img_metas, **kwargs)
File "/data1/xieyangyang/yolodet-pytorch/yolodet/models/detectors/YOLOv5Detector.py", line 100, in forward_train
head_loss = self.head.loss(*head_loss_inputs)
File "/data1/xieyangyang/yolodet-pytorch/yolodet/models/heads/yolo.py", line 99, in loss
bbox_loss, confidence_loss, class_loss = multi_apply(self.loss_single, pred, indices,tbox,tcls,ancher,self.conf_balances,ignore_mask)
File "/data1/xieyangyang/yolodet-pytorch/yolodet/utils/util.py", line 32, in multi_apply
return tuple(map(list, zip(*map_results)))
File "/data1/xieyangyang/yolodet-pytorch/yolodet/models/heads/yolo.py", line 91, in loss_single
return self.yolov5_loss_single(pred, indices,tbox,tcls,anchors, conf_balances,ignore_mask)
File "/data1/xieyangyang/yolodet-pytorch/yolodet/models/heads/yolo.py", line 210, in yolov5_loss_single
pwh = (ps[:, 2:4].sigmoid() * 2) ** 2 * torch.from_numpy(anchors).to(device) # 0-4倍缩放 model.hyp['anchor_t']=4
RuntimeError: CUDA error: device-side assert triggered
RuntimeError: Caught RuntimeError in DataLoader worker process 3.
Original Traceback (most recent call last):
File "/root/.local/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 198, in _worker_loop
data = fetcher.fetch(index)
File "/root/.local/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 47, in fetch
return self.collate_fn(data)
File "/root/liyang/yolodet-pytorch/yolodet/dataset/loader/build_dataloader.py", line 92, in collate
clt[k] = torch.stack(v, 0)
RuntimeError: stack expects each tensor to be equal size, but got [3, 640, 640] at entry 0 and [3, 1280, 1280] at entry 6
是loader/build_dataloader.py 里面collate的问题?
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.