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 when training a _w6 model #20

Open
d-colwell opened this issue Nov 27, 2023 · 1 comment
Open

Error when training a _w6 model #20

d-colwell opened this issue Nov 27, 2023 · 1 comment

Comments

@d-colwell
Copy link

Hi,
Loading the a w6 config model using the below code:

    model = create_yolov7_model(
        architecture="yolov7-w6", num_classes=num_classes, pretrained=pretrained
    )

gives you an error in the constructor of the Yolov7DetectionHeadWithAux class. The cause of the error is that use_implicit_modules is being passed to this classes constructor, which is not expecting this arg. To fix this, you can remove the True from the config on line 470 of the model_configs.py, but that exposes a second error.
When use_implicit_modules is defaulted, the forward pass of the network throws an index out of bounds error. I have patched this by defaulting the parameter to true when called from the Yolov7DetectionHeadWithAux constructor, but im not sure if this is the correct approach

@parlaynu
Copy link

I just ran into the same problem. Fixed it by adding the use_implicit_modules argument to the constructor of Yolov7DetectionHeadWithAux so it matches Yolov7DetectionHead, and passing it on to the call to super().__init__ as in the below diff.
No need to change the configs.

class Yolov7DetectionHeadWithAux(Yolov7DetectionHead):
    def __init__(
        self,
         num_classes=80,
         anchor_sizes_per_layer=(),
         strides: torch.Tensor = (),
+        use_implicit_modules: bool = True,
         in_channels_per_layer=(),
     ):
         super().__init__(
-            num_classes, anchor_sizes_per_layer, strides, in_channels_per_layer
+            num_classes, anchor_sizes_per_layer, strides, use_implicit_modules, in_channels_per_layer
         )
         self.m2 = nn.ModuleList(
             nn.Conv2d(in_channels, self.num_outputs * self.num_anchor_sizes, 1)

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

2 participants