dotnet / dotnet/machinelearning

Use function to create dynamic Bitmap runtime

Open
#5,610 5 comments 0 reactions 0 assignees View on GitHub
area-Vision needs-author-action
Dominant language
C#
Stars
9.4k
Forks
2k
Avg merge
2d 20h
Merged PRs (30d)
11

Description

I would like to build a Image Classificator with ml.net, the classification should be by auto rotate image.
Idea is have X images rotated right, then create dynamic at runtime Z images for each X rotated ad random value than use rotation as Label.
I need to rotate at runtime cause train set is around 2gb, do on disk for random angles will require around 1Tb and is not possible.

```
IDataView shuffledFullImagesDataset = mlContext.Transforms.Conversion.
MapValueToKey(outputColumnName: "LabelAsKey", inputColumnName: nameof(ImageData.Label), keyOrdinality: ValueToKeyMappingEstimator.KeyOrdinality.ByValue)
.Append(mlContext.Transforms.ExtractPixels(outputColumnName: "ImgInput", inputColumnName: "Image"))

public ImageData(string pathFile, int label)
{
PathFile = pathFile;
Label = label;
}

[ImageType(110, 110)]
public Bitmap Image => BitmapHelper.GetRotatedByteArrayToBitmap(File.ReadAllBytes(PathFile), Label);

public readonly int Label;

public readonly string PathFile;
```
But i have error when try to call Image look like not exist.
I found a python script that use keras to create random Imgs rotared at runtime when elaborate each Batch, then will avoid to allocate so much memory, but i didnt found some behavior on ml.net, look like it wanna allocate all imgs before training.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.