-
Notifications
You must be signed in to change notification settings - Fork 129
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
Yolov7 export to CoreML crashing #22
Comments
Having same problem with Yolov5 as well |
I tried to make converter to get some variable to a argument such as image size, label name. |
Hey @junmcenroe, can I assist you to convert another model in the same domain? |
Hi @roimulia2 I do not catch up your comment correctly, but if you have time to assist to covert another model in the same domain, no issue. Is your intention is to build other model's converter for yolov7-d6/e6/e6e/tiny/w6? <yolov7.yolov7x>
<yolov7-w6, yolov7-e6e, yolov7-d6>
For yolo7-tiny, just to replace anchor numbers should be work |
Yolov7 trained with 1280 x 1280 images (pertained weights / model used: yolov7-d6)
Trained with 5 custom labels.
Inference runs fine, I added --img-size 1280 to the detect command:
!python detect.py --weights my_custom_weights.pt --conf 0.25 --img-size 1280 --source inference/images/my_image.jpg
I updated classLabels[] to my 5 labels (removing the rest)
I added --img-size 1280 to the export command ie !python export.py --img-size 1280 --weight my_custom_weights.pt
but on the last cell, output is:
IndexError Traceback (most recent call last)
in ()
1 # run the functions to add decode layer and NMS to the model.
----> 2 addExportLayerToCoreml(builder)
3 nmsSpec = createNmsModelSpec(builder.spec)
4 combineModelsAndExport(builder.spec, nmsSpec, f"big_data_best.mlmodel") # The model will be saved in this path.
in addExportLayerToCoreml(builder)
45 f"{outputName}_multiplied_xy_by_two"], output_name=f"{outputName}subtracted_0_5_from_xy", mode="ADD", alpha=-0.5)
46 grid = make_grid(
---> 47 featureMapDimensions[i], featureMapDimensions[i]).numpy()
48 # x,y * 2 - 0.5 + grid[i]
49 builder.add_bias(name=f"add_grid_from_xy{outputName}", input_name=f"{outputName}_subtracted_0_5_from_xy",
IndexError: list index out of range
I tried changing cell 8:
featureMapDimensions = [640 // stride for stride in strides]
to
featureMapDimensions = [1280 // stride for stride in strides]
as well as:
builder.add_scale(name=f"normalize_coordinates_{outputName}", input_name=f"{outputName}_raw_coordinates",
output_name=f"{outputName}raw_normalized_coordinates", W=torch.tensor([1 / 640]).numpy(), b=0, has_bias=False)
to
builder.add_scale(name=f"normalize_coordinates{outputName}", input_name=f"{outputName}_raw_coordinates",
output_name=f"{outputName}_raw_normalized_coordinates", W=torch.tensor([1 / 1280]).numpy(), b=0, has_bias=False)
neither attempt worked.
Also, Yolov7 export.py CoreML was recently updated.
I have previously exported a 1280 x 1280 image size Yolov5 custom trained model to Core ML using this repo.
Any thoughts or ideas would be greatly appreciated!!
The text was updated successfully, but these errors were encountered: