ไม่สามารถระบุวิธีแปลง Detectron2* และรุ่น Layout-LM* เป็น OpenVINO™ Intermediate Representation (IR) และอนุมานด้วยปลั๊กอิน CPU
หากต้องการแปลงโมเดล Detectron2 ให้ทําตามบทช่วยสอน Colab เพื่อฝึกฝนและการอนุมานโมเดล Detectron2* ด้วย PyTorch* และทําตามขั้นตอนที่ระบุไว้ด้านล่างเพื่อแปลงโมเดลเป็นรูปแบบ ONNX* แล้วจึงแปลงเป็นรูปแบบ IR
$ python export_model.py --config-file ./output.yaml --sample-image ./new.jpg --output ./model/ --export-export-method tracing --format onnx MODEL รุ่น WEIGHTS./output/model_final.pth CPU ของอุปกรณ์
print (cfg.dump())
ด้วย open("output.yaml", "w") เป็น f:
f.write (cfg.dump())
$ pip ติดตั้ง openvino-dev
$ mo --input_model./model/model.onnx
ด้วยรุ่น ONNX*:
$ benchmark_app -m model.onnx -d CPU -niter 100 -api async -hint ปริมาณงาน
$ benchmark_app -m model.onnx -d CPU -niter 100 -api async -hint ความหน่วงแฝง
กับรุ่น IR:
$ benchmark_app -m model.xml -d CPU -niter 100 -api async -hint ทรูพุต
$ benchmark_app -m model.xml -d CPU -niter 100 -api async -hint ความหน่วงแฝง
ในการแปลงรุ่น Layout-LM ทําตามขั้นตอน ที่อธิบายไว้ด้านล่างเพื่อแปลงโมเดล Layout-LM และการอนุมานด้วย OpenVINO™
$pip ติดตั้ง Transformers[onnx]
$ python3 -m transformers.onnx --model=microsoft/layoutlm-base-uncased onnx
$ pip ติดตั้ง openvino-dev
$ mo --input_model ./onnx/model.onnx
ด้วยรุ่น ONNX*:
$ benchmark_app -m onnx/model.onnx -d CPU -niter 100 -api async -hint ทรูพุต -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]
กับรุ่น IR:
$ 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]
หมาย เหตุ |
รูปร่างอินพุต (กําหนดโดย -data_shape ในคําสั่งด้านบน) อาจแตกต่างกันไปตามรูปแบบการใช้งาน |