TokyoYoshida / CoreMLYOLOExample

Example of YOLOv3 Model running on Core ML
0 stars 0 forks source link

Conversion process for yolov3 model to coreML format #1

Open NaeemKhan333 opened 2 years ago

NaeemKhan333 commented 2 years ago

@TokyoYoshida Thanks for the nice app. I want to understand the conversion process of the yolov3 model into coreml format. Can you have any notebook or python script which helps in conversion and testing the app? Thank you

NaeemKhan333 commented 2 years ago

Thanks for the nice repository. I have used the following link for conversion

https://qiita.com/TokyoYoshida/items/68a5f77e72e48fa870e6

There are some steps that are missing or ambiguous in the given links.

https://qiita.com/TokyoYoshida/items/68a5f77e72e48fa870e6 ( Step 6 and 7 are confusing)

from coremltools.models.neural_network import datatypes

builder.add_reshape_static(name='Reshape1', input_name='grid1', output_name='output1', output_shape=(255,13,13))
builder.add_reshape_static(name='Reshape2', input_name='grid2', output_name='output2', output_shape=(255,26,26))
builder.add_reshape_static(name='Reshape3', input_name='grid3', output_name='output3', output_shape=(255,52,52))
builder.spec.description.output[0].name = "output1"
builder.spec.description.output[0].type.multiArrayType.shape[0] = 255
builder.spec.description.output[0].type.multiArrayType.shape.append(13)
builder.spec.description.output[0].type.multiArrayType.shape.append(13)

builder.spec.description.output[1].name = "output2"
builder.spec.description.output[1].type.multiArrayType.shape[0] = 255
builder.spec.description.output[1].type.multiArrayType.shape.append(26)
builder.spec.description.output[1].type.multiArrayType.shape.append(26)

builder.spec.description.output[2].name = "output3"
builder.spec.description.output[2].type.multiArrayType.shape[0] = 255
builder.spec.description.output[2].type.multiArrayType.shape.append(52)
builder.spec.description.output[2].type.multiArrayType.shape.append(52)
builder.spec.description.output[0].name = "output1"
builder.spec.description.output[0].type.multiArrayType.shape[0] = 255
builder.spec.description.output[0].type.multiArrayType.shape.append(13)
builder.spec.description.output[0].type.multiArrayType.shape.append(13)

builder.spec.description.output[1].name = "output2"
builder.spec.description.output[1].type.multiArrayType.shape[0] = 255
builder.spec.description.output[1].type.multiArrayType.shape.append(26)
builder.spec.description.output[1].type.multiArrayType.shape.append(26)

builder.spec.description.output[2].name = "output3"
builder.spec.description.output[2].type.multiArrayType.shape[0] = 255
builder.spec.description.output[2].type.multiArrayType.shape.append(52)
builder.spec.description.output[2].type.multiArrayType.shape.append(52)

Can you guide me

Can you guide me about it? Thanks