Coder Social home page Coder Social logo

wongkinyiu / scaledyolov4 Goto Github PK

View Code? Open in Web Editor NEW
2.0K 2.0K 569.0 492 KB

Scaled-YOLOv4: Scaling Cross Stage Partial Network

License: GNU General Public License v3.0

Python 100.00%
deep-learning machine-learning ml object-detection pytorch scaled-yolov4 yolo yolov3 yolov4 yolov4-csp yolov4-large yolov4-tiny

scaledyolov4's People

Contributors

wongkinyiu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scaledyolov4's Issues

Window10 wsl2 nvidia-docker get error when running " python setup.py build install"

/usr/local/cuda/bin/nvcc -Iexternal -I/opt/conda/lib/python3.6/site-packages/torch/include -I/opt/conda/lib/python3.6/site-packages/torch/include/torch/csrc/api/include -I/opt/conda/lib/python3.6/site-packages/torch/include/TH -I/opt/conda/lib/python3.6/site-packages/torch/include/THC -I/usr/local/cuda/include -I/opt/conda/include/python3.6m -c -c /mish-cuda/csrc/mish_kernel.cu -o /mish-cuda/build/temp.linux-x86_64-3.6/csrc/mish_kernel.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options '-fPIC' --expt-extended-lambda -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=1 -gencode=arch=compute_61,code=sm_61 -gencode=arch=compute_75,code=sm_75 -gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_80,code=sm_80 -gencode=arch=compute_70,code=sm_70 -gencode=arch=compute_80,code=compute_80 -gencode=arch=compute_52,code=sm_52 -std=c++14
/mish-cuda/csrc/mish_kernel.cu:3:10: fatal error: CUDAApplyUtils.cuh: No such file or directory
#include "CUDAApplyUtils.cuh"

^~~~~~~~~~~~~~~~~~~~
compilation terminated.
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
File "/opt/conda/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 1471, in _run_ninja_build
check=True)
File "/opt/conda/lib/python3.6/subprocess.py", line 438, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "setup.py", line 30, in
'build_ext': BuildExtension
File "/opt/conda/lib/python3.6/site-packages/setuptools/init.py", line 161, in setup
return distutils.core.setup(**attrs)
File "/opt/conda/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/opt/conda/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/opt/conda/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/opt/conda/lib/python3.6/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/opt/conda/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/opt/conda/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/opt/conda/lib/python3.6/site-packages/setuptools/command/build_ext.py", line 87, in run
_build_ext.run(self)
File "/opt/conda/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
_build_ext.build_ext.run(self)
File "/opt/conda/lib/python3.6/distutils/command/build_ext.py", line 339, in run
self.build_extensions()
File "/opt/conda/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 633, in build_extensions
build_ext.build_extensions(self)
File "/opt/conda/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 194, in build_extensions
self.build_extension(ext)
File "/opt/conda/lib/python3.6/site-packages/setuptools/command/build_ext.py", line 208, in build_extension
_build_ext.build_extension(self, ext)
File "/opt/conda/lib/python3.6/distutils/command/build_ext.py", line 533, in build_extension
depends=ext.depends)
File "/opt/conda/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 462, in unix_wrap_ninja_compile
with_cuda=with_cuda)
File "/opt/conda/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 1211, in _write_ninja_file_and_compile_objects
error_prefix='Error compiling objects for extension')
File "/opt/conda/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 1484, in _run_ninja_build
raise RuntimeError(message)
RuntimeError: Error compiling objects for extension
root@006c33c494ce:/mish-cuda#

Unable to find image 'nvcr.io/nvidia/pytorch:20.06-py3' locally

20.06-py3: Pulling from nvidia/pytorch
23884877105a: Pulling fs layer
bc38caa0f5b9: Pulling fs layer
2910811b6c42: Pulling fs layer
36505266dcc6: Waiting
b3160bd02226: Waiting
1854e99b6b01: Pulling fs layer
1854e99b6b01: Waiting
946388849428: Waiting
37b7becebba3: Waiting
c375d2e174ca: Waiting
4978443c000b: Waiting
181b0b110ed9: Waiting
fb0dd2917726: Waiting
43891d45480f: Waiting
d5a7b1f52fad: Pulling fs layer
68cdd679c06e: Waiting
d09af3b6a30d: Waiting
427aa2219a5c: Waiting
23edf8f627eb: Pulling fs layer
23edf8f627eb: Waiting
f9a261ee19e5: Pulling fs layer
0c2852bbc5e6: Pulling fs layer
02e1eb53084b: Waiting
a2acdcfe588b: Pulling fs layer
f9a261ee19e5: Waiting
0c2852bbc5e6: Waiting
cf5c4e384a9c: Pulling fs layer
055616a53b8d: Waiting
c44d52d21edf: Waiting
c3e2faefbf6c: Waiting
c4979e3f6ef6: Waiting
e90bbad973ce: Pull complete
a1f688bf81ad: Pull complete
19e00825f910: Pull complete
4e5257186489: Pull complete
28e29532f45b: Pull complete
bdd086d90934: Pull complete
992d5e510ca4: Pull complete
e79cd3cbe2d6: Pull complete
761468de75c4: Pull complete
2b17d69a8948: Pull complete
c819bad9fe4c: Pull complete
a89c91edcb2e: Pull complete
d190303a2ae1: Pull complete
58152c74466a: Pull complete
6bfe1ef731fb: Pull complete
0ca4f1c7264c: Pull complete
22b1c121e58c: Pull complete
481770fa1227: Pull complete
3c652ebd4e52: Pull complete
39cfad382034: Pull complete
29882039c1b5: Pull complete
9ecab4cec575: Pull complete
56b05df2798a: Pull complete
0a50c25972aa: Pull complete
284967003afa: Pull complete
9272a680c908: Pull complete
1f7957821bba: Pull complete
4f29d4fc8251: Pull complete
9b441e1a8fca: Pull complete
Digest: sha256:c7cf8b9a93c092e3ec5fa027730a517e132bf742e0bfd034a3d44561a92cd508
Status: Downloaded newer image for nvcr.io/nvidia/pytorch:20.06-py3

小白问题 code在什么地方下载呢?

nvidia-docker run --name yolov4_csp -it -v your_coco_path/:/coco/ -v your_code_path/:/yolo --shm-size=64g nvcr.io/nvidia/pytorch:20.02-py3
中 your_code_path 这个code需要在什么地方下载呢?

tiny里的 因为我看步骤里有个make

Batch mode Cluster-NMS when turning on TTA

Hi, what an excellent work. It is indeed amazing to get such AP and FPS.

I notice that you incorporate batch mode Weighted Cluster-NMS from https://github.com/Zzh-tju/yolov5

And I see there is an improvement when turning on TTA.

I wanna know is it helpful to switch NMS function to batch mode Weighted Cluster-NMS? Can it keep high efficiency when using TTA?

我的环境下,读取模型文件时发生了错误

感谢大佬工作! 我好像读不出来你的模型
python3命令行下,使用torch 1.6版本

输入:
import torch
model = torch.load('yolov4-p5.pt')

返回如下错误:
File "/home/popzq/.conda/envs/zpy/lib/python3.7/site-packages/torch/serialization.py", line 765, in _legacy_load
result = unpickler.load()
ModuleNotFoundError: No module named 'mc'

yolov4-csp.weights load error

Namespace(agnostic_nms=False, augment=False, cfg='models/yolov4-csp.cfg', classes=None, conf_thres=0.4, device='0', img_size=640, iou_thres=0.5, names='data/coco.names', output='inference/output', save_txt=False, source='inference/images', update=False, view_img=False, weights='weights/yolov4-csp.weights')
Using CUDA device0 _CudaDeviceProperties(name='GeForce GTX 1080 Ti', total_memory=11175MB)

Model Summary: 342 layers, 5.29214e+07 parameters, 5.29214e+07 gradients
Traceback (most recent call last):
File "/media/data1/project/project2020/Detection/yolov4/ScaledYOLOv4/yolov4-csp/detect.py", line 187, in
detect()
File "/media/data1/project/project2020/Detection/yolov4/ScaledYOLOv4/yolov4-csp/detect.py", line 44, in detect
model.load_state_dict(torch.load(weights[0], map_location=device)['model'])
File "/media/data1/3rdtool/anaconda3/envs/yolov4last/lib/python3.8/site-packages/torch/serialization.py", line 581, in load
with _open_file_like(f, 'rb') as opened_file:
File "/media/data1/3rdtool/anaconda3/envs/yolov4last/lib/python3.8/site-packages/torch/serialization.py", line 230, in _open_file_like
return _open_file(name_or_buffer, mode)
File "/media/data1/3rdtool/anaconda3/envs/yolov4last/lib/python3.8/site-packages/torch/serialization.py", line 211, in init
super(_open_file, self).init(open(name, mode))
FileNotFoundError: [Errno 2] No such file or directory: 'w'

Process finished with exit code 1

Mish-cuda的安装

ubuntu16.04, V100 GPU. Python3.7, 在cuda9.0, Pytorch1.3.0的情况下 Mish-cuda是可正常编译安装的,但是此时无法使用amp;
CUDA9.2和CUDA10.0,CUDA10.2下均尝试显示安装Mish-cuda报错,大佬们有遇到过这种情况吗?

what is OSAnet ?

Hi,

Thanks for your sharing. When reading the paper, I am puzzled about about what is OSAnet is. I can not find the full name of OSAnet.
Would you please kindly tell me the full name of OSAnet?

Thank you and best regards!

How does FPS be computed?

Hi, I'd like to know how FPS is computed? How does the time consumption per detection be considered? Include data input, network forward and NMS or just network forward and NMS or any other way?

train all nan?

I use :python train.py --batch-size 16 --img 512 512 --data person.yaml --cfg yolov4-p5.yaml --weights yolov4-p5.pt --sync-bn --device 1 --name yolov4-p5-tune --hyp 'data/hyp.finetune.yaml' --epochs 450 --resume

result:
image

About AlexeyAB darknet with coco dataset

ALexeyAB的darknet好像对coco的支持有点问题,class会越界。
做了一个表,反映射90 class 到80class
int coco_ids2[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 0, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 0, 25, 26,0,0,
27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40, 0, 41, 42, 43, 44, 45,
46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 58, 59, 60, 0, 61,0,0, 62,
0, 63, 64, 65, 66, 67, 68, 69, 70, 71,
72, 73,0, 74, 75, 76, 77, 78, 79, 80};
有个问题是,如果我用coco 2017 dataset,从头开始训练,不加载任何预训练集,能否复现您的yolov4-csp结果?

yolov4 csp running on darknet , get lower AP.

同样的yolov4 csp放在darknet下跑,发现ap低了许多,如下
./darknet detector valid cfg/coco.data cfg/yolov4-csp.cfg ../weights/yolov4-csp.weights -out yolov4-csp -gpus 0
python valcoco.py ./results/yolov4-csp.json
yolov4-csp 1850秒
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.17229
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.32294
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.16451
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.15231
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.26031
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.21131
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.21734
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.41937
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.51365
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.33643
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.54722
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.67830

下面是您的结果
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.47827
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.66448
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.51928
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.30647
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.53106
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.61056
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.36823
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.60434
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.65795
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.48486
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.70892
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.79914

Training yolov4-csp in darknet, loss curve oscillation at 6.

你好,yolov4-csp在darknet上训练一类时,3000次之后loss曲线下降到3左右,突然上升,后面一直在6左右震荡,是为什么呢?该数据集已经在yolov4成功训练且收敛到0.5以内,且需要修改的cfg参数已经修改。

Out of memery when doing NMS

File "/opt/conda/lib/python3.6/site-packages/torchvision/ops/boxes.py", line 41, in nms
by NMS, sorted in decreasing order of scores
"""
return torch.ops.torchvision.nms(boxes, scores, iou_threshold)
~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
RuntimeError: CUDA out of memory. Tried to allocate 2.98 GiB (GPU 0; 10.76 GiB total capacity; 1.19 GiB already allocated; 2.35 GiB free; 7.46 GiB reserved in total by PyTorch)

How to do nms in cpu?

Class outof range error!

Running cmd like this:
python test.py --img 640 --conf 0.001 --batch 8 --device 0 --data coco.yaml --cfg models/yolov4-csp.cfg --weights weights/yolov4-csp.weights

Then get error:
File "test.py", line 204, in test
plot_images(img, targets, paths, str(f), names) # ground truth
File "/yolo/ScaledYOLOv4/utils/general.py", line 1040, in plot_images
cls = names[cls] if names else cls
IndexError: list index out of range

cls is 81, bigger than 80.....

I dumped the vraiable "targets" content:
array([[ 0, 24, 0.17775, 0.63109, 0.096399, 0.1668],
[ 0, 24, 0.83072, 0.67971, 0.060551, 0.15465],
[ 0, 24, 0.87575, 0.51178, 0.035997, 0.15762],
[ 0, 24, 0.42382, 0.43125, 0.033051, 0.13742],
[ 0, 24, 0.68085, 0.64953, 0.076607, 0.067734],
[ 0, 24, 0.44217, 0.48498, 0.043795, 0.045352],
[ 0, 24, 0.31235, 0.5276, 0.02994, 0.051523],
[ 0, 24, 0.60032, 0.52289, 0.025461, 0.11711],
[ 0, 24, 0.78515, 0.56635, 0.026607, 0.11785],
[ 1, 1, 0.24626, 0.61436, 0.032039, 0.22887],
[ 1, 1, 0.14895, 0.64904, 0.017545, 0.11941],
[ 1, 35, 0.24478, 0.7382, 0.087738, 0.023672],
[ 2, 1, 0.63058, 0.59766, 0.1183, 0.35156],
[ 2, 81, 0.24046, 0.53158, 0.070327, 0.072227],
[ 2, 65, 0.58796, 0.65, 0.27506, 0.35984],
[ 2, 65, 0.93365, 0.65893, 0.085074, 0.3423],
[ 2, 72, 0.12993, 0.46594, 0.070744, 0.13977],
[ 2, 62, 0.47219, 0.64619, 0.10659, 0.3673],
[ 3, 5, 0.62987, 0.4707, 0.64786, 0.45648],
[ 3, 5, 0.27145, 0.41068, 0.47272, 0.37238],
[ 3, 3, 0.054658, 0.74605, 0.060952, 0.071719],
[ 3, 8, 0.745, 0.74648, 0.063095, 0.060781],
[ 3, 8, 0.58124, 0.74785, 0.073646, 0.064453],
[ 3, 8, 0.25408, 0.7474, 0.081756, 0.066914],
[ 3, 3, 0.21022, 0.74863, 0.060521, 0.059766],
[ 3, 8, 0.7686, 0.56697, 0.022649, 0.06168],
[ 4, 1, 0.53983, 0.56291, 0.097158, 0.25504],
[ 4, 1, 0.41235, 0.58021, 0.12065, 0.38387],
[ 4, 42, 0.53795, 0.73945, 0.3244, 0.12695],
[ 4, 42, 0.58822, 0.66465, 0.14936, 0.068984],
[ 5, 19, 0.53641, 0.69809, 0.17263, 0.22766],
[ 6, 19, 0.84571, 0.59525, 0.10897, 0.40504],
[ 6, 19, 0.15413, 0.57355, 0.080313, 0.3918],
[ 6, 19, 0.40476, 0.54951, 0.11509, 0.48785],
[ 6, 19, 0.24983, 0.55186, 0.10772, 0.4598],
[ 6, 19, 0.55379, 0.59623, 0.066131, 0.36262],
[ 6, 19, 0.48101, 0.56086, 0.10286, 0.43875],
[ 6, 1, 0.74391, 0.42926, 0.032381, 0.10375],
[ 6, 1, 0.7894, 0.44299, 0.027559, 0.13199],
[ 6, 1, 0.85795, 0.39836, 0.023929, 0.060703],
[ 6, 1, 0.83626, 0.4077, 0.024807, 0.072891],
[ 6, 1, 0.64939, 0.32572, 0.066905, 0.16285],
[ 6, 19, 0.66518, 0.55859, 0.10565, 0.46094],
[ 6, 19, 0.78207, 0.61826, 0.063988, 0.2827],
[ 6, 19, 0.58983, 0.564, 0.063467, 0.42504],
[ 6, 19, 0.33322, 0.56281, 0.060313, 0.43422],
[ 6, 19, 0.53852, 0.41461, 0.037545, 0.083437],
[ 7, 1, 0.85318, 0.7493, 0.072247, 0.32406],
[ 7, 1, 0.79301, 0.74746, 0.047039, 0.33484],
[ 7, 38, 0.37947, 0.24355, 0.26609, 0.15008],
[ 7, 38, 0.73007, 0.55457, 0.12126, 0.2382],
[ 7, 1, 0.16522, 0.71104, 0.0073958, 0.04332],
[ 7, 1, 0.21314, 0.70934, 0.0038691, 0.02],
[ 7, 1, 0.5818, 0.66602, 0.0028572, 0.018594],
[ 7, 1, 0.17909, 0.71131, 0.0043155, 0.038242],
[ 7, 1, 0.9545, 0.68676, 0.015283, 0.11172],
[ 7, 1, 0.24716, 0.70498, 0.0045536, 0.02168],
[ 7, 1, 0.23838, 0.70316, 0.0040179, 0.016875],
[ 7, 1, 0.96447, 0.69387, 0.023438, 0.27688],
[ 7, 1, 0.22234, 0.71023, 0.0022024, 0.017109],
[ 7, 38, 0.42449, 0.69049, 0.11277, 0.26691],
[ 7, 1, 0.92075, 0.76617, 0.07189, 0.29969],
[ 7, 1, 0.49405, 0.67188, 0.9375, 0.19141]],

Licence

Thanks for sharing the great work. Would you mind adding a licence?

load model error

Thanks for your wonderful work!
I run test.py and load yolov4-p5.pt and the error is :
Traceback (most recent call last):
File "/home/yfzhang/PycharmProjects/YOLO/test.py", line 269, in
test(opt.data,
File "/home/yfzhang/PycharmProjects/YOLO/test.py", line 55, in test
model = attempt_load(weights, map_location=device) # load FP32 model
File "/home/yfzhang/PycharmProjects/YOLO/models/experimental.py", line 137, in attempt_load
model.append(torch.load(w, map_location=map_location)['model'].float().fuse().eval()) # load FP32 model
File "/home/yfzhang/anaconda3/envs/YOLO/lib/python3.8/site-packages/torch/serialization.py", line 595, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "/home/yfzhang/anaconda3/envs/YOLO/lib/python3.8/site-packages/torch/serialization.py", line 774, in _legacy_load
result = unpickler.load()
ModuleNotFoundError: No module named 'mc'

get error when running test.py

:~/myProjects/ScaledYOLOv4-yolov4-large# python test.py --img 896 --conf 0.001 --batch 1 --device 0 --data data/coco.yaml --weights weights/yolov4-p5.pt

Namespace(augment=False, batch_size=1, conf_thres=0.001, data='data/coco.yaml', device='0', img_size=896, iou_thres=0.65, merge=False, save_json=True, save_txt=False, single_cls=False, task='val', verbose=False, weights=['weights/yolov4-p5.pt'])
Using CUDA device0 _CudaDeviceProperties(name='Tesla V100-PCIE-16GB', total_memory=16130MB)

/root/.local/lib/python3.7/site-packages/torch/serialization.py:453: SourceChangeWarning: source code of class 'models.yolo.Model' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/root/.local/lib/python3.7/site-packages/torch/serialization.py:453: SourceChangeWarning: source code of class 'torch.nn.modules.container.Sequential' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/root/.local/lib/python3.7/site-packages/torch/serialization.py:453: SourceChangeWarning: source code of class 'torch.nn.modules.conv.Conv2d' has changed. you can retrieve the original source code by accessing theobject's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/root/.local/lib/python3.7/site-packages/torch/serialization.py:453: SourceChangeWarning: source code of class 'torch.nn.modules.batchnorm.SyncBatchNorm' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/root/.local/lib/python3.7/site-packages/torch/serialization.py:453: SourceChangeWarning: source code of class 'torch.nn.modules.container.ModuleList' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
Fusing layers... Model Summary: 331 layers, 7.07943e+07 parameters, 6.81919e+07 gradients
Traceback (most recent call last):
File "test.py", line 278, in
opt.verbose)
File "test.py", line 74, in test
_ = model(img.half() if half else img) if device.type != 'cpu' else None # run once
File "/root/.local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call
result = self.forward(*input, **kwargs)
File "/root/myProjects/ScaledYOLOv4-yolov4-large/models/yolo.py", line 109, in forward
return self.forward_once(x, profile) # single-scale inference, train
File "/root/myProjects/ScaledYOLOv4-yolov4-large/models/yolo.py", line 129, in forward_once
x = m(x) # run
File "/root/.local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call
result = self.forward(*input, **kwargs)
File "/root/myProjects/ScaledYOLOv4-yolov4-large/models/common.py", line 66, in forward
return self.cv4(self.act(self.bn(torch.cat((y1, y2), dim=1))))
File "/root/.local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call
result = self.forward(*input, **kwargs)
File "/root/.local/lib/python3.7/site-packages/torch/nn/modules/batchnorm.py", line 430, in forward
raise AttributeError('SyncBatchNorm is only supported within torch.nn.parallel.DistributedDataParallel')
AttributeError: SyncBatchNorm is only supported within torch.nn.parallel.DistributedDataParallel
root@wufei-jupyter-nchkw:~/myProjects/ScaledYOLOv4-yolov4-large# python test.py --img 896 --conf 0.001 --batch 8 --device 0 --data coco.yaml --weights weights/yolov4-p5.pt
Namespace(augment=False, batch_size=8, conf_thres=0.001, data='./data/coco.yaml', device='0', img_size=896, iou_thres=0.65, merge=False, save_json=True, save_txt=False, single_cls=False, task='val', verbose=False,weights=['weights/yolov4-p5.pt'])
Using CUDA device0 _CudaDeviceProperties(name='Tesla V100-PCIE-16GB', total_memory=16130MB)

/root/.local/lib/python3.7/site-packages/torch/serialization.py:453: SourceChangeWarning: source code of class 'models.yolo.Model' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/root/.local/lib/python3.7/site-packages/torch/serialization.py:453: SourceChangeWarning: source code of class 'torch.nn.modules.container.Sequential' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/root/.local/lib/python3.7/site-packages/torch/serialization.py:453: SourceChangeWarning: source code of class 'torch.nn.modules.conv.Conv2d' has changed. you can retrieve the original source code by accessing theobject's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/root/.local/lib/python3.7/site-packages/torch/serialization.py:453: SourceChangeWarning: source code of class 'torch.nn.modules.batchnorm.SyncBatchNorm' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/root/.local/lib/python3.7/site-packages/torch/serialization.py:453: SourceChangeWarning: source code of class 'torch.nn.modules.container.ModuleList' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
Fusing layers... Model Summary: 331 layers, 7.07943e+07 parameters, 6.81919e+07 gradients
Traceback (most recent call last):
File "test.py", line 278, in
opt.verbose)
File "test.py", line 74, in test
_ = model(img.half() if half else img) if device.type != 'cpu' else None # run once
File "/root/.local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call
result = self.forward(*input, **kwargs)
File "/root/myProjects/ScaledYOLOv4-yolov4-large/models/yolo.py", line 109, in forward
return self.forward_once(x, profile) # single-scale inference, train
File "/root/myProjects/ScaledYOLOv4-yolov4-large/models/yolo.py", line 129, in forward_once
x = m(x) # run
File "/root/.local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call
result = self.forward(*input, **kwargs)
File "/root/myProjects/ScaledYOLOv4-yolov4-large/models/common.py", line 66, in forward
return self.cv4(self.act(self.bn(torch.cat((y1, y2), dim=1))))
File "/root/.local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call
result = self.forward(*input, **kwargs)
File "/root/.local/lib/python3.7/site-packages/torch/nn/modules/batchnorm.py", line 430, in forward
raise AttributeError('SyncBatchNorm is only supported within torch.nn.parallel.DistributedDataParallel')
AttributeError: SyncBatchNorm is only supported within torch.nn.parallel.DistributedDataParallel

Fail to train with multiple of GPU in DP mode

Here is the wrong detail.
Traceback (most recent call last):
File "/home/xxx/hard_disk/xxx/ScaledYOLOv4/train.py", line 438, in
train(hyp, opt, device, tb_writer)
File "/home/xxx/hard_disk/xxx/ScaledYOLOv4/train.py", line 255, in train
loss, loss_items = compute_loss(pred, targets.to(device), model) # scaled by batch_size
File "/home/xxx/hard_disk/xxx/ScaledYOLOv4/utils/general.py", line 446, in compute_loss
tcls, tbox, indices, anchors = build_targets(p, targets, model) # targets
File "/home/xxx/hard_disk/xxx/ScaledYOLOv4/utils/general.py", line 526, in build_targets
r = t[None, :, 4:6] / anchors[:, None] # wh ratio
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

Process finished with exit code 1

How to train yolov4-csp via darknet ?

How to train yolov4-csp using darknet ?

  1. use the yolov4-csp.cfg ?
  2. how to change classes and filters params , the same way as yolov4-custom ?
  3. The yolov4-csp weights can load by opencv ?

Thanks

yolov4 tiny

您好,
我想請問一下這裡的 yolov4-tiny 跟 darknet 的 yolov4-tiny 架構都一樣,但我看論文有說 backbone改為 OSANet,想請問一下這兩個有什麼差別呢? 另外也想請教一下, yolov4-tiny 裡似乎沒有使用 mosaic 是為什麼呢?
謝謝您。

RuntimeError: cuDNN error: CUDNN_STATUS_INTERNAL_ERROR

Analyzing anchors... anchors/target = 7.18, Best Possible Recall (BPR) = 0.9972
Image sizes 640 train, 640 test
Using 4 dataloader workers
Starting training for 300 epochs...
0%| | 0/805 [00:00<?, ?it/s]
Epoch gpu_mem GIoU obj cls total targets img_size
0%| | 0/805 [00:02<?, ?it/s]
Traceback (most recent call last):
File "/home/ljy/ScaledYOLOv4-yolov4-large/train.py", line 448, in
train(hyp, opt, device, tb_writer)
File "/home/ljy/ScaledYOLOv4-yolov4-large/train.py", line 269, in train
scaler.scale(loss).backward()
File "/home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/tensor.py", line 185, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph)
File "/home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/autograd/init.py", line 125, in backward
Variable._execution_engine.run_backward(
RuntimeError: cuDNN error: CUDNN_STATUS_INTERNAL_ERROR
Exception raised from findAlgorithms at /pytorch/aten/src/ATen/native/cudnn/Conv.cpp:550 (most recent call first):
frame #0: c10::Error::Error(c10::SourceLocation, std::string) + 0x42 (0x7f2d0cd8d1e2 in /home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/lib/libc10.so)
frame #1: + 0xec42f7 (0x7f2d0e0ba2f7 in /home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/lib/libtorch_cuda.so)
frame #2: + 0xebcf7e (0x7f2d0e0b2f7e in /home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/lib/libtorch_cuda.so)
frame #3: + 0xeb800e (0x7f2d0e0ae00e in /home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/lib/libtorch_cuda.so)
frame #4: + 0xeb9bfb (0x7f2d0e0afbfb in /home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/lib/libtorch_cuda.so)
frame #5: at::native::cudnn_convolution_backward_input(c10::ArrayRef, at::Tensor const&, at::Tensor const&, c10::ArrayRef, c10::ArrayRef, c10::ArrayRef, long, bool, bool) + 0xb2 (0x7f2d0e0b0152 in /home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/lib/libtorch_cuda.so)
frame #6: + 0xf1f35b (0x7f2d0e11535b in /home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/lib/libtorch_cuda.so)
frame #7: + 0xf4f178 (0x7f2d0e145178 in /home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/lib/libtorch_cuda.so)
frame #8: at::cudnn_convolution_backward_input(c10::ArrayRef, at::Tensor const&, at::Tensor const&, c10::ArrayRef, c10::ArrayRef, c10::ArrayRef, long, bool, bool) + 0x1ad (0x7f2d48fed88d in /home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/lib/libtorch_cpu.so)
frame #9: at::native::cudnn_convolution_backward(at::Tensor const&, at::Tensor const&, at::Tensor const&, c10::ArrayRef, c10::ArrayRef, c10::ArrayRef, long, bool, bool, std::array<bool, 2ul>) + 0x223 (0x7f2d0e0ae823 in /home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/lib/libtorch_cuda.so)
frame #10: + 0xf1f445 (0x7f2d0e115445 in /home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/lib/libtorch_cuda.so)
frame #11: + 0xf4f1d4 (0x7f2d0e1451d4 in /home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/lib/libtorch_cuda.so)
frame #12: at::cudnn_convolution_backward(at::Tensor const&, at::Tensor const&, at::Tensor const&, c10::ArrayRef, c10::ArrayRef, c10::ArrayRef, long, bool, bool, std::array<bool, 2ul>) + 0x1e2 (0x7f2d48ffc242 in /home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/lib/libtorch_cpu.so)
frame #13: + 0x2ec9c62 (0x7f2d4acbfc62 in /home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/lib/libtorch_cpu.so)
frame #14: + 0x2ede224 (0x7f2d4acd4224 in /home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/lib/libtorch_cpu.so)
frame #15: at::cudnn_convolution_backward(at::Tensor const&, at::Tensor const&, at::Tensor const&, c10::ArrayRef, c10::ArrayRef, c10::ArrayRef, long, bool, bool, std::array<bool, 2ul>) + 0x1e2 (0x7f2d48ffc242 in /home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/lib/libtorch_cpu.so)
frame #16: torch::autograd::generated::CudnnConvolutionBackward::apply(std::vector<at::Tensor, std::allocatorat::Tensor >&&) + 0x258 (0x7f2d4ab46c38 in /home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/lib/libtorch_cpu.so)
frame #17: + 0x3375bb7 (0x7f2d4b16bbb7 in /home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/lib/libtorch_cpu.so)
frame #18: torch::autograd::Engine::evaluate_function(std::shared_ptrtorch::autograd::GraphTask&, torch::autograd::Node*, torch::autograd::InputBuffer&, std::shared_ptrtorch::autograd::ReadyQueue const&) + 0x1400 (0x7f2d4b167400 in /home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/lib/libtorch_cpu.so)
frame #19: torch::autograd::Engine::thread_main(std::shared_ptrtorch::autograd::GraphTask const&) + 0x451 (0x7f2d4b167fa1 in /home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/lib/libtorch_cpu.so)
frame #20: torch::autograd::Engine::thread_init(int, std::shared_ptrtorch::autograd::ReadyQueue const&, bool) + 0x89 (0x7f2d4b160119 in /home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/lib/libtorch_cpu.so)
frame #21: torch::autograd::python::PythonEngine::thread_init(int, std::shared_ptrtorch::autograd::ReadyQueue const&, bool) + 0x4a (0x7f2d588fb86a in /home/ljy/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/lib/libtorch_python.so)
frame #22: + 0xc9067 (0x7f2d5a25a067 in /home/ljy/anaconda3/envs/yolov5/bin/../lib/libstdc++.so.6)
frame #23: + 0x9609 (0x7f2d5e43a609 in /lib/x86_64-linux-gnu/libpthread.so.0)
frame #24: clone + 0x43 (0x7f2d5e361293 in /lib/x86_64-linux-gnu/libc.so.6)

前面都是正常的,是我的环境有问题吗

training yolov4-tiny on yolov4-csp branch results in lower AP than darknet version

這幾天嘗試透過yolov4-csp的branch進行COCO 2017 dataset訓練,為了讓yolov4-tiny能過正常訓練,我在parse_config.py中的supported新增了['resize','group_id'],讓yolov4-tiny.cfg中的這兩個參數得以被讀取到,其餘程式碼沒有任何更動。

結果發現訓練出來的yolov4-tiny,AP表現低於您在darknet上所測出來的yolov4-tiny,如下表所示:

 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.158
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.299
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.150
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.052
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.212
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.248
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.169
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.285
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.313
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.097
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.421
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.482

使用的指令是:

python -m torch.distributed.launch --nproc_per_node 4 train.py --device 0,1,2,3 --batch-size 64 --data coco.yaml --cfg yolov4-tiny.cfg --weights 'yolov4-tiny.conv.29' --name yolov4-tiny --sync-bn

之前曾經嘗試在ultralytics/yolov3版本底下訓練YOLOv3-tiny過,測試出來的AP結果還蠻正常的,與darknet版本差不多。

我自己有在猜測會不會是使用多顆GPU進行訓練的關係,不過也不是很確定就是了

我也有讀了yolov4-csp branch中的models.py、layers.py、test.py,發現與ultralytics/yolov3的差異不是很大,不知道您針對這個現象有沒有什麼想法呢?

关于mosaic的问题

你好,感谢你提供这么好的开源项目!
我看到在数据增强使用mosaic时,拼图的中心点,你选择的是样本图片的宽高,yc, xc = s, s
而u版的中心点却不是这种方式,请问你有对比过这两种处理的优劣吗?或者你为什么是这样做的,谢谢!

PyTorch Yolov4-tiny weight

Hi, thank you for the great work !
Is there a PyTorch YOLOV4-tiny weight? I'd like to export it to an ONNX model.

Pre-trained yolov4-p7 doesn't achieve advertised AP

Issue description

yolov4-p7.pt achieves lower AP than advertised one on COCO val

  • Advertised AP
# yolov4-p7
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.55046
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.72925
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.60224
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.39836
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.59854
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.68405
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.40256
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.66929
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.72943
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.59943
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.76873
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.84460
  • Achieved AP
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.545
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.724
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.597
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.394
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.591
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.678
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.400
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.668
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.729
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.602
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.765
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.845

However, i saw the latter is presented in the paper.
Table 10: Ablation study of training schedule with/without fine-tuning. in the paper

Recall yolov4-p7.pt actually achieved

 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.545
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.724
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.597
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.394
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.591
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.678
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.400
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.668
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.729
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.602
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.765
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.845

YOLOv4-P7 without finetuning achieves same AP.
I think yolov4-p7.pt provided in this repo is un-finetuned one. Is it correct?

训练自己的数据集过程中出错

我用yolov5/v3的方法准备数据,训练模型,训练过程中出错了:
from n params module arguments
0 -1 1 928 models.common.Conv [3, 32, 3, 1]
1 -1 1 18560 models.common.Conv [32, 64, 3, 2]
2 -1 1 19904 models.common.BottleneckCSP [64, 64, 1]
3 -1 1 73984 models.common.Conv [64, 128, 3, 2]
4 -1 1 161152 models.common.BottleneckCSP [128, 128, 3]
5 -1 1 295424 models.common.Conv [128, 256, 3, 2]
6 -1 1 2614016 models.common.BottleneckCSP [256, 256, 15]
7 -1 1 1180672 models.common.Conv [256, 512, 3, 2]
8 -1 1 10438144 models.common.BottleneckCSP [512, 512, 15]
9 -1 1 4720640 models.common.Conv [512, 1024, 3, 2]
10 -1 1 20728832 models.common.BottleneckCSP [1024, 1024, 7]
11 -1 1 7610368 models.common.SPPCSP [1024, 512, 1]
12 -1 1 131584 models.common.Conv [512, 256, 1, 1]
13 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
14 8 1 131584 models.common.Conv [512, 256, 1, 1]
15 [-1, -2] 1 0 models.common.Concat [1]
16 -1 1 2298880 models.common.BottleneckCSP2 [512, 256, 3]
17 -1 1 33024 models.common.Conv [256, 128, 1, 1]
18 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
19 6 1 33024 models.common.Conv [256, 128, 1, 1]
20 [-1, -2] 1 0 models.common.Concat [1]
21 -1 1 576000 models.common.BottleneckCSP2 [256, 128, 3]
22 -1 1 295424 models.common.Conv [128, 256, 3, 1]
23 -2 1 295424 models.common.Conv [128, 256, 3, 2]
24 [-1, 16] 1 0 models.common.Concat [1]
25 -1 1 2298880 models.common.BottleneckCSP2 [512, 256, 3]
26 -1 1 1180672 models.common.Conv [256, 512, 3, 1]
27 -2 1 1180672 models.common.Conv [256, 512, 3, 2]
28 [-1, 11] 1 0 models.common.Concat [1]
29 -1 1 9185280 models.common.BottleneckCSP2 [1024, 512, 3]
30 -1 1 4720640 models.common.Conv [512, 1024, 3, 1]
31 [22, 26, 30] 1 50260 models.yolo.Detect [2, [[13, 17, 31, 25, 24, 51, 61, 45], [48, 102, 119, 96, 97, 189, 217, 184], [171, 384, 324, 451, 616, 618, 800, 800]], [256, 512, 1024]]
Model Summary: 476 layers, 7.0274e+07 parameters, 7.0274e+07 gradients

Transferred 935/943 items from weights/yolov4-p5.pt
Optimizer groups: 158 .bias, 163 conv.weight, 155 other
Traceback (most recent call last):
File "/media/lb/1a80f700-11af-4e7a-ace6-c34917dfdbb9/TEST/yolo/train.py", line 443, in
train(hyp, opt, device, tb_writer)
File "/media/lb/1a80f700-11af-4e7a-ace6-c34917dfdbb9/TEST/yolo/train.py", line 151, in train
world_size=opt.world_size)
File "/media/lb/1a80f700-11af-4e7a-ace6-c34917dfdbb9/TEST/yolo/utils/datasets.py", line 60, in create_dataloader
pad=pad)
File "/media/lb/1a80f700-11af-4e7a-ace6-c34917dfdbb9/TEST/yolo/utils/datasets.py", line 344, in init
labels, shapes = zip([cache[x] for x in self.img_files])
File "/media/lb/1a80f700-11af-4e7a-ace6-c34917dfdbb9/TEST/yolo/utils/datasets.py", line 344, in
labels, shapes = zip(
[cache[x] for x in self.img_files])
KeyError: '/media/lb/1a80f700-11af-4e7a-ace6-c34917dfdbb9/TEST/yolo/arm/images/train2017/000000001114.jpg'

定位到代码中在datasets.py的第344行:

  # Get labels
    labels, shapes = zip(*[cache[x] for x in self.img_files])    #344行
    self.shapes = np.array(shapes, dtype=np.float64)
    self.labels = list(labels)

请问这是什么问题造成的?

What is OSANet mentioned in the paper

Hi, you mentioned in the paper that you apply OSANet architecture for tiny model, but I cannot find its reference.
Where may I get more detailed information about OSANet?

By the way, should it be depth $\Beta$ and width $\gamma$ in Table 1?

Thanks.

mish_cuda install filed

i install mish-cuda by this instructions.
For using pre-trained models:

cd /yolo
git clone https://github.com/thomasbrandon/mish-cuda mc
cd mc

# change all of name which is mish_cuda to mish_mish and build.
# 1. mc/src/mish_cuda -> mc/src/mish_mish
# 2. mc/csrc/mish_cuda.cpp -> mc/csrc/mish_mish.cpp
# 3. in mc/setup.py
#   3.1 line 5 -> 'csrc/mish_mish.cpp'
#   3.2 line 11 -> name='mish_mish'
#   3.3 line 20 -> 'mish_mish._C'

python setup.py build
# rename mc/build/lib.xxx folder to mc/build/lib

# modify import in models/common.py
# line 7 -> from mc.build.lib.mish_mish import MishCuda as Mish

but i got some errors in your docker image .my cuda verison is 11, pytorch is 1.7.0 ;
 **python mc/setup.py build
/opt/conda/lib/python3.6/site-packages/torch/cuda/__init__.py:52: UserWarning: CUDA initialization: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx (Triggered internally at  /pytorch/c10/cuda/CUDAFunctions.cpp:100.)
  return torch._C._cuda_getDeviceCount() > 0
No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda'
running build
running build_ext
building 'mish_mish._C' extension
creating /workspace/ScaledYOLOv4-yolov4-large/build
creating /workspace/ScaledYOLOv4-yolov4-large/build/temp.linux-x86_64-3.6
creating /workspace/ScaledYOLOv4-yolov4-large/build/temp.linux-x86_64-3.6/csrc
Emitting ninja build file /workspace/ScaledYOLOv4-yolov4-large/build/temp.linux-x86_64-3.6/build.ninja...
Compiling objects...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
ninja: error: '/workspace/ScaledYOLOv4-yolov4-large/csrc/mish_mish.cpp', needed by '/workspace/ScaledYOLOv4-yolov4-large/build/temp.linux-x86_64-3.6/csrc/mish_mish.o', missing and no known rule to make it
Traceback (most recent call last):
  File "/opt/conda/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 1522, in _run_ninja_build
    env=env)
  File "/opt/conda/lib/python3.6/subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.**

The above exception was the direct cause of the following exception:

**Traceback (most recent call last):
  File "mc/setup.py", line 30, in <module>
    'build_ext': BuildExtension
  File "/opt/conda/lib/python3.6/site-packages/setuptools/__init__.py", line 161, in setup
    return distutils.core.setup(**attrs)
  File "/opt/conda/lib/python3.6/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/opt/conda/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/opt/conda/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/opt/conda/lib/python3.6/distutils/command/build.py", line 135, in run
    self.run_command(cmd_name)
  File "/opt/conda/lib/python3.6/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/opt/conda/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  **File "/opt/conda/lib/python3.6/site-packages/setuptools/**command/build_ext.py", line 87, in run
    _build_ext.run(self)
  File "/opt/conda/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
    _build_ext.build_ext.run(self)
  File "/opt/conda/lib/python3.6/distutils/command/build_ext.py", line 339, in run
    self.build_extensions()
  File "/opt/conda/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 653, in build_extensions
    build_ext.build_extensions(self)
  File "/opt/conda/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 194, in build_extensions
    self.build_extension(ext)
  File "/opt/conda/lib/python3.6/site-packages/setuptools/command/build_ext.py", line 208, in build_extension
    _build_ext.build_extension(self, ext)
  File "/opt/conda/lib/python3.6/distutils/command/build_ext.py", line 533, in build_extension
    depends=ext.depends)
  File "/opt/conda/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 482, in unix_wrap_ninja_compile
    with_cuda=with_cuda)
  File "/opt/conda/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 1238, in _write_ninja_file_and_compile_objects
    error_prefix='Error compiling objects for extension')
  File "/opt/conda/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 1538, in _run_ninja_build
    raise RuntimeError(message) from e
RuntimeError: Error compiling objects for extension**
how can i sove this problem? before this install, i successfully install mish-cuda in anconda enviroment with cuda==10.1 pytorch==1.7 

export libtorch onnx

I want to export the model (libtorch、onnx),but after running the export.py then generate the errors

Traceback (most recent call last):
File "export.py", line 24, in
y = model(img) # dry run
File "/home/sun/anaconda3/envs/th17/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/sun/data/Project_Code/ScaledYOLOv4-yolov4-large/models/yolo.py", line 109, in forward
return self.forward_once(x, profile) # single-scale inference, train
File "/home/sun/data/Project_Code/ScaledYOLOv4-yolov4-large/models/yolo.py", line 129, in forward_once
x = m(x) # run
File "/home/sun/anaconda3/envs/th17/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/sun/data/Project_Code/ScaledYOLOv4-yolov4-large/models/common.py", line 31, in forward
return self.act(self.bn(self.conv(x)))
File "/home/sun/anaconda3/envs/th17/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/sun/anaconda3/envs/th17/lib/python3.6/site-packages/torch/nn/modules/batchnorm.py", line 477, in forward
raise ValueError('SyncBatchNorm expected input tensor to be on GPU')
ValueError: SyncBatchNorm expected input tensor to be on GPU

ERROR: pycocotools unable to run: invalid literal for int() with base 10: 'COCO_val2014_000000054959'

When I use test.py in yolov4-csp branch to calculate the mAP of the trained model, I encounter the following error:

Scanning labels ../coco/labels/val2014.cache (4954 found, 0 missing, 46 empty, 0 duplicate, for 5000 images): 100%|█████████████████████| 5000/5000 [00:00<00:00, 19854.77it/s]
               Class      Images     Targets           P           R      [email protected]  [email protected]:.95: 100%|██████████████████████████████████████████| 625/625 [01:00<00:00, 10.29it/s]
                 all       5e+03    3.51e+04       0.161       0.459       0.314       0.174
Speed: 1.5/3.2/4.8 ms inference/NMS/total per 416x416 image at batch-size 8

COCO mAP with pycocotools... saving detections_val2017__results.json...
ERROR: pycocotools unable to run: invalid literal for int() with base 10: 'COCO_val2014_000000054959'

The command I use:

python test.py --img 416 --conf 0.001 --batch 8 --device 0 --data coco.yaml --cfg models/yolov4-tiny.cfg --weights runs/exp3_yolov4-tiny/weights/best_yolov4-tiny.pt

Thanks for your great work.

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.