Es konnte nicht ermittelt werden, wie Detectron2*- und Layout-LM*-Modelle in OpenVINO™ Intermediate Representation (IR) und Inferencierung mit CPU-Plugin konvertiert werden.
Zur Konvertierung des Detectron2-Modells folgen Sie dem Colab-Tutorial , um das Detectron2*-Modell mit PyTorch* zu trainieren und zu inferenzen, und befolgen Sie auch die unten beschriebenen Schritte, um das Modell in das ONNX*-Format und dann in das IR-Format zu konvertieren.
$ python export_model.py --config-file ./output.yaml --sample-image ./new.jpg --output ./model/ --export-method tracing --format onnx MODEL. GEWICHTE ./output/model_final.pth-MODELL. GERÄT, CPU
print(cfg.dump())
mit open("output.yaml", "w") als f:
f.write(cfg.dump())
$ pip install openvino-dev
$ mo --input_model ./model/model.onnx
Mit ONNX* Modell:
$ benchmark_app -m model.onnx -d CPU -niter 100 -api async -hint Durchsatz
$ benchmark_app -m model.onnx -d CPU -niter 100 -api async -hint Latenz
Mit IR-Modell:
$ benchmark_app -m model.xml -d CPU -niter 100 -api async -hint Durchsatz
$ benchmark_app -m model.xml -d CPU -niter 100 -api async -hint Latenz
So konvertieren Sie das Layout-LM-Modell. Führen Sie die unten beschriebenen Schritte aus, um das Layout-LM-Modell und die Inferenz mit OpenVINO™ zu konvertieren.
$pip install transformers[onnx]
$ python3 -m transformers.onnx --model=microsoft/layoutlm-base-uncased onnx
$ pip install openvino-dev
$ mo --input_model ./onnx/model.onnx
Mit ONNX* Modell:
$ benchmark_app -m onnx/model.onnx -d CPU -niter 100 -api async -hint throughput -data_shape input_ids[1,1], bbox[1,1,4], attention_mask[1,1], token_type_ids[1,1]
$ benchmark_app -m onnx/model.onnx -d CPU -niter 100 -api async -hint latency -data_shape input_ids[1,1], bbox[1,1,4], attention_mask[1,1], token_type_ids[1,1]
Mit IR-Modell:
$ benchmark_app -m model.xml -d CPU -niter 100 -api async -hint throughput -data_shape input_ids[1,1], bbox[1,1,4], attention_mask[1,1], token_type_ids[1,1]
$ benchmark_app -m model.xml -d CPU -niter 100 -api async -hint latency -data_shape input_ids[1,1], bbox[1,1,4], attention_mask[1,1], token_type_ids[1,1]
Hinweis |
Eingabeformen (definiert durch -data_shape in den oben genannten Befehlen) können je nach Anwendungsfall unterschiedlich sein. |