Icône du site Apprenez Delphi

Delphi AI: Ultimate Guide

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!

What Exactly Is Artificial Intelligence?

Artificial intelligence has been a hot topic in the software development industry for some time now. But what exactly is artificial intelligence? In its simplest form, artificial intelligence is the ability of a computer to perform tasks that normally require human intelligence, such as understanding natural language and recognizing objects. However, artificial intelligence can also be used to create more sophisticated applications that can learn and adapt as they are used. As artificial intelligence technology continues to evolve, it is likely that we will see even more amazing applications of this powerful tool in the future.

What Is A Neural Network?

Neural networks are a type of artificial intelligence that are modeled after the brain. Neural networks are composed of neurons, which are connected to each other. The connections between neurons can be weighted, so that some connections are stronger than others. Neural networks learn by adjusting the weights of the connections between neurons. Neural networks are often used in pattern recognition, such as image recognition or facial recognition. Neural networks can also be used for regression, which is when the output of a neural network is a continuous value, such as a real number. Neural networks are sometimes called artificial neural networks or parallel distributed processing systems.

Neural Network: CAI Neural API

What is the CAI Neural API?

Neural network with advanced hardware instructions and OpenCL support. It includes convolutional layers, fully connected layers, locally connected layers, min / max / avg pools, min / max / avg layers, trainable and non-trainable normalization layers, concatenation / summation / reshaping layers, and more. It also features multi-path architecture support. The project features examples demonstrating CIFAR-10 classification for images, DenseNetBC L40, Separable Convolutions, Identity Shortcut Connection, Gradient Ascent, Artificial Art, Super Resolution, an Autoencoder, and more.

Image Classification Example:

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);

Find out more about the CAI neural API for Delphi.

Neural Network: Keras 4 Delphi

What is Keras?

Keras is a high-level neural networks API, written in Python and capable of running on top of TensorFlow, CNTK, or Theano. It was developed with a focus on enabling fast experimentation. Being able to go from idea to result with the least possible delay is key to doing good research. Keras has the following key features: allows the same code to run seamlessly across CPU and GPU devices, supports both convolution based networks and recurrent networks (as well as their combinations),runs seamlessly on CPU and GPU devices. Keras is compatible with Python 3.5-3.7 and is distributed under the MIT license. Keras was created by Google engineer François Chollet.

Keras4Delphi is a neural network API that allows for highly productive prototyping and it supports convolutional networks and recurrent networks. It runs on both the CPU and GPU. It can run on top of TensorFlow, CNTK, or Theano.

Example:

//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');

Find out more about the Keras for Delphi.

How Can Artificial Intelligence (AI) Be Used?

Artificial intelligence in software development is the process of creating intelligent computer programs. This can be done through a variety of methods, including artificial neural networks, genetic algorithms, and artificial life. The aim of artificial intelligence in software development is to create programs that can solve problems and perform tasks that would otherwise be difficult or impossible for humans to do. This often involves creating programs that can learn and adapt to new situations. Artificial intelligence has been used in a variety of applications, including games, finance, medicine, and manufacturing. While artificial intelligence has great potential, it also poses a number of challenges, such as the potential for unethical behavior and the need for carefully controlled artificial environments.

What Is Machine Learning?

Machine learning is a type of artificial intelligence that allows computers to learn from data, without being explicitly programmed. Machine learning is a subset of AI that emphasizes the ability of machines to improve automatically through experience. Machine learning algorithms have been used in a variety of fields, including medical diagnosis, stock trading, robot control, and natural language processing. In software development, machine learning can be used for a variety of tasks, including code completion, bug detection, and software recommendation. Machine learning algorithms are constantly improving, and as they become more sophisticated, they will continue to change the way we interact with computers and the world around us.

Machine Learning And Deep Learning With Tensorflow + Delphi via Python4Delphi

What is Tensorflow?

TensorFlow is an open-source software library for high-performance numerical computation. Its flexible architecture allows easy deployment of computation across a variety of platforms (CPUs, GPUs, TPUs), and from desktops to clusters of servers to mobile and edge devices.

Originally developed by researchers and engineers from the Google Brain team within Google’s AI organization, it comes with strong support for machine learning and deep learning and the flexible numerical computation core is used across many other scientific domains.

Example Delphi Code:

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.

Example Python Code:

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])

Find out more about Tensorflow with Delphi.

Machine Learning: Tensorflow Lite with Delphi

What is TensorFlow Lite?

TensorFlow Lite is a set of tools to help developers run TensorFlow models on mobile, embedded, and IoT devices. It enables on-device machine learning inference with low latency and a small binary size. TensorFlow Lite supports a subset of the operations in the full TensorFlow API. This makes it possible to deploy machine learning models on devices with very limited computational resources. For example, TensorFlow Lite can run on a Raspberry Pi with just 1GB of RAM. In addition, TensorFlow Lite supports a number of hardware accelerators, which can further improve performance. Overall, TensorFlow Lite provides a powerful and efficient way to run machine learning models on resource-constrained devices.

TensorFlow Lite for Delphi is a library containing a set of tools that enables machine learning on a wide variety of devices including Windows 11/10/8/7. There are three demos built in Delphi that demonstrate the usage of the TensorFlow Lite library. These demos include a digit classifier, face detection, and object detection.

Example:

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;

Find out more about TensorFlow Lite with Delphi.

What Is Deep Learning?

Deep learning is a branch of machine learning that deals with algorithms inspired by the structure and function of the brain called artificial neural networks. Neural networks are used to recognize patterns, cluster and classify data, and make predictions based on data. Deep learning is a neural network with multiple layers that can learn increasingly abstract representations of data. The first layer of a deep learning network learns low-level features such as edges, while the last layer learns high-level features such as shapes or objects. Many deep learning networks are trained by feeding them large amounts of data and allowing them to learn from the data themselves. This is different from traditional Machine Learning algorithms, which require human input to learn from data. Deep learning is often used for image recognition, speech recognition, and natural language processing tasks.

Deep Learning: PyTorch with Delphi

What is PyTorch?

PyTorch is a Python-based open-source scientific computing package for deep learning that accelerate the pace of machine learning and artificial intelligence research. Pytorch provide two high-level features:

  • Tensor computation (like NumPy) with strong acceleration via GPUs
  • Build, train and deploy deep neural networks on a tape-based autograd system.

A number of pieces of deep learning software are built on top of PyTorch, including Tesla Autopilot, Uber’s Pyro, HuggingFace’s Transformers, PyTorch Lightning, and Catalyst. You can reuse your favorite Python packages such as NumPy, SciPy, and Cython to extend PyTorch when needed.

Example Delphi Code:

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.

Example Python Code:

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()

Find out more about PyTorch with Delphi.

How Is Artificially Intelligence Being Used?

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 Library: IntelligenceLab

What is IntelligenceLab?

IntelligenceLab is a commercial AI library from an Embarcadero Technical Partner which can be used for data grouping, SPAM filters, computer vision, speech recognition, and other tasks.

It supports:

  • Neural Networks
  • Self-Organizing Map
  • Naive Bayes
  • K Nearest Neighbor
  • Back Propagation
  • Data Preparation

Example:

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;

Find out more about IntelligenceLab with Delphi.

Machine Learning: 5 Ways To Use ML in your Windows Apps

How do I start using Machine Learning in Windows?

Machine Learning is a branch of artificial intelligence that deals with the design and development of algorithms that can learn from and make predictions on data. Machine Learning algorithms have been used in a variety of applications, such as spam detection, facial recognition, and disease diagnosis. In recent years, there has been an increasing interest in Machine Learning, due to the availability of large data sets and advances in computing power.

Windows is a popular operating system for personal computers, laptops, and servers. There are many Machine Learning software packages available for Windows, such as Orange, WEKA, and Microsoft Azure Machine Learning Studio. In order to start using Machine Learning on Windows, you will need to choose a software package and install it on your computer. Once you have installed the software, you will need to gather data that you want to use for training your Machine Learning algorithm. This data can be in the form of text, images, or videos. Once you have gathered your data, you will need to split it into two sets: a training set and a test set. The training set is used to train your Machine Learning algorithm, while the test set is used to evaluate the performance of your algorithm.

After you have trained your algorithm on the training set, you can then use it to make predictions on the test set. Machine Learning is a powerful tool that can be used to solve a variety of problems. By using Machine Learning on Windows, you can take advantage of this technology without having to purchase expensive cloud solutions.

Python4Delphi (P4D) empowers Python users with Delphi’s award-winning VCL functionalities for Windows, which enable us to build native Windows apps 5x faster. This integration enables us to create a modern GUI with Windows 10 looks and responsive controls for our Python Machine Learning applications.

Read the full blog post about machine learning on Windows with Delphi.

DeepAI API

What is the DeepAI API?

The primary motivation behind designing AI solutions is to study data and predict meaningful insights out of the data. In today’s world, where businesses are producing loads and loads of data, AI serves its best purpose by providing various kinds of predictive outcomes for the companies.

Some sample DeepAI APIs include Colorizer, Image Similarity, Super Resolution, Fast Style Transfer, DenseCap, Toonify, and Content Moderation.

Example:

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;

Read the full blog post about using the DeepAI API with Delphi.

Computer Vision: Microsoft Cognitive Services

What are Microsoft Cognitive Services?

Implements the FaceAPI service from Microsoft. Features detecting up to 10 faces in a photo with face attribute support for gender, age, emotion, hair style, and sun classes. It is also able to identify a person if they have previously been added.

Microsoft’s Azure has a broad collection of services you can access with an easy-to-use API.

Azure is Microsoft’s cloud hosting and computing platform with a catalog of more than 200 different products. It also includes products which allow you to implement Machine Learning services. Those services all have an API which you can access using client access libraries or a REST client. Delphi takes this ease of use one step further by providing a TAzureConnectionInfo to implement some of those services quickly and with a minimal amount of code.

Read the full blog post about computer vision with Microsoft Cognitive Services.

Ready to get started building powerful Delphi AI solutions?

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.

Quitter la version mobile