Это реализация Microsoft Open Neural Network Exchange (onnxruntime) для Freepascal? и Дельфи ⚔
Библиотеки Onnxruntime поставляются с большинством современных выпусков Windows после Windows 8 , на момент написания времени версия 1.13.1 является самым последним выпуском, его можно установить на MacOS и большинство выпусков Linux , для разработки и обновлений, пожалуйста, посетите страницу Github OnnxRuntime.
onnxruntime.dll уже поставляется с окнами, вы можете найти его в %WINDIR%SysWOW64onnxruntime.dll или %WINDIR%System32onnxruntime.dll
Проверьте https://github.com/microsoft/onnxruntime/releases
Из вашего проекта Lazarus или Delphi в заголовке блока Pascal включает файлы
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> и ваши входы, используя 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]ЦП: более быстрая папка примеров RCNN10
Скачать FasterRCNN-10.onnx
GPU: yolo v7 (directml) папка
Скачать и извлечь yolov7_640x640.onnx отсюда