Open Updrones-SimonRegner opened 2 years ago
In general: Don't change the number of classes, just edit label
-> Put the labels in there you have, the rest will be caculated.
=> https://github.com/dbsystel/yolov5-coreml-tools/blob/main/src/coreml_export/main.py#L34
The Traceback is misleading, actually the coreml conversion fails, but it seems I do not exit the application, so it continues to run and then throws later an exception.
This https://github.com/dbsystel/yolov5-coreml-tools/blob/main/src/coreml_export/main.py#L79 line seems to fail, so the actual conversion from torchscript, but the exception is not printed / empty? A little bit weird.
As a first step you should use one of the pretrained models to make sure your setup and everything is correct.
Then it would help, if you share the model, so I can test myself.
When I run it with the pretrained model I get the same error as in #2 I am using yolov5 with the tag version 5. I read in the question #2, that this code had not been tested with the version 5. Where you able to fix the version 5 bug with the pertained model? Could this be the error, or is it maybe something with my setup?
I haven't tried yet, the repo is not actively developed with new features as it works as it is currently for our setup. But I'm happy to help and always accept Pull Requests.
I would then recommend trying one of the yolo models that were already tested by me. I believe that should be version 2, 3 or 4. Just to make sure it's not your setup.
But if you get the same error for version 5 as in #2, then probably your custom model is the problem. Although you should also get some kind of an error regarding your model. That seems still weird to me. How did you train your custom model? Is it based on one of the pretrained models? Which version?
Hi,
I also encountered the same problem with my custom model even with the pretrained model yolov5s. My way to reproduce is,
class SPPF(nn.Module):
def __init__(self, c1, c2, k=5): # equivalent to SPP(k=(5, 9, 13))
super().__init__()
c_ = c1 // 2 # hidden channels
self.cv1 = Conv(c1, c_, 1, 1)
self.cv2 = Conv(c_ * 4, c2, 1, 1)
self.m = nn.MaxPool2d(kernel_size=k, stride=1, padding=k // 2)
def forward(self, x):
x = self.cv1(x)
with warnings.catch_warnings():
warnings.simplefilter('ignore') # suppress torch 1.9.0 max_pool2d() warning
y1 = self.m(x)
y2 = self.m(y1)
return self.cv2(torch.cat([x, y1, y2, self.m(y2)], 1))
Thanks
Hi,
I always getting the error shown in the picture.
I didn't used the pretrained model to train my own one, so I changed the number of classes to 1.
Can someone help me with this problem?
I am using: Python 3.8.8 CoreML toolkit 4.1
Thanks for the help.