Can I use Python SDK to make model for OpenMV?

Today, I saw that you have released the Python SDK, so I would like to ask if it can be used to train object detection models for OpenMV H7 Plus?

2 Likes

Hi @HaoLeng

Thanks for the interest!

The Python SDK, can be used to generate the C++ Lib, but you will be using the C++ Lib to build your project. Please see the BYOM doc for more info.

Best

Eoin

I saw the ouput of ei.model.list_deployment_targets() in that document has the item openmv, but when I set the target , I got the error output Could not deploy: deploy_target: [openmv] not in[....]
and I wonder how to convert the model to int8_tflite and labels.txt ,please give me some suggestion.

1 Like

I have the same problem. I’m trying to use “openmv-fw” as my deploy_target, but then getting the message: deploy_target: [openmv-fw] not in[…]. But “openmv-fw” does appear when listing the available profile target devices with:

ei.model.list_deployment_targets()

Hello @baarratia @HaoLeng,

There is indeed a bug. Our core engineering team has been notified. We’re working on adding the support.

Best,

Louis

1 Like

Hi, thanks for the reply.
I just checked again, and now “openmv-fw” is not available when listing the deployment targets. Is there any timeline or plans to support it in the Python SDK? I’m really interested in testing it.

Thanks!

Hello @baarratia,

I’m checking internally. We have an internal ticket about this issue but I don’t have any ETA for now.

Best,

Louis

1 Like

Hi! I just tried again and now the “openmv-fw” is back when printing the available profile target devices. But when executing the command ei.model.deploy(…) with deploy_target=‘openmv-fw’, it is still printing the following error message:

Could not deploy: deploy_target: [openmv-fw] not in ['zip', 'arduino', 'cubemx', 'wasm', 'wasm-browser-simd', 'tensorrt', 'ethos', 'synaptics-tensaiflow-lib', 'meta-tf', 'memryx-dfp', 'slcc', 'arduino-nano-33-ble-sense', 'arduino-nicla-vision', 'espressif-esp32', 'raspberry-pi-rp2040', 'silabs-xg24', 'infineon-cy8ckit-062s2', 'infineon-cy8ckit-062-ble', 'nordic-thingy53', 'renesas-ck-ra6m5', 'runner-linux-aarch64', 'runner-linux-armv7', 'runner-linux-x86_64', 'runner-linux-aarch64-akd1000', 'runner-linux-x86_64-akd1000', 'runner-mac-x86_64', 'runner-linux-aarch64-tda4vm', 'particle']

Is there any work around yet with this?

Thanks again :]

Hi @HaoLeng and @baarratia,

Apologies for the long delay. I’m finally getting around to addressing this issue. The problem is that if you don’t specify model_input_type in the .deploy() function, it will default to OtherInput(). Studio sees this and adjusts the pretrained model settings accordingly. From this, Studio will automatically limit your deployment options based on that input type. The openmv option requires ImageInput to be set as the input type, or it won’t appear in the deployment options.

If you call ei.model.list_deployment_targets() before uploading a model, all deploy targets will be listed. If you call it after running either .profile() or .deploy(), only the available ones will be listed.

To fix this, you need to specify the model_input_type as ImageInput() when you call .deploy(). This will allow you to deploy to the openmv target. For example:

# Set model information
model_output_type = ei.model.output_type.ObjectDetection(
    labels=["Class 1, Class 2"],
    last_layer = "fomo",
    minimum_confidence = 0.2,
)

# Set input information
model_input_type = ei.model.input_type.ImageInput(
    scaling_range = "0..1"
)

# Create OpenMV library with trained model
deploy_bytes = None
try:
    deploy_bytes = ei.model.deploy(
        model=model_path,
        model_output_type=model_output_type,
        model_input_type=model_input_type,
        deploy_target="openmv"
    )
except Exception as e:
    print(f"Could not deploy: {e}")

# Write the downloaded raw bytes to a file
if deploy_bytes:
    with open(deploy_filename, 'wb') as f:
        f.write(deploy_bytes.getvalue())

If you try to call .deploy() for the openmv target with anything other than model_input_type=ei.model.input_type.ImageInput(), you will get the Could not deploy: deploy_target: [openmv] not in[....] error. Note that if you do not specify a value for model_input_type, it will default to ei.model.input_type.OtherInput(). See here to learn about the input types.

I have added a note in the Deploy section of the getting started guide to help troubleshoot this issue.

2 Likes