Esta é uma implementação da Open Neural Network Exchange (OnNxRuntime) da Microsoft para FreePasCal? e Delphi ⚔️
As bibliotecas OnNxRuntime são enviadas com a maioria dos lançamentos modernos do Windows após o Windows 8 , a partir do momento em que isso está escrito, a versão 1.13.1 é a versão mais recente, pode ser instalada no MacOS e na maioria dos lançamentos do Linux , para desenvolvimento e atualizações, visite o OnNxRuntime Github Page.
onnxruntime.dll já está enviado com janelas, você pode encontrá -lo em %WINDIR%SysWOW64onnxruntime.dll ou %WINDIR%System32onnxruntime.dll
Verifique https://github.com/microsoft/onnxruntime/releases
Do seu projeto Lázaro ou Delphi no cabeçalho da unidade Pascal inclui os arquivos
unit formUnit;
{ $h+ }
interface
uses onnxruntime_pas_api, onnxruntime, Classes etc... ; var
session : TORTSession;
begin
session := TORTSession.Create( ' ./mymodel/filname.onnx ' );
{
*****************************************************************
Check your model requirements for input/output
names and value dimensions before preparing the inputs.
to explore the model before preparing use :
session.GetInputCount and session.GetOutputCount
session.GetInputName and session.GetOutputName
session.GetInputTypeInfo and session.GetOutputTypeInfo
****************************************************************
} TORTTensor<type> e suas entradas usando TORTNameValueList var
x,y:integer;
imageData : array of array of single;
inTensor : TORTTensor<single> ;
inputs : TORTNameValueList ;
begin
// assuming the model input name is 'image' and the tensor shape is [width, height]
inTensor := TORTTensor<single>.Create([width, height { , depth ,etc... } ]);
for y:= 0 to inTensor.shape[ 1 ]- 1 do
for x:= 0 to inTensor.shape[ 0 ]- 1 do
inTensor.index2[x, y]:= imageData[x, y]; // your float values
inputs[ ' image ' ] := inTensor; var
myDetection : array of single;
i:integer;
outputs : TORTNameValueList;
outTensor : TORTTensor<single>
begin
outputs := session.run(inputs);
outTensor := outputs[ ' result ' ]
for i:= 0 to outTensor.shape[ 0 ] do
myDetection[i] := outTensor.index1[i]CPU: pasta de exemplo mais rápida rcnn10
Baixe FasterRCNN-10.onnx aqui
GPU: pasta YOLO V7 (DirectML)
Baixar e extrair yolov7_640x640.onnx daqui