¿Esta es una implementación del intercambio de redes neuronal abierta de Microsoft (Onnxruntime) para Freepascal? y Delphi ⚔️
Las bibliotecas de Onnxruntime vienen enviadas con la mayoría de las versiones modernas de Windows después de Windows 8 , hasta el momento en que se escribe esto, la versión 1.13.1 es la versión más reciente, se puede instalar en macOS y la mayoría de las versiones de Linux , para el desarrollo y las actualizaciones, visite la página de Github de Onnxruntime.
onnxruntime.dll ya está enviado con Windows, puede encontrarlo en %WINDIR%SysWOW64onnxruntime.dll o %WINDIR%System32onnxruntime.dll
Consulte https://github.com/microsoft/onnxruntime/releases
Desde su Proyecto Lázaro o Delphi en el encabezado de la Unidad Pascal incluye los archivos
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> y sus 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: carpeta de ejemplo RCNN10 más rápida
Descargar FasterRCNN-10.onnx desde aquí
GPU: carpeta YOLO V7 (DirectML)
Descargue y extraiga yolov7_640x640.onnx desde aquí