アプライアンスコメント Learn Delphi

Delphi AI: 完全ガイド

Stable Diffusion Client

Generative art with AI on the desktop. · Open Source Sample · 50+ custom Stale Diffusion models · Image to image and Upscaling · Cloud Based GPUs Or On-Prem GPU · Windows, macOS, Linux Built In Delphi Download Source Code

CodeDroid AI

Generate code and Delphi forms with AI. · Open Source Sample · GPT-4, Vicuna-13, and other LLMs · Custom prompt template system · Cloud Based GPUs Or On-Prem GPU · Windows, macOS, Linux Built In Delphi Download Source Code

SDXL Inpainting

Generative AI art inpainting client for SDXL · Open Source Sample · Create masks and inpaint with AI · Painting history and negative prompts · Cloud Based GPUs Or On-Prem GPU · Windows, macOS, Linux Built In Delphi Download Source Code

AI Vision Chat

Discuss images with AI · Open Source Sample · LLaVA-7b model · See how it works with API X-Ray · Cloud Based GPUs Or On-Prem GPU · Windows, macOS, Linux Built In Delphi Download Source Code


Delphi In The Age of AI

Artificial intelligence (AI) is one of the most fascinating and rapidly-growing areas of computer science. Although still in its early stages, AI has already started to revolutionize the world we live in, with applications in everything from self-driving cars to medical diagnosis. In this guide, we’ll take a look at what AI is, how it works, how you can use it from Delphi, before exploring some of the exciting possibilities it offers for the future. So read on to learn more about Delphi and this amazing technology – you might be surprised by just how much it can do!

人工知能とは何なのか

近年、人工知能は、ソフトウェア開発業界ではホットな話題です。では、人工知能とはいったい何を指すのでしょう?その最も単純な形態では、人工知能とは、自然言語の理解や物体の認識といった、通常、人間の知能を必要とするタスクを遂行するコンピュータの能力をいいます。また、人工知能を利用し、使用を通じて学習し適応できる精巧なアプリケーションを作成することもできます。人工知能技術が進化し続けるにつれ、将来、このパワフルなツールからさらに驚くべきアプリケーションが誕生する可能性があります。

ニューラルネットワークとは

ニューラルネットワークは、人間の脳の働きを模した人工知能の一種です。ニューラルネットワークは、互いに結合したニューロンで構成されています。ニューロン間の結合に重みを付けて、⼀部の結合を他の結合よりも強力にすることができます。ニューラルネットワークは、ニューロン間の結合強度を調整することにより学習します。ニューラルネットワークは、画像認識や顔認識などのパターン認識によく用いられます。ニューラルネットワークは回帰にも使⽤でき、これは、ニューラルネットワークの出⼒が実数などの連続値である場合です。ニューラルネットワークは、⼈⼯ニューラルネットワークまたは並列分散処理システムと呼ばれることもあります。

ニューラルネットワーク:CAIニューラルAPI

CAIニューラルAPIとは

⾼度なハードウェア動作命令と OpenCL サポートを備えたニューラルネットワークをいいます。畳み込み層、全結合層、局所結合型層、min/max/avgプール、min/max/avgレイヤ、trainable/non-trainable正規化層、concatenation / summation / reshapingレイヤなどが含まれます。また、マルチパス アーキテクチャ サポート機能も備えています。GitHub プロジェクトの機能として、CIFAR-10 画像分類、DenseNetBC L40、分離可能な畳み込み、Shortcut ConnectionのIdentify関数、勾配上昇、AIアート、超解像、オートエンコーダなどが紹介されています。

画像分類の例:

NN := TNNet.Create();
NN.AddLayer([
  TNNetInput.Create(32, 32, 3), //32x32x3 Input Image
  TNNetConvolutionReLU.Create({Features=}16, {FeatureSize=}5, {Padding=}0, {Stride=}1, {SuppressBias=}0),
  TNNetMaxPool.Create({Size=}2),
  TNNetConvolutionReLU.Create({Features=}32, {FeatureSize=}5, {Padding=}0, {Stride=}1, {SuppressBias=}0),
  TNNetMaxPool.Create({Size=}2),
  TNNetConvolutionReLU.Create({Features=}32, {FeatureSize=}5, {Padding=}0, {Stride=}1, {SuppressBias=}0),
  TNNetFullConnectReLU.Create({Neurons=}32),
  TNNetFullConnectLinear.Create(NumClasses),
  TNNetSoftMax.Create()
]);

CreateCifar10Volumes(ImgTrainingVolumes, ImgValidationVolumes, ImgTestVolumes);

WriteLn('Neural Network will minimize error with:');
WriteLn(' Layers: ', NN.CountLayers());
WriteLn(' Neurons:', NN.CountNeurons());
WriteLn(' Weights:', NN.CountWeights());

NeuralFit := TNeuralImageFit.Create;
NeuralFit.InitialLearningRate := fLearningRate;
NeuralFit.Inertia := fInertia;
NeuralFit.Fit(NN, ImgTrainingVolumes, ImgValidationVolumes, ImgTestVolumes, NumClasses, {batchsize}128, {epochs}100);

Delphi向けCAIニューラルAPIの詳細はこちら

ニューラルネットワーク:Keras 4 Delphi

Kerasとは

Keras は、Python で記述された⾼レベルニューラルネットワーク API で、TensorFlow、CNTK、または Theano 上で実行可能です。迅速な実験を可能にすることに重点を置いて開発されました。発想から結果までの過程における遅延を最⼩限に抑えることが、優れた研究を⾏うための鍵となります。Keras の主要機能は、同一コードをCPU / GPUデバイス全域でシームレスに実⾏、畳み込みベースのネットワークと再帰型ネットワークの両⽅ (およびそれらの組み合わせ) をサポート、CPU及びGPU デバイス上でシームレスに実⾏することを可能にします。 Keras は Python 3.5-3.7 と互換性があり、MIT ライセンスの下で配布されています。Keras は、Google のエンジニアである François Chollet によって作成されました。

Keras4Delphi は、⽣産性の⾼いプロトタイピングを可能にするニューラルネットワーク API であり、畳み込みネットワークと再帰型ネットワークをサポートします。CPU と GPU の両⽅で動作します。TensorFlow、CNTK、または Theano上で実⾏可能です。

例:

//Load train data
var x : TNDarray := TNumPy.npArray<Double>( [ [ 0, 0 ], [ 0, 1 ], [ 1, 0 ], [ 1, 1 ] ] );
var y : TNDarray := TNumPy.npArray<Double>( [ 0, 1, 1, 0 ] );

//Build functional model
var input  : TKInput := TKInput.Create(tnp_shape.Create([2]));
var hidden1: TBaseLayer  := TDense.Create(32, 'relu').&Set([input]);
var hidden2: TBaseLayer  := TDense.Create(64, 'relu').&Set([hidden1]);
var output : TBaseLayer  := TDense.Create(1,  'sigmoid').&Set([hidden2]);

var model : TModel := TModel.Create ( [ input ] , [ output ]);

//Compile and train
model.Compile(TStringOrInstance.Create( TAdam.Create ), 'binary_crossentropy',['accuracy']);

var batch_size : Integer := 2;
var history: THistory := model.Fit(x, y, @batch_size, 10,1);

model.Summary;

var logs := history.HistoryLogs;

//Save model and weights
var json : string := model.ToJson;
TFile.WriteAllText('model.json', json);
model.SaveWeight('model.h5');

//Load model and weight
var loaded_model : TBaseModel := TSequential.ModelFromJson(TFile.ReadAllText('model.json'));
loaded_model.LoadWeight('model.h5');

Keras for Delphiの詳細はこちら

人工知能(AI)の活用

ソフトウェア開発における⼈⼯知能は、知的なコンピュータプログラムを作成するプロセスです。これは、⼈⼯ニューラルネットワーク、遺伝的アルゴリズム、⼈⼯⽣命など、さまざまな⽅法で⾏うことができます。ソフトウェア開発における⼈⼯知能の⽬的は、問題を解決し、他の⽅法では⼈間によって実⾏困難または不可能なタスクを遂行できるプログラムの作成です。これには多くの場合、新しい状況を学習して、適応できるプログラムの作成が必要となります。⼈⼯知能は、ゲーム、⾦融、医療、製造など、さまざまな⽤途で使⽤されています。⼈⼯知能には⼤きな可能性がある一方で、倫理的行動リスクや慎重に制御された⼈⼯環境の必要性など、多くの課題も提起します。

機械学習とは

機械学習とは、明⽰的にプログラムされていなくてもコンピュータがデータから学習することを可能にする⼈⼯知能の⼀種です。機械学習は、機械が経験を通じて⾃動的に改善する能⼒を強調したAI のサブセットです。機械学習アルゴリズムは、医療診断、株式取引、ロボット制御、⾃然⾔語処理など、さまざまな分野で利用されています。ソフトウェア開発では、コード補完、バグ検出、ソフトウェア レコメンデーションなど、さまざまなタスクに機械学習を活用できます。機械学習アルゴリズムは継続的に向上しており、洗練度が高くなるにつれて、人とコンピュータや周囲の世界との関わり方に変化をもたらし続けるでしょう。

Python4Delphiを介したTensorflow+Delphiによる機械学習とディープラーニング

Tensorflowとは

TensorFlow は、⾼性能数値計算⽤のオープンソース ソフトウェア ライブラリです。その柔軟なアーキテクチャにより、さまざまなプラットフォーム(CPU、GPU、TPU)にわたって、また、デスクトップから複数のサーバークラスタ、モバイル及びエッジ デバイスまで、計算処理を容易に実装できます。

もともと Google の AI 組織内の Google Brain チームの研究者とエンジニアによって開発されたもので、機械学習とディープラーニングを強⼒にサポートし、柔軟な数値計算コアは他の多くの科学分野で利用されています。

Delphiコード例:

unit Unit1;



interface

uses
  Classes, SysUtils,
  Windows, Messages, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ComCtrls, ExtCtrls,
  PythonEngine, Vcl.PythonGUIInputOutput;

type
  TForm1 = class(TForm)
    PythonEngine1: TPythonEngine;
    Memo1: TMemo;
    Panel1: TPanel;
    Button1: TButton;
    Splitter1: TSplitter;
    Button2: TButton;
    Button3: TButton;
    OpenDialog1: TOpenDialog;
    SaveDialog1: TSaveDialog;
    PythonGUIInputOutput1: TPythonGUIInputOutput;
    Memo2: TMemo;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Déclarations privées }
  public
    { Déclarations publiques }
  end;


var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  PythonEngine1.ExecStrings( Memo1.Lines );
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  with OpenDialog1 do
    begin
      if Execute then
        Memo1.Lines.LoadFromFile( FileName );
    end;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  with SaveDialog1 do
    begin
      if Execute then
        Memo1.Lines.SaveToFile( FileName );
    end;
end;

end.

Pythonコード例:

import tensorflow as tf

# Load and prepare the dataset
mnist = tf.keras.datasets.mnist

(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0

# Build the tf.keras.Sequential model by stacking layers.
# Choose an optimizer and loss function for training:
model = tf.keras.models.Sequential([
  tf.keras.layers.Flatten(input_shape=(28, 28)),
  tf.keras.layers.Dense(128, activation='relu'),
  tf.keras.layers.Dropout(0.2),
  tf.keras.layers.Dense(10)
])

predictions = model(x_train[:1]).numpy()
predictions

# Convert the logits to probabilities for each class
tf.nn.softmax(predictions).numpy()

loss_fn = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True)

loss_fn(y_train[:1], predictions).numpy()

# Compile the deep learning model
model.compile(optimizer='adam',
              loss=loss_fn,
              metrics=['accuracy'])

# Fitting, adjust the model parameters to minimize the loss:
model.fit(x_train, y_train, epochs=5)

# Evaluate the model
model.evaluate(x_test,  y_test, verbose=2)

# Attach the softmax layer
probability_model = tf.keras.Sequential([
  model,
  tf.keras.layers.Softmax()
])

probability_model(x_test[:5])

Delphiを用いたTensorflowの詳細

機械学習:DelphiによるTensorflow Liteの使用

TensorFlow Liteとは

TensorFlow Lite は、開発者がモバイル、組み込み、そしてIoTまでの各端末でTensorFlow モデルを実行する際に役⽴つツールセットです。低レイテンシーかつ小型バイナリで、オンデバイスでの機械学習推論を可能にします。TensorFlow Lite は、完全な TensorFlow API の演算のサブセットをサポートしています。これにより、計算リソースが非常に限られているデバイスでも機械学習モデルを実装できます。例えば、TensorFlow Lite は、搭載RAMが僅か1GBのRAM Raspberry Pi でも実⾏できます。さらに、TensorFlow Liteは多くのハードウェア アクセラレータをサポートするため、パフォーマンスの一層の向上が可能です。全体として、TensorFlow Liteは、リソースに制約のあるデバイスで機械学習モデルを実⾏する強⼒で効率的な⽅法を提供します。

TensorFlow Lite for Delphi は、Windows 11/10/8/7を含む多種多様なデバイスで機械学習を可能にするツールセットを備えたライブラリです。TensorFlow Lite ライブラリの活用事例として、Delphi でビルドした3つのデモを紹介します。デモには、数字分類器、顔検出、物体検出が含まれています。

例:

var
  i, X, Y: DWORD;

  fLibrary: HMODULE;
  fModel: Pointer;
  fInterpreterOptions: Pointer;
  fInterpreter: Pointer;
  fStatus: TfLiteStatus;
  fInputTensorCount, fOutputTensorCount, fNumDims: Int32;
  fInputTensor, fOutputTensor: Pointer;
  fInputDims: Integer;
  fTensorName: PAnsiChar;
  fTensorType: TfLiteType;
  fTensorByteSize: SIZE_T;

  fInput: array [0 .. 28 * 28 - 1] of Float32;
  fOutput: array [0 .. 10 - 1] of Float32;

  fValue: Extended;
begin
  fLibrary := LoadLibrary(LibraryName);

  if fLibrary = 0 then
  begin
    ShowMessage('Error: Load tensorflow lite library ' + LibraryName + ' - ' +
      SysErrorMessage(GetLastError));
    Exit;
  end;

  try
    fModel := TfLiteModelCreateFromFile(PAnsiChar(AnsiString(Edit1.Text)));

    if fModel = nil then
    begin
      ShowMessage('Error: Create model from file - ' +
        SysErrorMessage(GetLastError));
      Exit;
    end;

    fInterpreterOptions := TfLiteInterpreterOptionsCreate;

    if fInterpreterOptions <> nil then
    begin
      TfLiteInterpreterOptionsSetNumThreads(fInterpreterOptions, 2);

      fInterpreter := TfLiteInterpreterCreate(fModel, fInterpreterOptions);

      TfLiteInterpreterOptionsDelete(fInterpreterOptions);
      TfLiteModelDelete(fModel);

      if fInterpreter <> nil then
      begin
        fStatus := TfLiteInterpreterAllocateTensors(fInterpreter);

        fInputTensorCount := TfLiteInterpreterGetInputTensorCount(fInterpreter);
        fOutputTensorCount := TfLiteInterpreterGetOutputTensorCount
          (fInterpreter);

        fInputTensor := TfLiteInterpreterGetInputTensor(fInterpreter, 0);
        fOutputTensor := TfLiteInterpreterGetOutputTensor(fInterpreter, 0);

        if fInputTensor <> nil then
        begin
          fTensorByteSize := TfLiteTensorByteSize(fInputTensor);

          for Y := 0 to Image1.Picture.Bitmap.Height - 1 do
          begin
            for X := 0 to Image1.Picture.Bitmap.Width - 1 do
            begin
              if (Image1.Canvas.Pixels[X, Y] > 0) then
                fInput[X + (Y * Image1.Picture.Bitmap.Width)] := 1
              else
                fInput[X + (Y * Image1.Picture.Bitmap.Width)] := 0;
            end;
          end;

          fStatus := TfLiteTensorCopyFromBuffer(fInputTensor, @fInput,
            fTensorByteSize);

          fStatus := TfLiteInterpreterInvoke(fInterpreter);

          if fStatus = kTfLiteOk then
          begin
            for i := 0 to High(fOutput) do
              fOutput[i] := 0;

            fOutputTensor := TfLiteInterpreterGetOutputTensor(fInterpreter, 0);

            fTensorByteSize := TfLiteTensorByteSize(fOutputTensor);

            if fOutputTensor <> nil then
            begin
              fStatus := TfLiteTensorCopyToBuffer(fOutputTensor, @fOutput,
                fTensorByteSize);

              if fStatus = kTfLiteOk then
              begin
                ListView1.Items.Clear;

                for i := 0 to Length(fOutput) - 1 do
                begin
                  fValue := StrToFloat(Copy(FloatToStr(fOutput[i]), 1, 17));

                  if fValue <= 1 then
                  begin
                    with ListView1.Items.Add do
                    begin
                      Caption := FloatToStrF(fValue, ffNumber, 17, 17);
                      SubItems.Add(IntToStr(i));
                    end;
                  end;
                end;

                ListView1.AlphaSort;

                Beep;
              end;
            end;
          end;
        end;
      end;
    end;
  finally
    FreeLibrary(fLibrary);
  end;

DelphiによるTensorFlow Lite使用の詳細

ディープラーニングとは

ディープラーニング(深層学習)は、⼈⼯ニューラルネットワークと呼ばれる、脳の構造と機能に着想を得たアルゴリズムを扱う機械学習の⼀分野です。ニューラルネットワークは、パターンの認識、データのクラスタリングと分類、データに基づく予測に用いられます。深層学習は、徐々に抽象度が上がるデータ表現を学習できる、複数の階層を持つニューラルネットワークです。深層学習ネットワークの最初の層は、エッジなどの低レベルの特徴を学習し、最後の層は、形状やオブジェクトなどの⾼レベルの特徴を学習します。多くの深層学習ネットワークは、⼤量のデータを取り込み、データ⾃体から学習できるようにすることでトレーニングされます。これは、データから学習するために⼈間による⼊⼒を必要とする従来の機械学習アルゴリズムとは異なります。多くの場合、ディープラーニングは、画像認識、⾳声認識、自然言語処理タスクに利用されています。

ディープラーニング:DelphiによるPyTorchの使用

PyTorchとは

PyTorch は、ディープラーニング⽤のPython向けのオープンソース科学計算パッケージで、機械学習及び⼈⼯知能研究を推進します。Pytorch は 2つの⾼レベル機能を提供します。

  • GPU を介した強⼒なアクセラレーションによるTensor計算 (NumPy など)
  • テープ・ベースの autograd システム上でのディープニューラルネットワークの構築、トレーニング及び実装

Tesla Autopilot、Uber の Pyro、HuggingFace の Transformers、PyTorch Lightning、Catalystなど、数々のディープラーニングソフトウェアがPyTorch 上に構築されています。必要に応じて、NumPy、SciPy、Cython など、好みのPythonパッケージを再利⽤して、PyTorch を拡張できます。

Delphiコード例:

unit Unit1;



interface

uses
  Classes, SysUtils,
  Windows, Messages, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ComCtrls, ExtCtrls,
  PythonEngine, Vcl.PythonGUIInputOutput;

type
  TForm1 = class(TForm)
    PythonEngine1: TPythonEngine;
    Memo1: TMemo;
    Panel1: TPanel;
    Button1: TButton;
    Splitter1: TSplitter;
    Button2: TButton;
    Button3: TButton;
    OpenDialog1: TOpenDialog;
    SaveDialog1: TSaveDialog;
    PythonGUIInputOutput1: TPythonGUIInputOutput;
    Memo2: TMemo;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Déclarations privées }
  public
    { Déclarations publiques }
  end;


var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  PythonEngine1.ExecStrings( Memo1.Lines );
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  with OpenDialog1 do
    begin
      if Execute then
        Memo1.Lines.LoadFromFile( FileName );
    end;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  with SaveDialog1 do
    begin
      if Execute then
        Memo1.Lines.SaveToFile( FileName );
    end;
end;

end.

Pythonコード例:

import torch
from torch.utils.data import Dataset
from torchvision import datasets
from torchvision.transforms import ToTensor, Lambda
import matplotlib.pyplot as plt


training_data = datasets.FashionMNIST(
    root="data",
    train=True,
    download=True,
    transform=ToTensor()
)

test_data = datasets.FashionMNIST(
    root="data",
    train=False,
    download=True,
    transform=ToTensor()
)

labels_map = {
    0: "T-Shirt",
    1: "Trouser",
    2: "Pullover",
    3: "Dress",
    4: "Coat",
    5: "Sandal",
    6: "Shirt",
    7: "Sneaker",
    8: "Bag",
    9: "Ankle Boot",
}
figure = plt.figure(figsize=(8, 8))
cols, rows = 3, 3
for i in range(1, cols * rows + 1):
    sample_idx = torch.randint(len(training_data), size=(1,)).item()
    img, label = training_data[sample_idx]
    figure.add_subplot(rows, cols, i)
    plt.title(labels_map[label])
    plt.axis("off")
    plt.imshow(img.squeeze(), cmap="gray")
plt.show()

DelphiによるPyTorch使用の詳細

人工知能の実用化

Many people think of artificial intelligence (AI) only in terms of movies and television shows in which computers become sentient beings. However, artificial intelligence is already being used extensively in the field of software development. AI can be used to create software that can learn and adapt to new situations, as well as to automate repetitive tasks. In many cases, AI-powered software is able to outperform its human counterparts. For example, Google’s AlphaGo artificial intelligence system beat a professional Go player in a five-game match in 2016. As artificial intelligence continue to evolve, it is likely that even more amazing feats will be achieved in the field of software development.

Delphi AIライブラリ:IntelligenceLab

IntelligenceLabとは

IntelligenceLab は、データのグループ化、スパム フィルタ、コンピュータ視覚及び音声認識、その他のタスクに利用できる、エンバカデロのテクノロジーパートナーが提供する商⽤ AI ライブラリです。

サポート対象:

  • ニューラルネットワーク
  • ⾃⼰組織化マップ
  • 単純ベイズ
  • K近傍法
  • 誤差逆伝播法
  • データプレパレーション(データ準備)

例:

var
  ATrainingData : ISLRealMatrixBuffer;
  AResposes     : ISLRealMatrixBuffer;
  ATestData     : ISLRealBuffer;
  I             : Integer;
  J             : Integer;
  pt            : TPoint;

begin
  ATrainingData  := TSLRealMatrixBuffer.CreateSize( 100, 2 );
  AResposes  := TSLRealMatrixBuffer.CreateSize( 100, 1 );

  Image1.Picture.Bitmap.Width := 500;
  Image1.Picture.Bitmap.Height := 500;
  
  for I := 0 to 50 - 1 do
    begin       
    AResposes[ I, 0 ] := 1;
    ATrainingData[ I, 0 ] := 10 + Random( 230 );
    ATrainingData[ I, 1 ] := 10 + Random( 230 );
    end;

  for I := 50 to 100 - 1 do
    begin
    AResposes[ I, 0 ] := 2;
    ATrainingData[ I, 0 ] := 260 + Random( 230 );
    ATrainingData[ I, 1 ] := 260 + Random( 230 );
    end;
    
  ILNeuralNetworkBackpropTrain1.Train( ATrainingData, AResposes );
  
  ATestData := TSLRealBuffer.CreateSize( 2 );
  for I := 0 to 500 - 1 do
    for J := 0 to 500 - 1 do
      begin
      ATestData[ 1 ] := I;
      ATestData[ 0 ] := J;
      ILNeuralNetwork1.Predict( ATestData );
      end;

  // display the original training samples
  for i := 0 to 100 div 2 - 1 do
    begin
    pt.x := Round( ATrainingData[ I, 0 ]);
    pt.y := Round( ATrainingData[ I, 1 ]);

    Image1.Picture.Bitmap.Canvas.Pen.Color := clBlue;
    Image1.Picture.Bitmap.Canvas.Brush.Color := clBlue;
    Image1.Picture.Bitmap.Canvas.Ellipse( pt.x - 2, pt.y - 2, pt.x + 2, pt.y + 2 );

    pt.x := Round( ATrainingData[ I + 50, 0 ]);
    pt.y := Round( ATrainingData[ I + 50, 1 ]);

    Image1.Picture.Bitmap.Canvas.Pen.Color := clLime;
    Image1.Picture.Bitmap.Canvas.Brush.Color := clLime;
    Image1.Picture.Bitmap.Canvas.Ellipse( pt.x - 2, pt.y - 2, pt.x + 2, pt.y + 2 );
    end;

DelphiによるIntelligenceLab使用の詳細

機械学習: Windows アプリで機械学習を使⽤する 5つの⽅法

Windowsで機械学習機能を使い始めるには

機械学習は、データから学習して、データに対する予測を⾏うことができるアルゴリズムの設計と開発を扱う、⼈⼯知能の⼀部⾨です。機械学習アルゴリズムは、スパム検出、顔認識、病気の診断など、さまざまなアプリケーションで使⽤されています。近年、⼤規模なデータセットの利⽤が可能となり、計算能⼒の進化により、機械学習への関⼼が⾼まっています。

Windows は、パーソナルコンピュータ、ラップトップ及びサーバー用の人気のあるオペレーティングシステムです。Orange、WEKA、Microsoft Azure Machine Learning Studio など、Windows で利⽤できる機械学習ソフトウェアパッケージが多数あります。Windowsで機械学習機能を使い始めるには、ソフトウェアパッケージを選び、コンピュータにインストールする必要があります。ソフトウェアをインストール後、機械学習アルゴリズムのトレーニングに使⽤するデータを収集する必要があります。データ形式は、テキスト、画像、または動画が可能です。データを収集後、データセットをトレーニング用とテスト用に分割する必要があります。トレーニングセットは機械学習アルゴリズムのトレーニングに使われ、テストセットはアルゴリズムのパフォーマンス評価に使われます。

トレーニングセットでアルゴリズムのトレーニングを終了後、そのアルゴリズムを使ってテストセットで予測を⾏うことができます。機械学習は、多種多様な問題を解決するために使⽤できる強⼒なツールです。Windowsで機械学習機能を使用することにより、⾼価なクラウドソリューションを購⼊する必要なく、この技術を活用できます。

Python4Delphi(P4D)は、受賞歴のある DelphiのWindows向け機能であるVCLをPythonユーザーに提供し、ネイティブWindowsアプリの構築を5倍の生産性で実現します。この統合により、Python 機械学習アプリケーション⽤に、Windows 10 の外観とレスポンシブ コントロールを備えたモダンなGUI を作成できます。

Delphi を使⽤した Windows での機械学習に関するブログ記事全文

DeepAI API

DeepAI APIとは

AI ソリューションを設計する主な動機は、データを研究し、データから有意義なインサイトを予測することです。企業が⼤量のデータを⽣成し、読み込む今⽇の世界では、AIは、企業にさまざまな種類の予測結果を提供することで、その最たる目的を果たします。

DeepAI API のサンプルには、Colorizer、Image Similarity、Super Resolution、Fast Style Transfer、DenseCap、 Toonify、Content Moderation などが含まれています。

例:

var
  MS: TMemoryStream;
  IMG: TJPEGImage;
  IdHTTP1 : TIdHTTP;
begin
  MS := TMemoryStream.Create;
  IdHTTP1 := TIdHTTP.Create(nil);
  try
    IMG := TJPEGImage.Create;
    try
        MS.Clear;
        urls := StringReplace(urls, 'https', 'http', [rfReplaceAll, rfIgnoreCase]);
        IdHTTP1.Get(urls, MS);
        MS.Position := 0;
        MS.SaveToFile(resourcesDirectory + '\output.jpg');
        IMG.LoadFromStream(MS);
        ImgResult.Picture.Assign(IMG);
        Application.ProcessMessages;

    finally
      IMG.Free;
    end;
  finally
    MS.Free;
  end;

DelphiによるDeeperAI API使用に関するブログ記事全文

コンピュータビジョン:Microsoft Cognitive Services

Microsoft Cognitive Servicesとは

MicrosoftのFaceAPI サービスを実装。性別、年齢、感情、髪型及び光のあたりかたから顔属性を検出、1枚の写真で最⼤10⼈の顔を判別する機能です。また、以前に追加された⼈物であれば、その⼈物を特定することもできます。

MicrosoftのAzure は、使いやすい API を介してアクセスできる広範なサービスを取り揃えています。

Azure は、200 を超えるさまざまな製品のカタログを備えた Microsoft のクラウド ホスティング/コンピューティングプラットフォームです。また、機械学習サービスを実装できる製品も含まれています。これらのサービスにはすべて、クライアントアクセスライブラリまたは RESTクライアントを介してアクセスできるAPIが用意されています。 Delphi は、これらの任意のサービスを最⼩のコード量で迅速に実装できる TAzureConnectionInfo を提供し、この使いやすさをさらに⼀歩前進させています。

Microsoft Cognitive Servicesを使⽤したコンピュータビジョンに関するブログ記事全文

強力なDelphi AIサポートを用いてAIソリューション構築にチャレンジ

If you’re looking for a platform to build artificial intelligence applications and services, Delphi is worth considering. With its comprehensive suite of tools and libraries, as well as its growing community of developers, Delphi makes it easy to get started with AI. Ready to get started incorporating AI into your projects today? Contact us to learn more about how we can help you make the most of this powerful technology.

モバイルバージョンを終了