Dies ist eine Implementierung von Microsofts Open Neural Network Exchange (OnnxRuntime) für Freepascal? und Delphi ⚔️
OnnxRuntime -Bibliotheken werden nach Windows 8 mit den meisten modernen Windows -Releases versandt. Zum Zeitpunkt, in dem dies geschrieben wurde, ist Version 1.13.1 die neueste Version, die auf MacOS und den meisten Linux -Releases installiert werden kann.
onnxruntime.dll ist bereits mit Fenstern versendet. Sie können es in %WINDIR%SysWOW64onnxruntime.dll oder %WINDIR%System32onnxruntime.dll finden.
Überprüfen Sie https://github.com/microsoft/onnxruntime/releases
Aus Ihrem Lazarus- oder Delphi -Projekt am Kopf der Pascal -Einheit enthalten die Dateien
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> und Ihren Eingängen mit TORTNameValueList vor 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: schnellerer RCNN10 -Beispielordner
Laden Sie FasterRCNN-10.onnx von hier herunter
GPU: YOLO V7 (DIRECTML) Ordner
Laden Sie yolov7_640x640.onnx von hier herunter und extrahieren Sie sie