Giter Club home page Giter Club logo

yolov5ds's Introduction

YOLOv5DS

Multi-task yolov5 with detection and segmentation based on yolov5(branch v6.0)

  • decoupled head
  • anchor free
  • segmentation head

README中文

Ablation experiment

All experiments is trained on a small dataset with 47 classes ,2.6k+ images for training and 1.5k+ images for validation:

model P R [email protected] [email protected]:95
yolov5s 0.536 0.368 0.374 0.206
yolov5s+train scrach 0.452 0.314 0.306 0.152
yolov5s+decoupled head 0.555 0.375 0.387 0.214
yolov5s + decoupled head+class balance weights 0.541 0.392 0.396 0.217
yolov5s + decoupled head+class balance weights 0.574 0.386 0.403 0.22
yolov5s + decoupled head+seghead 0.533 0.383 0.396 0.212

The baseline model is yolov5s. triks like decoupled head, add class balance weights all help to improve MAP.

Adding a segmentation head can still get equivalent MAP as single detection model.

Training Method

python trainds.py

As VOC dataset do not offer the box labels and mask labels for all images, so we forward this model with a detection batch and a segmention batch by turns, and accumulate the gradient , than update the whole model parameters.

MAP

To compare with the SSD512, we use VOC07+12 training set as the detection training set, VOC07 test data as detection test data, for segmentation ,we use VOC12 segmentation datset as training and test set.

the input size is 512(letter box).

model VOC2007 test
SSD512 79.8
yolov5s+seghead(512) 79.2

The above results only trained less than 200 epoch, weights

demo

see detectds.py.

Train custom data

  1. Use labelme to label box and mask on your dataset;

    the box label format is voc, you can use voc2yolo.py to convert to yolo format,

    the mask label is json files , you should convert to mask .png image labels,like VOC2012 segmentation labels.

  2. see how to arrange your detection dataset with yolov5 , then arrange your segmentation dataset same as yolo files , see data/voc.yaml:

    
    # Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
    path: .  # dataset root dir
    train: VOC/det/images/train  # train images (relative to 'path') 118287 images
    val: VOC/det/images/test  # train images (relative to 'path') 5000 images
    road_seg_train: VOC/seg/images/train   # road segmentation data
    road_seg_val: VOC/seg/images/val
    
    # Classes
    nc: 20  # number of classes
    segnc: 20
    
    names: ['aeroplane', 'bicycle', 'bird', 'boat',
               'bottle', 'bus', 'car', 'cat', 'chair',
               'cow', 'diningtable', 'dog', 'horse',
               'motorbike', 'person', 'pottedplant',
               'sheep', 'sofa', 'train', 'tvmonitor']  # class names
    
    segnames: ['aeroplane', 'bicycle', 'bird', 'boat',
               'bottle', 'bus', 'car', 'cat', 'chair',
               'cow', 'diningtable', 'dog', 'horse',
               'motorbike', 'person', 'pottedplant',
               'sheep', 'sofa', 'train', 'tvmonitor']
    
    1. change the config in trainds.py and :
    python trainds.py 
    
    1. test image folder with :

      python detectds.py
      

Reference

  1. YOLOP: You Only Look Once for Panoptic Driving Perception
  2. yolov5

Blogs

  1. https://blog.csdn.net/IEEE_FELLOW/article/details/121912670?spm=1001.2014.3001.5502
  2. https://blog.csdn.net/qq_57076285/article/details/124265887
  3. https://blog.csdn.net/sadjhaksdas/article/details/125762260
  4. https://blog.csdn.net/LWD19981223/article/details/125921793

yolov5ds's People

Contributors

midasklr 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

yolov5ds's Issues

损失在代码哪部分

你好,我在loss.py里没有看到添加关于语义分割的损失,您把他放在哪里了呢。

weight tensor should be defined either for all or no classes

 Epoch   gpu_mem       box       obj       cls    labels  img_size

0%| | 0/1 [00:00<?, ?it/s]
Traceback (most recent call last):
File "trainds.py", line 686, in
main(opt)
File "trainds.py", line 583, in main
train(opt.hyp, opt, device, callbacks)
File "trainds.py", line 369, in train
segloss = SegLoss(seg_pred[1], segtargets.long().to(device)) # loss scaled by batch_size
File "/root/anaconda3/envs/de1/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/root/anaconda3/envs/de1/lib/python3.8/site-packages/torch/nn/modules/loss.py", line 1047, in forward
return F.cross_entropy(input, target, weight=self.weight,
File "/root/anaconda3/envs/de1/lib/python3.8/site-packages/torch/nn/functional.py", line 2690, in cross_entropy
return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction)
File "/root/anaconda3/envs/de1/lib/python3.8/site-packages/torch/nn/functional.py", line 2387, in nll_loss
ret = torch._C._nn.nll_loss2d(input, target, weight, _Reduction.get_enum(reduction), ignore_index)
RuntimeError: weight tensor should be defined either for all or no classes at /pytorch/aten/src/THCUNN/generic/SpatialClassNLLCriterion.cu:27

VOC数据集格式问题

请问,可以给一个小的VOC数据集的例子吗,不太清楚具体VOC的分割数据集该怎么组织???

非常感谢

视频预测不分割

请问detectds.py 文件 使用test.mp4测试的,为什么没有分割出来呢?而图片有分割出来

分割

大佬你好,请问你这个里面分割是用的什么算法?

RuntimeError: weight tensor should be defined either for all or no classes

I have two categories and I encountered this error when starting training, can you help me
Traceback (most recent call last):
File "D:/git/python/yolov5ds-main/trainds.py", line 372, in train
segloss = SegLoss(seg_pred[1], segtargets.long().to(device)) # loss scaled by batch_size
File "D:\ProgramData\Miniconda3\envs\yolov5\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "D:\ProgramData\Miniconda3\envs\yolov5\lib\site-packages\torch\nn\modules\loss.py", line 1152, in forward
label_smoothing=self.label_smoothing)
File "D:\ProgramData\Miniconda3\envs\yolov5\lib\site-packages\torch\nn\functional.py", line 2846, in cross_entropy

数据集加载部分特别慢

数据集加载部分特别慢,另外自己的数据集按照VOC格式制作好训练不起来,检查过格式没有问题,只是类别是2,各位有知道的这是个什么情况的吗

IndexError: index 1 is out of bounds for axis 0 with size 1

求教在运行detectds.py文件时,出现这种错误是为什么
Traceback (most recent call last):
File "C:/Users/zyh/Desktop/4.6/yolov5ds-main/detectds.py", line 320, in
main(opt)
File "C:/Users/zyh/Desktop/4.6/yolov5ds-main/detectds.py", line 315, in main
run(**vars(opt))
File "D:\python\3.7\lib\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "C:/Users/zyh/Desktop/4.6/yolov5ds-main/detectds.py", line 175, in run
pred_color = colorEncode(mask, colorsmap).astype(np.uint8)
File "C:/Users/zyh/Desktop/4.6/yolov5ds-main/detectds.py", line 46, in colorEncode
np.tile(colors[label],
IndexError: index 1 is out of bounds for axis 0 with size 1

Process finished with exit code 1

TensorRt

@midasklr Hi,

Thank you for your work. Is it possible to run it on TensorRT C++ or Onnx C++?

detectds运行

你好,请问一下我运行detectds过后只有分割的目标没有检测的类别名有遇到过吗而且,我的目标和背景分割出来的颜色跟您贴的demo是相反的

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.