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

add ghostbottleneck module into yolov5s.yaml #398

Closed
polarbearwy opened this issue Jul 14, 2020 · 12 comments
Closed

add ghostbottleneck module into yolov5s.yaml #398

polarbearwy opened this issue Jul 14, 2020 · 12 comments
Labels
question Further information is requested Stale

Comments

@polarbearwy
Copy link

❔Question

when i add ghostbottleneck module into yolov5s stucture, issue shows.

Additional context

RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1. Got 34 and 62 in dimension 2 at /pytorch/aten/src/TH/genric/THTensor.cpp:612

@polarbearwy polarbearwy added the question Further information is requested label Jul 14, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Jul 14, 2020

Hello @polarbearwy, thank you for your interest in our work! Please visit our Custom Training Tutorial to get started, and see our Jupyter Notebook Open In Colab, Docker Image, and Google Cloud Quickstart Guide for example environments.

If this is a bug report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom model or data training question, please note that Ultralytics does not provide free personal support. As a leader in vision ML and AI, we do offer professional consulting, from simple expert advice up to delivery of fully customized, end-to-end production solutions for our clients, such as:

  • Cloud-based AI systems operating on hundreds of HD video streams in realtime.
  • Edge AI integrated into custom iOS and Android apps for realtime 30 FPS video inference.
  • Custom data training, hyperparameter evolution, and model exportation to any destination.

For more information please visit https://www.ultralytics.com.

@glenn-jocher
Copy link
Member

@polarbearwy you need to add custom modules you want to use to yolo.py to let it know to expect them. You can do that here:

yolov5/models/yolo.py

Lines 175 to 198 in 1e94bcf

if m in [nn.Conv2d, Conv, Bottleneck, SPP, DWConv, MixConv2d, Focus, CrossConv, BottleneckCSP, C3]:
c1, c2 = ch[f], args[0]
# Normal
# if i > 0 and args[0] != no: # channel expansion factor
# ex = 1.75 # exponential (default 2.0)
# e = math.log(c2 / ch[1]) / math.log(2)
# c2 = int(ch[1] * ex ** e)
# if m != Focus:
c2 = make_divisible(c2 * gw, 8) if c2 != no else c2
# Experimental
# if i > 0 and args[0] != no: # channel expansion factor
# ex = 1 + gw # exponential (default 2.0)
# ch1 = 32 # ch[1]
# e = math.log(c2 / ch1) / math.log(2) # level 1-n
# c2 = int(ch1 * ex ** e)
# if m != Focus:
# c2 = make_divisible(c2, 8) if c2 != no else c2
args = [c1, c2, *args[1:]]
if m in [BottleneckCSP, C3]:
args.insert(2, n)
n = 1

@polarbearwy
Copy link
Author

I have already add custom modules to yolo.py, but there are still problems

@mary-0830
Copy link

I have same question.

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@orangezishuai
Copy link

I have already add custom modules to yolo.py, but there are still problems

hello,are you slove this issue?thanks!

@glenn-jocher
Copy link
Member

@polarbearwy @python-faker there was a recent PR #1176 for a bug fix in GhostConv() modules. Please git pull and try again, and if the error repeats please submit a full Bug Report with code to reproduce. Thank you.

@orangezishuai
Copy link

@polarbearwy @python-faker there was a recent PR #1176 for a bug fix in GhostConv() modules. Please git pull and try again, and if the error repeats please submit a full Bug Report with code to reproduce. Thank you.

thank you very much,I solved the problem through your method.
The reason for the problem is the lack of input parameters. My comparison is as follows

before
class GhostConv(nn.Module): # Ghost Convolution https://github.com/huawei-noah/ghostnet def __init__(self, c1, c2, k=1, s=1, g=1, act=True): # ch_in, ch_out, kernel, stride, groups super(GhostConv, self).__init__() c_ = c2 // 2 # hidden channels # self.cv1 = Conv(c1, c_, k, s, g, act) # self.cv2 = Conv(c_, c_, 5, 1, c_, act)
after
class GhostConv(nn.Module): # Ghost Convolution https://github.com/huawei-noah/ghostnet def __init__(self, c1, c2, k=1, s=1, g=1, act=True): # ch_in, ch_out, kernel, stride, groups super(GhostConv, self).__init__() c_ = c2 // 2 # hidden channels self.cv1 = Conv(c1, c_, k, s, None, g, act) self.cv2 = Conv(c_, c_, 5, 1, None, c_, act)

@glenn-jocher
Copy link
Member

Great!

@lucasjinreal
Copy link

@python-faker how's the ghostconv performance after you changed?

@Ankur-singh
Copy link

@glenn-jocher & @python-faker what did you use for weights? I tried using yolov5s.pt but most of the weights are simply ignored. In the output it showed Transferred 146/553 items from yolov5s.pt
It would be great if someone can share the pretrained weights.

@glenn-jocher
Copy link
Member

@Ankur-singh all of our COCO models are trained from scratch with --weights ''

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Stale
Projects
None yet
Development

No branches or pull requests

6 participants