hello,

i was wondering if someone can help.

I downloaded UTKFace dataset and trained an Age model using the same.

The output was tensorflow.keras model in h5 format.

I did a an inferencing test and it was working with web camera.

Now I converted the h5 model to onnx format using onnxmltools using onnxmltools.convert_keras(keras_model, target_opset=12)

I then converted the ONNX model to blob file from https://blobconverter.luxonis.com/ website using following paramters;

--data_type=FP16 --mean_values=[127.5,127.5,127.5] --scale_values=[255,255,255] -- input_shape=[-1,200,200,3]

The blob conversion was successful.

I then downloaded gen2-age-gender detection demo and replaced the "age-gender-recognition-retail-0013" model with my blob file.

recognition_nn.setBlobPath(str(Path("model.blob").resolve().absolute()))

when i run the main.py, i get following error;

Creating Color Camera...
OAK-D detected, app will display spatial coordiantes
Creating recognition Neural Network...
Traceback (most recent call last):
File "main.py", line 181, in <module>
device.startPipeline(create_pipeline(stereo))
File "main.py", line 170, in create_pipeline
recognition_nn.setBlobPath(nnPath)
IndexError: invalid map<K, T> key

can anyone help me how to resolve this error.

thanks

  • erik replied to this.

    Hi rexn8r ,
    Could you also provide the model, so we can try it out locally? I have pinged ML team to check this, but they would likely need the model.
    Thanks, Erik

    hi

    thanks for your response.

    Below is the link to download age model in H5 format;

    here's the netron result of the h5 model;

    Below is the link to download age model in onnx format;

    here's the netron result of the onnx model;

    thanks

    Hi @rexn8r ,
    I tried to use your pipeline to export, but I couldn't get it up and running. So then I tried a different method (shown in this notebook) and the exported model blob now works. Since the pipeline expects input to be in NCHW format I used inputs_as_nchw flag in the onnx model export. For future models we recommend using this format from the beginning of training (instead of Tensorflow's default NHWC). Here is the link to exported model blob. If you have any more questions, feel free to ask.
    Note: If you plan to use this model in gen2-age-gender example you have to change some things in the main while loop since your model only predicts age. You can get this value with this line: age = rec.getLayerFp16('age'). Also you need to change resize in script node to (200,200).

    hi @KlemenSkrlj

    thanks for your help. much appreciate.

    I did download the model.blob and modified the gen2-age-gender demo to check the result. The code link is here;

    unfortunately, the result is way off the mark.

    Can you provide any pointer from the above code to improve?

    thanks

    • erik replied to this.

      Hi rexn8r ,
      I'd suggest to first try OpenVINO model and check the accuracy of your model on face frames. If that works as expected, I'd create a pipeline that sends the frame to the OAK, does the inferencing, and sends the results back, to cross-check whether there was any accuracy loss. Could you try that first, please?
      Thanks, Erik