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

Error in creating model with Ghost modules #2081

Closed
alrzmshy opened this issue Jan 29, 2021 · 6 comments · Fixed by #2082
Closed

Error in creating model with Ghost modules #2081

alrzmshy opened this issue Jan 29, 2021 · 6 comments · Fixed by #2082
Labels
bug Something isn't working

Comments

@alrzmshy
Copy link

🐛 Bug

Hello, I'm trying to build the yolov5s models with Ghost modules but I run into an issue. I replaced C3 with GhostBottleneck in the yaml file and added GhostBottleneck in the list of modules that are expected in yolo.py file and as I try to construct the model, I get this error:

To Reproduce

Output:

TypeError                                 Traceback (most recent call last)
<ipython-input-2-7facafecdabb> in <module>()
----> 1 model = Model("./models/yolov5s.yaml")
      2 

<ipython-input-1-7b447b7ed90c> in __init__(self, cfg, ch, nc)
     78             logger.info('Overriding model.yaml nc=%g with nc=%g' % (self.yaml['nc'], nc))
     79             self.yaml['nc'] = nc  # override yaml value
---> 80         self.model, self.save = parse_model(deepcopy(self.yaml), ch=[ch])  # model, savelist
     81         self.names = [str(i) for i in range(self.yaml['nc'])]  # default names
     82         # print([x.shape for x in self.forward(torch.zeros(1, ch, 64, 64))])

<ipython-input-1-7b447b7ed90c> in parse_model(d, ch)
    252 
    253         print(m, args)
--> 254         m_ = nn.Sequential(*[m(*args) for _ in range(n)]) if n > 1 else m(*args)  # module
    255         t = str(m)[8:-2].replace('__main__.', '')  # module type
    256         np = sum([x.numel() for x in m_.parameters()])  # number params

TypeError: __init__() missing 1 required positional argument: 's'

Additional context

Here is my models folder that contains the modifications:

models.zip

@alrzmshy alrzmshy added the bug Something isn't working label Jan 29, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Jan 29, 2021

👋 Hello @alrzmshy, thank you for your interest in 🚀 YOLOv5! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

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 training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://www.ultralytics.com or email Glenn Jocher at [email protected].

Requirements

Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

$ pip install -r requirements.txt

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), testing (test.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

@glenn-jocher
Copy link
Member

@alrzmshy hi thanks for the bug report! Ghost bottlenecks are an interesting idea, which is why we included them. They should work just like you said, by replacing a C3 module with a Ghost Bottleneck module. I'll investigate the problem.

@glenn-jocher glenn-jocher added the TODO High priority items label Jan 29, 2021
@glenn-jocher glenn-jocher linked a pull request Jan 29, 2021 that will close this issue
@glenn-jocher
Copy link
Member

@alrzmshy I've updated GhostConv functionality a bit to make it easier to use in PR #2082. You should be able to replace a C3 module with a GhostBottleneck module now in your model.yaml and everything will work correctly.

Screen Shot 2021-01-29 at 11 28 33 AM

@glenn-jocher
Copy link
Member

Removing TODO as original issue is resolved in #2082.

@Henry0528
Copy link

Hello,l've recently changed the yolov5s models with ghost modules.I used ghostconv to replace conv and replaced the bottleneck in C3 with ghostbottleneck. I train with the new model successfully and get only a very small drop in map,while the new model costs about 8 GFlops which is half of the yolov5s model(16GFlops).But when l run the test.py and find that the time consume of testing is almost the same as the yolov5s model,sometime even longer.l don't know whether you have the same question and I wish I can get an answer.

@glenn-jocher
Copy link
Member

@Henry0528 can you post a table of quantiative comparisons identical to the README table before and after your changes on both CPU and GPU?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants