Jump to content
dummzeuch

Some more fun with ChatGPT and Delphi

Recommended Posts

3 minutes ago, Sherlock said:

It would probably use "old norse".

As I have no clue about AI, I asked some -maybe- silly questions.

Still not convinced by the answers.

Quote

-Are you still trained?


As a language model created by OpenAI, I was trained on a large corpus of text data and my parameters were fixed after training. I am not being retrained in real-time, but OpenAI periodically releases new versions of its models that are trained on more recent data or that incorporate new features and improvements. If you are using a version of my model that is more than a year old, there is a chance that I have been updated since then with new training data and other improvements. If you would like to use the most up-to-date version of my model, you may want to check OpenAI's website or contact the company directly for more information.
 

-Learning means saving data to the hard disk.


Learning in the context of artificial intelligence (AI) usually refers to the process of training a model on a dataset, not saving the data to a hard disk. In the case of AI language models like me, the training process involves presenting the model with a large corpus of text data and adjusting the model's parameters so that it can generate text that is similar to the input data. This process can take several days or even weeks to complete, and the resulting model can be quite large, requiring hundreds of gigabytes or even terabytes of storage space. However, the training data itself is typically not saved to disk once the model has been trained. Instead, the model is saved in a compact form that allows it to generate text efficiently at runtime.
 

-How many times was your model deleted?


As a machine learning model created by OpenAI, I have not been deleted since my creation. OpenAI maintains multiple copies of its models to ensure their availability and reliability, so it's unlikely that I would ever be deleted. Additionally, OpenAI takes the security and preservation of its models very seriously, so the likelihood of accidental deletion or loss is low. However, it's always possible for any software system to experience technical issues or other problems that could result in the loss of data, so it's important to have adequate backup and recovery procedures in place to minimize the risk of data loss.

 

 

-My favorite number is th 6

 

The number 6 is a positive integer that is commonly used and recognized in mathematical and everyday contexts. It has many interesting properties and is a perfect number, meaning that the sum of its divisors (excluding itself) is equal to the number itself. Some people find the number 6 to be aesthetically pleasing, while others have personal or cultural associations with the number that make it special to them. I'm glad to hear that 6 is your favorite number!

 

-What is my favorite number?


You mentioned earlier that your favorite number is 6.
 

 

 

Share this post


Link to post
1 hour ago, Kryvich said:

It `s Magic. Before our eyes, large artificial neural networks are becoming more and more intelligent.

Which only goes to show that the definition of "intelligence" is still very difficult, or at least is used very narrowly in the context of "artificial intelligence".

Share this post


Link to post
7 hours ago, Kryvich said:

It `s Magic. Before our eyes, large artificial neural networks are becoming more and more intelligent.

I think "Artificial Intelligence" is a misnomer, especially when it is applied to complex language models or classification algorithms that use neural networks. The word "intelligence" implies a level of active consideration that simply does not exist. While these systems have their uses and will continue to get better at them, they will never do more, and expecting intelligence out of these systems is not reasonable. People are impressed when Google's AI is able to identify objects and people in their photos, but no matter how long you train those models on pictures, they will never learn to play chess. And a chess model will never take what it is "learning" about chess and make intuitive leaps and apply the general game strategy to unrelated things like humans do. Once again I recommend this book: https://amzn.to/3HPwpFQ

  • Like 1

Share this post


Link to post

So I finally tried it myself, inspired by a fairly new SO question.

Me: Using the Delphi language, explain how to turn a large image into many smaller ones and tile them

Quote

In Delphi, you can split an image into smaller tiles using the TBitmap class. Here's an example of how to do it:


uses
  System.Types, Vcl.Graphics;

procedure SplitImage(const SourceImage: TBitmap; TileSize: TSize; Tiles: TArray<TBitmap>);
var
  i, j: Integer;
  DestRect: TRect;
begin
  SetLength(Tiles, (SourceImage.Width div TileSize.cx) * (SourceImage.Height div TileSize.cy));
  DestRect.Size := TileSize;
  for j := 0 to SourceImage.Height div TileSize.cy - 1 do
  begin
    for i := 0 to SourceImage.Width div TileSize.cx - 1 do
    begin
      DestRect.Left := i * TileSize.cx;
      DestRect.Top := j * TileSize.cy;
      Tiles[i + j * (SourceImage.Width div TileSize.cx)].Canvas.CopyRect(Rect(0, 0, TileSize.cx, TileSize.cy), SourceImage.Canvas, DestRect);
    end;
  end;
end;

This function takes a SourceImage TBitmap, a TileSize TSize that specifies the size of each tile, and an empty Tiles TArray of TBitmap that will be filled with the resulting tiles.

It first sets the length of Tiles to the number of tiles that will be created, then iterates through each row and column of tiles, copying a TileSize rectangle from the SourceImage to each tile in the Tiles array.

My follow up question then crashed the thing:

How can I make sure only the tiles visible on the screen will be painted?

☠️

Then I tried the same question again, hoping a different follow up would not crash...

It came up with a different answer:

Quote

Here's an example code in Delphi to divide a large image into smaller parts and then tile them:


uses
  Graphics;

procedure SplitImage(Source: TBitmap; TileWidth, TileHeight: Integer; Dest: TStrings);
var
  x, y: Integer;
  Tile: TBitmap;
begin
  Tile := TBitmap.Create;
  try
    Tile.Width := TileWidth;
    Tile.Height := TileHeight;

    for y := 0 to Source.Height div TileHeight - 1 do
    begin
      for x := 0 to Source.Width div TileWidth - 1 do
      begin
        Tile.Canvas.CopyRect(Rect(0, 0, TileWidth, TileHeight), Source.Canvas,
          Rect(x * TileWidth, y * TileHeight, (x + 1) * TileWidth, (y + 1) * TileHeight));
        Dest.AddObject(Format('Tile_%d_%d', [x, y]), Tile);
      end;
    end;
  finally
    Tile.Free;
  end;
end;

 

In this code, Source is the input image you want to split, TileWidth and TileHeight are the width and height of each tile, and Dest is a TStrings object that will hold the names and bitmaps of the tiles.

The SplitImage procedure creates a new TBitmap object named Tile and uses the CopyRect method of the canvas to extract a portion of the source image and save it as a tile. The extracted tile is then added to Dest along with a name generated using the Format function.

You can use the resulting Dest object to tile the images however you like.

 

Well that looked easy enough but:

Me: The source should be assumed to be 40000 by 40000 pixels

Quote

t's important to note that creating a TBitmap object with such a large size can result in performance and memory issues, as well as reaching the maximum limit for a bitmap's size. To avoid this, you may want to consider splitting the source image into multiple parts and processing each part separately, for example by using a loop and dividing the source image into smaller pieces each iteration.

Additionally, you may also want to consider using a more efficient image format, such as JPEG or PNG, for the source image instead of a BMP. These formats support lossy or lossless compression, which can help reduce the memory usage and improve the performance of the application.

Thanks for that piece of well known information...why do you think I wanted to split the thing in the first place? So...

Me: Well the splitting part you have done, but assume the source is a 40000 by 40000 PNG

Quote

In that case, you would simply need to load the PNG image into a TBitmap object before passing it to the SplitImage procedure. Here's an example code to do that:


uses
  Graphics, PNGImage;

procedure LoadImage(const FileName: string; Source: TBitmap);
var
  PNG: TPNGImage;
begin
  PNG := TPNGImage.Create;
  try
    PNG.LoadFromFile(FileName);
    Source.Assign(PNG);
  finally
    PNG.Free;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  Source: TBitmap;
  Tiles: TStringList;
begin
  Source := TBitmap.Create;
  try
    LoadImage('large_image.png', Source);

    Tiles := TStringList.Create;
    try
      SplitImage(Source, TileWidth, TileHeight, Tiles);

      // Use Tiles as needed, for example to draw them on

 

Eagle eyed I spot the issue at once (never minding the snippet is unfinished):

Me: that is to large for a TBitmap

Quote

You are correct, a TBitmap object with such a large size would likely result in performance and memory issues. To handle this issue, you could use a more efficient image processing library that is optimized for handling large images, such as the VCL Imaging Library (VCL.Imaging) or the Graphics32 library.

With these libraries, you can read and process the image in a more efficient way, such as by reading the image data in chunks or using a tiling approach, which would allow you to process large images without running into memory or performance issues.

Here's an example code using the VCL.Imaging library to split a large PNG image into smaller tiles:


uses
  System.Classes, Vcl.Imaging.Jpeg, Vcl.Imaging.PNGImage;

procedure LoadImage(const FileName: string; Source: TPngImage);
begin
  Source.LoadFromFile(FileName);
end;

procedure SplitImage(Source: TPngImage; TileWidth, TileHeight: Integer; Dest: TStrings);
var
  x, y: Integer;
  Tile: TPngImage;
begin
  Tile := TPngImage.Create;
  try
    Tile.Width := TileWidth;
    Tile.Height := TileHeight;

    for y := 0 to Source.Height div TileHeight - 1 do
    begin
      for x := 0 to Source.Width div TileWidth - 1 do
      begin
        Tile.Canvas.CopyRect(Rect(0, 0, TileWidth, TileHeight), Source.Canvas,
          Rect(x * TileWidth, y * TileHeight, (x + 1) * TileWidth, (y + 1) * TileHeight));
        Dest.AddObject(Format('Tile_%d_%d', [x, y]), Tile);
      end;
    end;
  finally
    Tile.Free;
  end;
end;

var
  Source: TPngImage;
  Tiles: TStringList;
begin
  Source := TPngImage.Create;
  try
    LoadImage('large_image.png', Source);

    Tiles := TStringList.Create;
    try
      SplitImage(Source, TileWidth, TileHeight, Tiles);

      // Use Tiles as needed, for example to draw them on a form
    finally
      Tiles.Free;
    end;
  finally
    Source.Free;
  end;
end;

In this code, Source is a TPngImage object that holds the large image, TileWidth and TileHeight are the width and height of each tile, and Dest is a TStrings object that will hold the names and PNG images of the tiles.

The SplitImage procedure creates a new TPngImage object named Tile and uses the CopyRect method of the canvas to extract a portion of the source image and save it as a tile. The extracted tile is then added to Dest along with a name generated using the Format function.

OK, that looks nice, with one slight snag in the middle part:

Me: Width and Height are ReadOnly for a TPNGImage.

That got it to thinking quite bit, and it started to write something in the likes of "Yes, you are right, and here is how to get around that". Started to put together some code and crashed again... Oh, well. I guess it is not ready for my stupid questions. 🕵️‍♂️

Share this post


Link to post

I had to try it, @Attila Kovacs


Lars Fosdal: write a poem about clouds in old norse
My bad for imprecise instructions as it wrote a poem about "clouds in old norse" rather than about "clouds" in old norse.

Quote

 

"Clouds of Old Norse Skies"

 

In the land of ice and fire,
Where the gods of Asgard reside,
The clouds dance in the wind and attire,
In a realm where myths collide.

 

With misty breath they soar above,
And paint the skies with shades of grey,
A world of dreams, a land of love,
A place where the ancients pray.

 

The wind whispers secrets from the sea,
As the clouds race across the skies,
A symphony of nature's poetry,
That the gods watch with proud eyes.

 

In the morning sun they glow with gold,
And in the evening turn to red,
A sign of the gods’ tales untold,
That fill the hearts of all the dead.

 

So let us raise our shields and sing,
In honor of these clouds of old,
For they are the guardians of everything,
In the skies of Norse mythology untold.

 


Lars Fosdal: på gammelnorsk
So I asked it to translate it to old norse - and albeit I am not 100% fluent, it is mostly understandable and looks credible.

Quote

 

"Skýjar á Gammelnorsku Himni"

 

Á landi is og eldar,
Har guðir Asgardur búa,
Dansa skýjar í vindinum og klæði,
Á riki þar sem sögur skoppa.

 

Með misty anda þeir fljúga yfir,
Og mála himnin með litum grár,
Veröld drauma, land ástar,
Staður þar sem forn ástropa.

 

Vindur hvísla leyndarmál frá sjónum,
Sem skýjar reika yfir himninum,
Sinfónía náttúrulegri poppunnar,
Sem guðir horfa á með stoltum augum.

 

Á morgnana skína þeir með gulli,
Og á kvöldinum lenda í rautt,
Tákni sögulegra guða ósegja,
Sem fylla hjarta allra dauðra.

 

Þess vegna hljótum við að hefja sverð vor,
Ávirka skýjar á gammelnorsku himninum,
Því þeir eru verndarar alls,
Á himnum norskrar mytologíu ósegju.

 


I fed finally fed that to Google Translate, which identified it as Icelandic - and that language is indeed closely related to Old Norse.

Quote

 

"Clouds in the Old Norse Sky"

 

In the land of ice and fire,
Where the gods of Asgard live,
Clouds and clothes dance in the wind,
On a land where stories bounce.

 

With misty breath they fly over,
And paint the sky with colors of gray,
The world of dreams, the land of love,
A place where ancient astropa.

 

The wind whispers secrets from the sea,
As clouds roam the sky,
A symphony of natural pop,
Which the gods look on with proud eyes.

 

In the morning they shine with gold,
And at night fall into red,
Symbols of the historical gods of the Unspeakable,
Which fill the heart of all the dead.

 

Therefore we must start our swords,
Active clouds in the Old Norse sky,
For they are the protectors of all,
In the sky of Norwegian mythology of the unspeakable.

 

Not perfect, but not half bad either.

It can be a fantastic tool, that can create even more fantastic bullshit unless you are careful with your parameters and your proof reading.

  • Like 2

Share this post


Link to post
On 2/3/2023 at 10:04 PM, Lars Fosdal said:

write a poem about clouds in old norse

Seems like pretty good lyrics for a new Manowar song 😄

Edited by Fr0sT.Brutal

Share this post


Link to post
On 2/3/2023 at 8:04 PM, Lars Fosdal said:

på gammelnorsk

ROFL....sorry, but in german "gammel" means "rotten". This is just too funny how related and then again not our languages are.:classic_biggrin:

Share this post


Link to post
6 minutes ago, Sherlock said:

and then again not

They indeed are.

 

"Das Wort wurde aus niederdeutsch gammeln → nds „alt werden“ übernommen und lässt sich auf ein germanisches Adjektiv mit der Bedeutung „alt“ zurückführen;"

 

 

Share this post


Link to post
27 minutes ago, Sherlock said:

ROFL....sorry, but in german "gammel" means "rotten". This is just too funny how related and then again not our languages are.:classic_biggrin:

gammel (Nor) = alter (Ger), but the etymologi is proto-german.

Interestingly enough: age (Eng) = alder (Nor), which descends from aldr (old Nor), which again stems from alter (Ger)

Share this post


Link to post

The common link is clear but the evolution of use and meaning is just baffling to me.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×