intel/openvino-plugins-for-obs-studio

How to rebuild the models ?

xurei opened this issue · 4 comments

I can't find any explaination in the doc about rebuilding the models (typically from tflite to OpenVINO optimized models).

Can you provide the procedure to convert an existing model ?

Hi @xurei,

We used this project to convert models from tflite to tensorflow, and then from tensorflow to onnx: https://github.com/PINTO0309/tflite2tensorflow (I would recommend using the docker image)

And then we used OpenVINO's model optimizer tool to convert the .onnx models to OpenVINO.

For example, these are the commands that we used for Face Landmarks with attention:

#convert tflite to tensorflow (.pb):
tflite2tensorflow \
--model_path face_landmark_with_attention.tflite \
--flatc_path flatc \
--schema_path schema/schema.fbs \
--output_pb

#convert tensorflow to onnx:
 tflite2tensorflow \
--model_path face_landmark_with_attention.tflite \
--flatc_path flatc \
--schema_path schema/schema.fbs \
--output_no_quant_float32_tflite \
--output_dynamic_range_quant_tflite \
--output_weight_quant_tflite \
--output_float16_quant_tflite \
--output_integer_quant_tflite \
--output_integer_quant_typ 'uint8' \
--string_formulas_for_normalization 'data / 255.0' \
--output_tfjs \
--output_onnx \
--onnx_opset 11

# finally, convert onnx to IR 
# From the activated openvino_env you previously set up: #
# Use mo to convert from tensorflow to OpenVINO IR -- normalize [0,255] to [0,1]:
mo --framework onnx  --input_model saved_model/model_float32.onnx --data_type FP32 --output_dir ./ov_out/FP32 --model_name face_landmark_with_attention_192x192 --reverse_input_channels --scale 255.0
mo --framework onnx  --input_model saved_model/model_float32.onnx --data_type FP16 --output_dir ./ov_out/FP16 --model_name face_landmark_with_attention_192x192 --reverse_input_channels --scale 255.0


I should also note that all of this was done before OpenVINO supported tflite models directly, which it now does. You shouldn't actually need to convert .tflite models anymore... instead, you can pass then directly to OpenVINO's load_model API.

(But there may be some value in pre-converting them 'offline')

I'll close this as completed for now, feel free to re-open if you have more questions. Thanks!

Sorry to bother you again...
I did find the face_landmark_with_attention model on https://github.com/PINTO0309/PINTO_model_zoo but couldn't find face_detection models. Any idea where I can find them ?

In any case, thanks for your help so far !