Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

我想把三个任务中的驾驶区域分割去掉,只训练车道线和检测这两个任务怎么实现?有没有好心人给点指导 #81

Closed
luna9806 opened this issue Dec 7, 2021 · 6 comments

Comments

@luna9806
Copy link

luna9806 commented Dec 7, 2021

No description provided.

@hs7251912
Copy link

可以修改YOLOP的模型定义。在lib/models/YOLOP.py中修改YOLOP的网络定义,把驾驶区域的网络注释掉。重新加载新模型,命名为YOLOP2head。就可以做训练车道线和检测这两个任务了。
YOLOP2head = [
[24, 33], #Det_out_idx, LL_Segout_idx
[ -1, Focus, [3, 32, 3]], #0
[ -1, Conv, [32, 64, 3, 2]], #1
[ -1, BottleneckCSP, [64, 64, 1]], #2
[ -1, Conv, [64, 128, 3, 2]], #3
[ -1, BottleneckCSP, [128, 128, 3]], #4
[ -1, Conv, [128, 256, 3, 2]], #5
[ -1, BottleneckCSP, [256, 256, 3]], #6
[ -1, Conv, [256, 512, 3, 2]], #7
[ -1, SPP, [512, 512, [5, 9, 13]]], #8
[ -1, BottleneckCSP, [512, 512, 1, False]], #9
[ -1, Conv,[512, 256, 1, 1]], #10
[ -1, Upsample, [None, 2, 'nearest']], #11
[ [-1, 6], Concat, [1]], #12
[ -1, BottleneckCSP, [512, 256, 1, False]], #13
[ -1, Conv, [256, 128, 1, 1]], #14
[ -1, Upsample, [None, 2, 'nearest']], #15
[ [-1,4], Concat, [1]], #16 #Encoder

[ -1, BottleneckCSP, [256, 128, 1, False]], #17
[ -1, Conv, [128, 128, 3, 2]], #18
[ [-1, 14], Concat, [1]], #19
[ -1, BottleneckCSP, [256, 256, 1, False]], #20
[ -1, Conv, [256, 256, 3, 2]], #21
[ [-1, 10], Concat, [1]], #22
[ -1, BottleneckCSP, [512, 512, 1, False]], #23

[17, 20, 23], Detect, [2, [[3,9,5,11,4,20], [7,18,6,39,12,31], [19,50,38,81,68,157]], [128, 256, 512]]], #Detection head 24

[ [17, 20, 23], Detect, [2, [[54,209,53,224,215,52], [62,213,68,328,105,202], [66,430,54,430,172,163]], [128, 256, 512]]], #Detection head 24

[ 16, Conv, [256, 128, 3, 1]], #25

[ -1, Upsample, [None, 2, 'nearest']], #26

[ -1, BottleneckCSP, [128, 64, 1, False]], #27

[ -1, Conv, [64, 32, 3, 1]], #28

[ -1, Upsample, [None, 2, 'nearest']], #29

[ -1, Conv, [32, 16, 3, 1]], #30

[ -1, BottleneckCSP, [16, 8, 1, False]], #31

[ -1, Upsample, [None, 2, 'nearest']], #32

[ -1, Conv, [8, 2, 3, 1]], #33 Driving area segmentation head

[ 16, Conv, [256, 128, 3, 1]], #25
[ -1, Upsample, [None, 2, 'nearest']], #26
[ -1, BottleneckCSP, [128, 64, 1, False]], #27
[ -1, Conv, [64, 32, 3, 1]], #28
[ -1, Upsample, [None, 2, 'nearest']], #29
[ -1, Conv, [32, 16, 3, 1]], #30
[ -1, BottleneckCSP, [16, 8, 1, False]], #31
[ -1, Upsample, [None, 2, 'nearest']], #32
[ -1, Conv, [8, 2, 3, 1]] #33 Lane line segmentation head
]

@luna9806
Copy link
Author

luna9806 commented Dec 8, 2021 via email

@tuvshu99
Copy link

I have changed the YOLOP.py. But i have following error.
What other modification is needed?

=> start training...
Traceback (most recent call last):
File "tools/train.py", line 395, in
main()
File "tools/train.py", line 323, in main
epoch, num_batch, num_warmup, writer_dict, logger, device, rank)
File "/home/essys/test/YOLOP/lib/core/function.py", line 77, in train
total_loss, head_losses = criterion(outputs, target, shapes,model)
File "/home/essys/anaconda3/envs/py36/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/essys/test/YOLOP/lib/core/loss.py", line 50, in forward
total_loss, head_losses = self._forward_impl(head_fields, head_targets, shapes, model)
File "/home/essys/test/YOLOP/lib/core/loss.py", line 114, in _forward_impl
lane_line_seg_predicts = predictions[2].view(-1)
IndexError: list index out of range

@tuvshu99
Copy link

tuvshu99 commented Jan 12, 2022

Sorry, email is not visible.
Added following to the YOLOP.py

YOLOP2H = [
[24, 33], #Det_out_idx, Da_Segout_idx, LL_Segout_idx
[ -1, Focus, [3, 32, 3]], #0
[ -1, Conv, [32, 64, 3, 2]], #1
[ -1, BottleneckCSP, [64, 64, 1]], #2
[ -1, Conv, [64, 128, 3, 2]], #3
[ -1, BottleneckCSP, [128, 128, 3]], #4
[ -1, Conv, [128, 256, 3, 2]], #5
[ -1, BottleneckCSP, [256, 256, 3]], #6
[ -1, Conv, [256, 512, 3, 2]], #7
[ -1, SPP, [512, 512, [5, 9, 13]]], #8
[ -1, BottleneckCSP, [512, 512, 1, False]], #9
[ -1, Conv,[512, 256, 1, 1]], #10
[ -1, Upsample, [None, 2, 'nearest']], #11
[ [-1, 6], Concat, [1]], #12
[ -1, BottleneckCSP, [512, 256, 1, False]], #13
[ -1, Conv, [256, 128, 1, 1]], #14
[ -1, Upsample, [None, 2, 'nearest']], #15
[ [-1,4], Concat, [1]], #16 #Encoder

[ -1, BottleneckCSP, [256, 128, 1, False]], #17
[ -1, Conv, [128, 128, 3, 2]], #18
[ [-1, 14], Concat, [1]], #19
[ -1, BottleneckCSP, [256, 256, 1, False]], #20
[ -1, Conv, [256, 256, 3, 2]], #21
[ [-1, 10], Concat, [1]], #22
[ -1, BottleneckCSP, [512, 512, 1, False]], #23
#[ [17, 20, 23], Detect, [1, [[3,9,5,11,4,20], [7,18,6,39,12,31], [19,50,38,81,68,157]], [128, 256, 512]]], #Detection head 24
[ [17, 20, 23], Detect, [2, [[54,209,53,224,215,52], [62,213,68,328,105,202], [66,430,54,430,172,163]], [128, 256, 512]]], #Detection head 24

#[ 16, Conv, [256, 128, 3, 1]], #25
#[ -1, Upsample, [None, 2, 'nearest']], #26
#[ -1, BottleneckCSP, [128, 64, 1, False]], #27
#[ -1, Conv, [64, 32, 3, 1]], #28
#[ -1, Upsample, [None, 2, 'nearest']], #29
#[ -1, Conv, [32, 16, 3, 1]], #30
#[ -1, BottleneckCSP, [16, 8, 1, False]], #31
#[ -1, Upsample, [None, 2, 'nearest']], #32
#[ -1, Conv, [8, 2, 3, 1]], #33 Driving area segmentation head

[ 16, Conv, [256, 128, 3, 1]], #34
[ -1, Upsample, [None, 2, 'nearest']], #35
[ -1, BottleneckCSP, [128, 64, 1, False]], #36
[ -1, Conv, [64, 32, 3, 1]], #37
[ -1, Upsample, [None, 2, 'nearest']], #38
[ -1, Conv, [32, 16, 3, 1]], #39
[ -1, BottleneckCSP, [16, 8, 1, False]], #40
[ -1, Upsample, [None, 2, 'nearest']], #41
[ -1, Conv, [8, 2, 3, 1]] #42 Lane line segmentation head
]

Line 536 of YOLOP.py, i changed
detects, _= model_out.

Line 578 of YOLOP.py, i changed
m_block_cfg = YOLOP2H

No other change.

@luna9806
Copy link
Author

I have changed the YOLOP.py. But i have following error. What other modification is needed?

=> start training... Traceback (most recent call last): File "tools/train.py", line 395, in main() File "tools/train.py", line 323, in main epoch, num_batch, num_warmup, writer_dict, logger, device, rank) File "/home/essys/test/YOLOP/lib/core/function.py", line 77, in train total_loss, head_losses = criterion(outputs, target, shapes,model) File "/home/essys/anaconda3/envs/py36/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, **kwargs) File "/home/essys/test/YOLOP/lib/core/loss.py", line 50, in forward total_loss, head_losses = self._forward_impl(head_fields, head_targets, shapes, model) File "/home/essys/test/YOLOP/lib/core/loss.py", line 114, in _forward_impl lane_line_seg_predicts = predictions[2].view(-1) IndexError: list index out of range

you need modify "loss.py" line114 115 123 124,change 2 to 1

@luna9806
Copy link
Author

but still exists many bugs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants