Code Monkey home page Code Monkey logo

yolor's Introduction

YOLOR

implementation of paper - You Only Learn One Representation: Unified Network for Multiple Tasks

PWC

Unified Network

To get the results on the table, please use this branch.

Model Test Size APtest AP50test AP75test batch1 throughput batch32 inference
YOLOR-CSP 640 52.8% 71.2% 57.6% 106 fps 3.2 ms
YOLOR-CSP-X 640 54.8% 73.1% 59.7% 87 fps 5.5 ms
YOLOR-P6 1280 55.7% 73.3% 61.0% 76 fps 8.3 ms
YOLOR-W6 1280 56.9% 74.4% 62.2% 66 fps 10.7 ms
YOLOR-E6 1280 57.6% 75.2% 63.0% 45 fps 17.1 ms
YOLOR-D6 1280 58.2% 75.8% 63.8% 34 fps 21.8 ms
YOLOv4-P5 896 51.8% 70.3% 56.6% 41 fps (old) -
YOLOv4-P6 1280 54.5% 72.6% 59.8% 30 fps (old) -
YOLOv4-P7 1536 55.5% 73.4% 60.8% 16 fps (old) -
  • Fix the speed bottleneck on our NFS, many thanks to NCHC, TWCC, and NARLabs support teams.
Model Test Size APval AP50val AP75val APSval APMval APLval weights
YOLOv4-CSP 640 49.1% 67.7% 53.8% 32.1% 54.4% 63.2% -
YOLOR-CSP 640 49.2% 67.6% 53.7% 32.9% 54.4% 63.0% weights
YOLOR-CSP* 640 50.0% 68.7% 54.3% 34.2% 55.1% 64.3% weights
YOLOv4-CSP-X 640 50.9% 69.3% 55.4% 35.3% 55.8% 64.8% -
YOLOR-CSP-X 640 51.1% 69.6% 55.7% 35.7% 56.0% 65.2% weights
YOLOR-CSP-X* 640 51.5% 69.9% 56.1% 35.8% 56.8% 66.1% weights

Developing...

Model Test Size APtest AP50test AP75test APStest APMtest APLtest
YOLOR-CSP 640 51.1% 69.6% 55.7% 31.7% 55.3% 64.7%
YOLOR-CSP-X 640 53.0% 71.4% 57.9% 33.7% 57.1% 66.8%

Train from scratch for 300 epochs...

Model Info Test Size AP
YOLOR-CSP evolution 640 48.0%
YOLOR-CSP strategy 640 50.0%
YOLOR-CSP strategy + simOTA 640 51.1%
YOLOR-CSP-X strategy 640 51.5%
YOLOR-CSP-X strategy + simOTA 640 53.0%

Installation

Docker environment (recommended)

Expand
# create the docker container, you can change the share memory size if you have more.
nvidia-docker run --name yolor -it -v your_coco_path/:/coco/ -v your_code_path/:/yolor --shm-size=64g nvcr.io/nvidia/pytorch:20.11-py3

# apt install required packages
apt update
apt install -y zip htop screen libgl1-mesa-glx

# pip install required packages
pip install seaborn thop

# install mish-cuda if you want to use mish activation
# https://github.com/thomasbrandon/mish-cuda
# https://github.com/JunnYu/mish-cuda
cd /
git clone https://github.com/JunnYu/mish-cuda
cd mish-cuda
python setup.py build install

# install pytorch_wavelets if you want to use dwt down-sampling module
# https://github.com/fbcotter/pytorch_wavelets
cd /
git clone https://github.com/fbcotter/pytorch_wavelets
cd pytorch_wavelets
pip install .

# go to code folder
cd /yolor

Colab environment

Expand
git clone https://github.com/WongKinYiu/yolor
cd yolor

# pip install required packages
pip install -qr requirements.txt

# install mish-cuda if you want to use mish activation
# https://github.com/thomasbrandon/mish-cuda
# https://github.com/JunnYu/mish-cuda
git clone https://github.com/JunnYu/mish-cuda
cd mish-cuda
python setup.py build install
cd ..

# install pytorch_wavelets if you want to use dwt down-sampling module
# https://github.com/fbcotter/pytorch_wavelets
git clone https://github.com/fbcotter/pytorch_wavelets
cd pytorch_wavelets
pip install .
cd ..

Prepare COCO dataset

Expand
cd /yolor
bash scripts/get_coco.sh

Prepare pretrained weight

Expand
cd /yolor
bash scripts/get_pretrain.sh

Testing

yolor_p6.pt

python test.py --data data/coco.yaml --img 1280 --batch 32 --conf 0.001 --iou 0.65 --device 0 --cfg cfg/yolor_p6.cfg --weights yolor_p6.pt --name yolor_p6_val

You will get the results:

 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.52510
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.70718
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.57520
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.37058
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.56878
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.66102
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.39181
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.65229
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.71441
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.57755
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.75337
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.84013

Training

Single GPU training:

python train.py --batch-size 8 --img 1280 1280 --data coco.yaml --cfg cfg/yolor_p6.cfg --weights '' --device 0 --name yolor_p6 --hyp hyp.scratch.1280.yaml --epochs 300

Multiple GPU training:

python -m torch.distributed.launch --nproc_per_node 2 --master_port 9527 train.py --batch-size 16 --img 1280 1280 --data coco.yaml --cfg cfg/yolor_p6.cfg --weights '' --device 0,1 --sync-bn --name yolor_p6 --hyp hyp.scratch.1280.yaml --epochs 300

Training schedule in the paper:

python -m torch.distributed.launch --nproc_per_node 8 --master_port 9527 train.py --batch-size 64 --img 1280 1280 --data data/coco.yaml --cfg cfg/yolor_p6.cfg --weights '' --device 0,1,2,3,4,5,6,7 --sync-bn --name yolor_p6 --hyp hyp.scratch.1280.yaml --epochs 300
python -m torch.distributed.launch --nproc_per_node 8 --master_port 9527 tune.py --batch-size 64 --img 1280 1280 --data data/coco.yaml --cfg cfg/yolor_p6.cfg --weights 'runs/train/yolor_p6/weights/last_298.pt' --device 0,1,2,3,4,5,6,7 --sync-bn --name yolor_p6-tune --hyp hyp.finetune.1280.yaml --epochs 450
python -m torch.distributed.launch --nproc_per_node 8 --master_port 9527 train.py --batch-size 64 --img 1280 1280 --data data/coco.yaml --cfg cfg/yolor_p6.cfg --weights 'runs/train/yolor_p6-tune/weights/epoch_424.pt' --device 0,1,2,3,4,5,6,7 --sync-bn --name yolor_p6-fine --hyp hyp.finetune.1280.yaml --epochs 450

Inference

yolor_p6.pt

python detect.py --source inference/images/horses.jpg --cfg cfg/yolor_p6.cfg --weights yolor_p6.pt --conf 0.25 --img-size 1280 --device 0

You will get the results:

horses

Citation

@article{wang2023you,
  title={You Only Learn One Representation: Unified Network for Multiple Tasks},
  author={Wang, Chien-Yao and Yeh, I-Hau and Liao, Hong-Yuan Mark},
  journal={Journal of Information Science and Engineering},
  year={2023}
}

Acknowledgements

Expand

yolor'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

yolor's Issues

Training on Multiple GPUs Error

How can I fix this?

Traceback (most recent call last):
  File "train.py", line 537, in <module>
    train(hyp, opt, device, tb_writer, wandb)
  File "train.py", line 288, in train
    loss, loss_items = compute_loss(pred, targets.to(device), model)  # loss scaled by batch_size
  File "/yolor/utils/loss.py", line 66, in compute_loss
    tcls, tbox, indices, anchors = build_targets(p, targets, model)  # targets
  File "/yolor/utils/loss.py", line 145, 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!

遇到了一个RuntimeError,如何解决?我使用的是非COCO数据集

Traceback (most recent call last):
File "train.py", line 540, in
train(hyp, opt, device, tb_writer, wandb)
File "train.py", line 287, in train
pred = model(imgs) # forward
File "D:\Software\Anaconda3\envs\YOLOR\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "G:\datasets_models\obj_models\yolor\models\models.py", line 543, in forward
return self.forward_once(x)
File "G:\datasets_models\obj_models\yolor\models\models.py", line 594, in forward_once
x = module(x, out) # WeightedFeatureFusion(), FeatureConcat()
File "D:\Software\Anaconda3\envs\YOLOR\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "G:\datasets_models\obj_models\yolor\utils\layers.py", line 404, in forward
return a.expand_as(x) * x
RuntimeError: The expanded size of the tensor (39) must match the existing size (255) at non-singleton dimension 1. Target sizes: [1, 39, 160, 160]. Tensor sizes: [1, 255, 1, 1]

Issues on the pretrained model

Hi,

Great work!
I use the main branch to train my model. I checked the pretrained yolor_p6.pt is okay. But could you provide more well-trained model for fine-tune? such as yolor_w6.pt, yolor_e6.pt....

I noticed in your paper branch, you provide these model, yolor-w6.pt, yolor-e6.pt....But it may not be compatible with the main branch code with the following error:

ModuleNotFoundError: No module named 'models.yolo'

Hope to get your advice!

Problem during testing with coco val2017 dataset

Used the following command:
python test.py --data data/coco.yaml --img 1280 --batch 32 --conf 0.001 --iou 0.65 --device 0 --cfg cfg/yolor_p6.cfg --weights yolor_p6.pt --name yolor_p6_val
Got the following result:
image

  • Provided the path to the dataset(images val2017)
  • Made a 'coco' directory and put the 'instances-val2017.json' file there under 'annotations folder'

What am I missing? It says that there are no labels, but I have provided the JSON file. Do I need to provide the annotation TXT files too? I am sorry if the question is dumb I am a beginner

yolov4-csp-fast

Hi ,

Thanks for your great job. I want to use your yolov4-csp-fast model. My codebranch is "paper".
As your paper said :YOLOv4-CSP-fast is modified from YOLOv4-CSP, we replace Stem A in YOLOv4-CSP by Stem B to form YOLOv4-CSP-fast.

so I only replace the first layer to ;

backbone:
  # [from, number, module, args]
  [[-1, 1, ReOrg, []],  # 0
   [-1, 1, Conv, [64, 3, 1]],  # 1-P1/2
   [-1, 1, Bottleneck, [64]],
   [-1, 1, Conv, [128, 3, 2]],  # 3-P2/4
   [-1, 2, BottleneckCSP, [128]],
   [-1, 1, Conv, [256, 3, 2]],  # 5-P3/8
   [-1, 8, BottleneckCSP, [256]],
   [-1, 1, Conv, [512, 3, 2]],  # 7-P4/16
   [-1, 8, BottleneckCSP, [512]],
   [-1, 1, Conv, [1024, 3, 2]], # 9-P5/32
   [-1, 4, BottleneckCSP, [1024]],  # 10
  ]

But it seems wrong:

RuntimeError: cuDNN error: CUDNN_STATUS_NOT_INITIALIZED Traceback (most recent call last): File "train.py", line 562, in <module> train(hyp, opt, device, tb_writer, wandb) File "train.py", line 318, in train scaler.scale(loss).backward() File "/opt/conda/lib/python3.6/site-packages/torch/tensor.py", line 227, in backward torch.autograd.backward(self, gradient, retain_graph, create_graph) File "/opt/conda/lib/python3.6/site-packages/torch/autograd/__init__.py", line 138, in backward allow_unreachable=True) # allow_unreachable flag

but if i set second layer to

[-1, 1, Conv, [64, 3, 2]], # 1-P1/2
it seems no problem.

can you share me your yolov4-csp-fast.yaml?
if i want inference more quickly, can i use DownC and BottleneckCSPF like yolor-d6?

thanks

Thanks!

pascal voc to yolo label format

I see in the train phase that we provide only 1280 as a dimension. So do we resize the image to say 1280x1280 before converting to yolo label format? Currently my yolo label was created with 720x1280 images. (Sorry, I'm new to Yolo)

training schedule logic

Hi,

I am confused about your training schedule logic in branch "paper".

`python -m torch.distributed.launch --nproc_per_node 8 --master_port 9527 train.py --batch-size 64 --img 1280 1280 --data data/coco.yaml --cfg models/yolor-p6.yaml --weights '' --sync-bn --device 0,1,2,3,4,5,6,7 --name yolor-p6 --hyp hyp.scratch.1280.yaml --epochs 300

python -m torch.distributed.launch --nproc_per_node 8 --master_port 9527 tune.py --batch-size 64 --img 1280 1280 --data data/coco.yaml --cfg models/yolor-p6.yaml --weights 'runs/train/yolor-p6/weights/last_298.pt' --sync-bn --device 0,1,2,3,4,5,6,7 --name yolor-p6-tune --hyp hyp.finetune.1280.yaml --epochs 450

python -m torch.distributed.launch --nproc_per_node 8 --master_port 9527 train.py --batch-size 64 --img 1280 1280 --data data/coco.yaml --cfg models/yolor-p6.yaml --weights 'runs/train/yolor-p6-tune/weights/epoch_424.pt' --sync-bn --device 0,1,2,3,4,5,6,7 --name yolor-p6-fine --hyp hyp.finetune.1280.yaml --epochs 450`

In third step, why you choose the epoch_424, and train only bis 450 epochs(only train remain 26 epochs )? why not chose the best finetung epoch?

colab train problem

!python train.py --data ./data/uav_coco.yaml --batch-size 8 --cfg ./models/uav_e6.yaml --name yolor-p6 --weights "" --hyp ./data/hyp.scratch.1280.yaml
i have some problems
Traceback (most recent call last):
File "train.py", line 537, in
train(hyp, opt, device, tb_writer, wandb)
File "train.py", line 86, in train
model = Darknet(opt.cfg).to(device) # create
File "/content/yolor/models/models.py", line 530, in init
self.module_defs = parse_model_cfg(cfg)
File "/content/yolor/utils/parse_config.py", line 13, in parse_model_cfg
with open(path, 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: './models/uav_e6.yaml.cfg'

AssertionError: No labels found in ../train/labels/.

I am currently using this repository in a Colab notebook on a custom dataset but when I try running the training script, I keep getting the following error:

Traceback (most recent call last):
  File "train.py", line 537, in <module>
    train(hyp, opt, device, tb_writer, wandb)
  File "train.py", line 183, in train
    rank=rank, world_size=opt.world_size, workers=opt.workers)
  File "/content/yolor/utils/datasets.py", line 72, in create_dataloader
    rank=rank)
  File "/content/yolor/utils/datasets.py", line 499, in __init__
    assert not augment, '%s. Can not train without labels.' % s
AssertionError: WARNING: No labels found in ../train/labels/. See https://github.com/ultralytics/yolov5/wiki/Train-Custom-Data. Can not train without labels.

I know for a fact that my dataset structure is formatted correctly and I do have labels in my train/labels/ folder so I was unsure what could be causing this issue. My folder structure looks something like this:
fldr-structure
For reference, I am running the following command to start the training process:

python train.py --batch-size 8 --img 416 416 --data /content/data.yaml --cfg cfg/yolor_p6.cfg --weights '' --device 0 --name yolor_p6 --hyp hyp.scratch.1280.yaml --epochs 300

And my data.yaml file looks like this:

train: ../train/images
val: ../valid/images

nc: 3
names: ['Crab', 'Lobster', 'Shrimp']

Any and all help would be appreciated; thank you!

Failing to finetune

Here's what I did:

  1. I have a pascal voc format label (8 classes, completely different form coco labels), which I converted to yolo format using this: https://gist.github.com/Amir22010/a99f18ca19112bc7db0872a36a03a1ec

  2. I made changes to yolor_p6.cfg, replacing filters from 255 with appropriate value, in my case 39, and the num_classes.

  3. I replaced labels in coco.labels with 8 classes of my own.

  4. The train command I used:
    python train.py --batch-size 1 --img 1280 1280 --data coco.yaml --cfg cfg/yolor_p6.cfg --weights yolor_p6.pt --device 0 --name yolor_p6_digit --hyp hyp.scratch.1280.yaml --epochs 20

Also tried with hyp.finetune.1280.yaml

But the model doesn't learn anything. Infact after 12 epochs the losses start increasing and mAP starts falling, which was already bad to begin with. Can you please guide me?

执行detect.py,使用自己训练好的权重检测一段.mp4视频报错

作者你好,继上次我使用自己的数据集训练好网络后,想使用训练好的权重检测一段mp4视频,但是报错了。视频为test.mp4,我放在和detct.py同级的目录下,运行指令如下:
python detect.py --source test.mp4 --cfg cfg/yolor_p6_puxiang.cfg --weights runs/train/exp3/weights/last_998.pt --conf 0.25 --img-size 1280 --device 0
报错如下:
Traceback (most recent call last):
File "detect.py", line 186, in
detect()
File "detect.py", line 44, in detect
model.load_state_dict(torch.load(weights[0], map_location=device)['model'])
File "D:\Software\Anaconda3\envs\YOLOR\lib\site-packages\torch\serialization.py", line 579, in load
with _open_file_like(f, 'rb') as opened_file:
File "D:\Software\Anaconda3\envs\YOLOR\lib\site-packages\torch\serialization.py", line 230, in _open_file_like
return _open_file(name_or_buffer, mode)
File "D:\Software\Anaconda3\envs\YOLOR\lib\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: 'y'

请问是否是yoloR不支持检测视频,只支持检测图片?还是我环境配置的问题呢?谢谢

How to change cfg for custom dataset with different number of classes?

Darknet repo has guide "How to train (to detect your custom objects)", where described how change count filters and other parameters for custom dataset. If i change in yolor_p6.cfg number of classes to 2, i get error

  File "/workspace/yolor/models/models.py", line 400, in forward
    p = p.view(bs, self.na, self.no, self.ny, self.nx).permute(0, 1, 3, 4, 2).contiguous()  # prediction
RuntimeError: shape '[4, 3, 7, 80, 80]' is invalid for input of size 6528000

No license File

Hi,
I have been looking through your projects, they are very cool. however I have noticed that, unlike darknet from alexab, none of your code has a license file... Which means that, at the moment, technically, people only have rights to view it, running and modifying the code is not allowed. I realize thinking about copyright is a pain in the rear, but the lawyers do care...

If you could add a license file to your projects (yolov4, yolov4csp, yolor, etc) it would be greatly appreciated.

Low FPS on jetson type devices

Hello. Thanks for your work.
When testing yolor-ssss-dwt 640 on devices like jetson Xavier NX, an unsatisfactory result was obtained in terms of performance (about 30 frames per second), yolo4-tiny + tkDNN FP16 640 * 640 ~ 100 fps. Are there ways to speed up the output for end devices?
At 2070S ~ 100 FPS

Unexpected output shape of onnx model

Hi! i'm on the paper branch and have exported a yolor-p6 model to onnx using models/export.py.
The onnx model has the output shape output: batch, 3, 96, 160, nc though I expected the shape output: batch, 3, max_boxes, nc
Am I doing anything wrong?
Thanks!

export onnx error

Hi

when exporting onnx, i faced a problem. Do you know how to solve this problem? I used leakyrelu to replace silu(not supported bei onnx ).

python -m torch.distributed.launch --nproc_per_node 8 --master_port 9527 train.py --batch-size 256 --img 640 640 --data data/.yaml --cfg models/yolor-ssss-dwt.yaml --weights '' --sync-bn --device 0,1,2,3,4,5,6,7 --name yolor-ssss --hyp hyp.scratch.1280.yaml --epochs 2

Starting ONNX export with onnx 1.7.0...
ONNX export failure: Sizes of tensors must match except in dimension 1. Got 23 and 24 in dimension 2 (The offending index is 1)

Training on custom dataset and labels

I have a dataset of my own which has 8 labels, completely different from the coco labels. I changed the data/coco.names and data/coco.yaml accordingly. But I get an index error:

Traceback (most recent call last):
  File "train.py", line 537, in <module>
    train(hyp, opt, device, tb_writer, wandb)
  File "train.py", line 344, in train
    log_imgs=opt.log_imgs if wandb else 0)
  File "/home/ubuntu/yolor/test.py", line 226, in test
    plot_images(img, output_to_target(output, width, height), paths, f, names)  # predictions
  File "/home/ubuntu/yolor/utils/plots.py", line 164, in plot_images
    cls = names[cls] if names else cls
IndexError: list index out of range

I tried printing the detection classes and its in the range 0-79 i.e coco labels. But why is this happening when I completely changed the labels?

Training command:
python train.py --batch-size 1 --img 1280 1280 --data coco.yaml --cfg cfg/yolor_p6.cfg --weights yolor_p6.pt --device 0 --name yolor_p6_digit --hyp hyp.scratch.1280.yaml --epochs 5

What should I do when testing doesn't work with pycocotools?

               Class      Images     Targets           P           R      [email protected]
               Class      Images     Targets           P           R      [email protected]
               Class      Images     Targets           P           R      [email protected]
               Class      Images     Targets           P           R      [email protected]
               Class      Images     Targets           P           R      [email protected]
               Class      Images     Targets           P           R      [email protected]
  [email protected]:.95: 100%|█| 18/18 [00:14<00:00,  1.89it/s]
                 all         548    3.88e+04       0.377       0.559       0.488       0.309
Speed: 8.8/4.6/13.4 ms inference/NMS/total per 1280x1280 image at batch-size 32

Evaluating pycocotools mAP... saving runs/test/yolor_p6_val8/best_ap_predictions.json...
loading annotations into memory...
ERROR: pycocotools unable to run: expected str, bytes or os.PathLike object, not list
Results saved to runs/test/yolor_p6_val8

This is what I get while testing. What should I do when this happens?

How do I use YOLOR-SSSS-DWT model?

I couldn't find YOLOR(or YOLOv4)-SSS(or SSSS)-DWT(or S2D) model in this repo.
It also has no detailed information in the paper.

Q1. How do I use DWT model or DWT module?

Q2. Can you provide DWT model and the weights?

Q3. What is S2D in YOLOR-SSSS and what is the difference between S2D and DWT? (not essential)

About num of filters in .cfg file

Hello, I'm trying to train YOLOR on my custom data.

In previous versions of YOLO, we set (classes + 5) * 3 filters in [convolution] layers before [yolo] layers.
I think we should do the same thing to 4 [implicit_mul] layers in yolor_p6.cfg in your work.
Is this collect?

Thank you.

关于plot_images的索引超出范围的问题

作者你好,我在运行我自己的数据集,到了最后一个epoch时,出现了下面的错误
Traceback (most recent call last):
File "F:/jinyuan/yolor-main/train.py", line 537, in
train(hyp, opt, device, tb_writer, wandb)
File "F:/jinyuan/yolor-main/train.py", line 344, in train
log_imgs=opt.log_imgs if wandb else 0)
File "F:\jinyuan\yolor-main\test.py", line 226, in test
plot_images(img, output_to_target(output, width, height), paths, f, names) # predictions
File "F:\jinyuan\yolor-main\utils\plots.py", line 163, in plot_images
cls = names[cls] if names else cls
IndexError: list index out of range
因为这个问题,导致最后在run里面少了很多图片,没有mAp的曲线图

请教,这是什么原因导致的呢,有何解决的方法,谢谢

SyntaxError while testing on jetson xavier nx

  File "test.py", line 155
    for *xyxy, conf, cls in x:
        ^
SyntaxError: invalid syntax

I know that the code is great(syntax error didn't happen when ran on the server), but I get syntaxerror when running test.py on jetson xavier nx. What should I do?

non_max_suppression causes CUDA out of memory.

I am training yolor with crowdhuman dataset. Even the train and test batch sizes are set to 1, the program still encounters memory problems when testing (I got 12G memory). I found it is due to non_max_suppression, anyone has the same problem?

Traceback (most recent call last):
  File "train.py", line 537, in <module>
    train(hyp, opt, device, tb_writer, wandb)
File "train.py", line 336, in train
results, maps, times = test.test(opt.data,
File "/workplace/Codes/yolor/test.py", line 134, in test
    output = non_max_suppression(inf_out, conf_thres=conf_thres, iou_thres=iou_thres)
File "/workplace/Codes/yolor/utils/general.py", line 341, in non_max_suppression
i = torch.ops.torchvision.nms(boxes, scores, iou_thres)
RuntimeError: CUDA out of memory. Tried to allocate 10.49 GiB (GPU 0; 10.91 GiB total capacity; 618.68 MiB already allocated; 6.45 GiB free; 3.78 GiB reserved in total by PyTorch) 

使用YOLOR训练自己的数据集(txt标注格式)报错

运行train.py,报错:Exception: Dataset not found
我想请问,YOLOR是否支持txt标注的数据集直接进行训练? 还是必须要先转成json或者xml的标注格式才能用?
README文件并未说明。也就是说,我是否要先把自己的数据集变成COCO数据集的格式才可以使用YOLOR,还是说可以向YOLOV5那样,使用txt标注的数据集直接训练呢?
谢谢

image size attribut not working

hi, when I change --img-size from 1280 to 320 for example it is not working and throws me an error which is :

Traceback (most recent call last):
File "detect.py", line 187, in
detect()
File "detect.py", line 86, in detect
pred = model(img, augment=opt.augment)[0]
File "C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Users\ASUS\Desktop\yoloR\yolor\models\models.py", line 543, in forward
return self.forward_once(x)
File "C:\Users\ASUS\Desktop\yoloR\yolor\models\models.py", line 594, in forward_once
x = module(x, out) # WeightedFeatureFusion(), FeatureConcat()
File "C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Users\ASUS\Desktop\yoloR\yolor\utils\layers.py", line 69, in forward
return torch.cat([outputs[i] for i in self.layers], 1) if self.multiple else outputs[self.layers[0]]
RuntimeError: torch.cat(): Sizes of tensors must match except in dimension 1. Got 15 and 16 in dimension 2 (The offending index is 1)

any solution for this problem .

The question is about the speed of the solution and its optimization.

Thanks for your work!
I would like to understand solutions that could be applied in final products, that is, solutions that are at the yolo4-tiny level in terms of speed / accuracy or better. The computational complexity of the solution is not entirely clear from the reamde file, as well as the possibility of using acceleration (for example, tkDNN) to increase the output speed. If you can describe in more detail the result obtained in terms of speed.

I wanted to have a testing table on jetson type devices

使用main分支下models/export.py转换yolor_p6.pt失败

代码修改如下:

import argparse
from models import *
from utils.torch_utils import select_device
import torch
from utils.google_utils import attempt_download
from utils.google_utils import attempt_load

if name == 'main':

parser = argparse.ArgumentParser()
parser.add_argument('--weights', type=str, default='./yolov4.pt', help='weights path')
parser.add_argument('--img-size', nargs='+', type=int, default=[640, 640], help='image size')
parser.add_argument('--batch-size', type=int, default=1, help='batch size')
parser.add_argument('--cfg', type=str, help='batch size')
opt = parser.parse_args()
opt.img_size *= 2 if len(opt.img_size) == 1 else 1  # expand
print(opt)

# Input
img = torch.zeros((opt.batch_size, 3, *opt.img_size)) # image size(1,3,320,192) ### ### iDetection
# Load PyTorch model
attempt_download(opt.weights)
model = Darknet(opt.cfg, opt.img_size)
model.load_state_dict(torch.load(opt.weights)['model'])
model.eval()
y = model(img)  # dry run

try:
    import onnx

    print('\nStarting ONNX export with onnx %s...' % onnx.__version__)
    f = opt.weights.replace('.pt', '.onnx')  # filename
    model.fuse()  # only for ONNX
    torch.onnx.export(model, img, f, verbose=False, opset_version=12, input_names=['images'],
                      output_names=['output'])
    # Checks
    onnx_model = onnx.load(f)  # load onnx model
    onnx.checker.check_model(onnx_model)  # check onnx model
    print(onnx.helper.printable_graph(onnx_model.graph))  # print a human readable model
    print('ONNX export success, saved as %s' % f)
except Exception as e:
    print('ONNX export failure: %s' % e)

代码我修改为上面的样式,onnx版本1.9.0,
使用命令为:python models/export.py --weights yolor_p6.pt --img-size 1280 --cfg cfg/yolor_p6.cfg

目前报错ONNX export failure: Exporting the operator silu to ONNX opset version 12 is not supported. Please open a bug to request ONNX export support for the missing operator.

我尝试了其他版本的onnx,也尝试了不同版本的opset_version,10以上都是这个错误,10以下是ONNX export failure: step!=1 is currently not supported

非常感谢,期待您的回复

How about yolov4-p6-light in 640 size?

I have test trained yolor-p6.yaml In VisDrone dataset (a famous UAV dataset) use 640 size and your pretrained .pt. And I get a excellent results, It's a great work!
Then, I trained yolov4-p6-light.yaml(remove the reOrg and IDetect module and I fix it in yolov5's rep) in VisDrone dataset use 640 size without pretrained, but the results under the original yolov4-csp‘s result. maybe it have some bug in my code.
So I'm training the same yolov4-p6-light.yaml(remove the reOrg and IDetect module and I fix it in your yolor's rep) in VisDrone use 640 size without pretrained, and I need find the bug in my own code if your yolor rep can get a good results. If not, that says yolov4-p6-light need a coco pretrained? because the model have four output, the loss can hard to convergence?
The all experiment trained in 300epoch, 32batchsize, 640*640 size, use single V100 to train the model. maybe you can solve my question. thks!

Difference between YOLO and JDE

Does the difference of both layers do inference?
I saw the method

io[..., :4] *= self.stride io[..., 4:] = F.softmax(io[..., 4:])

What does it means?

Unable to convert yolor_p6 to TensorRT

Thanks for this repository!
I managed to convert a trained model to ONNX using convert_onnx.py, but I can't manage to convert it to TensorRT for inference on a Jetson Xavier NX.

I have included the TensorRT (v7.1.3) build output below:

----------------------------------------------------------------
Input filename:   best.onnx
ONNX IR version:  0.0.6
Opset version:    11
Producer name:    pytorch
Producer version: 1.8
Domain:           
Model version:    0
Doc string:       
----------------------------------------------------------------
[06/10/2021-17:40:43] [W] [TRT] onnx2trt_utils.cpp:220: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
[06/10/2021-17:40:43] [W] [TRT] onnx2trt_utils.cpp:246: One or more weights outside the range of INT32 was clamped
[06/10/2021-17:40:43] [W] [TRT] onnx2trt_utils.cpp:246: One or more weights outside the range of INT32 was clamped
[06/10/2021-17:40:43] [W] [TRT] onnx2trt_utils.cpp:246: One or more weights outside the range of INT32 was clamped
[06/10/2021-17:40:43] [W] [TRT] onnx2trt_utils.cpp:246: One or more weights outside the range of INT32 was clamped
[06/10/2021-17:40:43] [W] [TRT] onnx2trt_utils.cpp:246: One or more weights outside the range of INT32 was clamped
[06/10/2021-17:40:43] [W] [TRT] onnx2trt_utils.cpp:246: One or more weights outside the range of INT32 was clamped
[06/10/2021-17:40:43] [W] [TRT] onnx2trt_utils.cpp:246: One or more weights outside the range of INT32 was clamped
[06/10/2021-17:40:43] [W] [TRT] onnx2trt_utils.cpp:246: One or more weights outside the range of INT32 was clamped
[06/10/2021-17:40:43] [W] [TRT] onnx2trt_utils.cpp:246: One or more weights outside the range of INT32 was clamped
[06/10/2021-17:40:43] [I] [TRT] ModelImporter.cpp:135: No importer registered for op: ScatterND. Attempting to import as plugin.
[06/10/2021-17:40:43] [I] [TRT] builtin_op_importers.cpp:3659: Searching for plugin: ScatterND, plugin_version: 1, plugin_namespace: 
[06/10/2021-17:40:43] [E] [TRT] INVALID_ARGUMENT: getPluginCreator could not find plugin ScatterND version 1
ERROR: builtin_op_importers.cpp:3661 In function importFallbackPluginImporter:
[8] Assertion failed: creator && "Plugin not found, are the plugin name, version, and namespace correct?"
[06/10/2021-17:40:43] [E] Failed to parse onnx file
[06/10/2021-17:40:43] [E] Parsing model failed
[06/10/2021-17:40:43] [E] Engine creation failed
[06/10/2021-17:40:43] [E] Engine set up failed
&&&& FAILED TensorRT.trtexec # trtexec --onnx=best.onnx

Any ideas on how to solve the ScatterND issue? Seems like a broadcasting operation unsupported by TRT.
Maybe using different opset version than 11, or rewriting all the lines that have elipsis indexing?

Error in Export onnx

!python models/export.py --weights yolor_p6.pt --img-size 512 --cfg cfg/yolor_p6.cfg

i got this error

Traceback (most recent call last):
File "models/export.py", line 5, in
from utils.google_utils import attempt_download
ModuleNotFoundError: No module named 'utils'

Train with branch paper

Hello! When I finish training with branch paper, it encountered with an error:

  File "train.py", line 562, in <module>
    train(hyp, opt, device, tb_writer, wandb)
  File "train.py", line 369, in train
    log_imgs=opt.log_imgs if wandb else 0)
  File "/home/linghu8812/yolor_ele/test.py", line 211, in test
    plot_images(img, output_to_target(output, width, height), paths, f, names)  # predictions
  File "/home/linghu8812/yolor_ele/utils/plots.py", line 108, in output_to_target
    return np.array(targets)
  File "/media/D/anaconda3/envs/deeplearning/lib/python3.7/site-packages/torch/tensor.py", line 630, in __array__
    return self.numpy()
TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

perhaps it should be this?

 return np.array(targets.cpu())

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.