ImageClassification 2.0.0.1
dotnet add package ImageClassification --version 2.0.0.1
NuGet\Install-Package ImageClassification -Version 2.0.0.1
<PackageReference Include="ImageClassification" Version="2.0.0.1" />
paket add ImageClassification --version 2.0.0.1
#r "nuget: ImageClassification, 2.0.0.1"
// Install ImageClassification as a Cake Addin #addin nuget:?package=ImageClassification&version=2.0.0.1 // Install ImageClassification as a Cake Tool #tool nuget:?package=ImageClassification&version=2.0.0.1
What is this?
This package is a wrapper library of ML.NET to do image classification.
You will need ImageClassification.IO
packeage along with this package.
Usege
Trainer class
Trainer
class is a class to train the Model (which will be two zip files) from your image data.
Image data you have to prepare in advence is a foldered image data like below.
Each folder names will be predicted Label names (Apple/Banana/Orange/...).
- Fruits
- Apple
- apple001.jpg
- apple002.jpg
- ...
- Banana
- Orange
- ...
- Apple
More images you prepare, better result you'll get.
Next, call Trainer.GenerateModel
with dataDir
you prepared.
<pre>
// Define hyper-paramters such as Epoch and BatchSize.
var hp = new HyperParameter
{
Epoch = 200,
BatchSize = 10,
LearningRate = 0.01f,
eTrainerArchitecture = eTrainerArchitectures.ResnetV250,
TestFraction = 0.3f,
ResultsToShow = 20
};
// Train and generate the model.
var results = Trainer.GenerateModel(dataDir, hp);
// Save the results as HTML file.(optional)
results.SaveAsHTML();
</pre>
Classifier class
Classifier
class is a class to get a prediction from the image file you give (=imageToClassify).
Call Classifier.GetSingleImagePrediction
along with the Model you've created at previus section.
<pre> string imageToClassify = @"C:\your\imageToClassify(apple_or_banana_or_orange).png"; var p = Classifier.GetSingleImagePrediction(results.Resultfiles.PipelineZip, results.Resultfiles.ModelZip, imageToClassify); Console.WriteLine($@"Predicted image label is: ""{p.PredictedLabel}"". Score:{p.HighScore}"); </pre>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
-
.NETFramework 4.7.2
- ImageClassification.IO (>= 2.0.0)
- Microsoft.ML (>= 2.0.0)
- Microsoft.ML.ImageAnalytics (>= 2.0.0)
- Microsoft.ML.Vision (>= 2.0.0)
- SciSharp.TensorFlow.Redist (>= 2.10.0)
-
net6.0
- ImageClassification.IO (>= 2.0.0)
- Microsoft.ML (>= 2.0.0)
- Microsoft.ML.ImageAnalytics (>= 2.0.0)
- Microsoft.ML.Vision (>= 2.0.0)
- SciSharp.TensorFlow.Redist (>= 2.10.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
2.0.x comes with ML.NET 2.0.0.0 or later.
Changed .NETCore3.1 to .NET6.0