SaeedP
Well-known member
- Joined
- Oct 21, 2020
- Messages
- 113
- Programming Experience
- 3-5
Hello,
This class is a logo builder project app. I have installed Microsoft ml but I still see a red line under Predict. I've tried many AI modes but still couldn't find what package should I install:
thanks,
This class is a logo builder project app. I have installed Microsoft ml but I still see a red line under Predict. I've tried many AI modes but still couldn't find what package should I install:
C#:
using Microsoft.ML;
namespace BlazorWasm_ML.net_Monica_Claude.Services
{
public class LogoGenerator
{
private readonly MLContext mlContext;
private readonly ITransformer model;
//Constructor
public LogoGenerator()
{
mlContext = new MLContext();
// Load CSV training data
var data = mlContext.Data.LoadFromTextFile<LogoModel>("logo_data.csv", hasHeader: true);
// Define and train model
model = mlContext.MulticlassClassification.Trainers.LbfgsMaximumEntropy(
"LogoText", "ImagePath")
.Fit(data);
}
//Method
public LogoPrediction Predict(byte[] imageData)
{
var prediction = model.Predict(mlContext.Data.LoadFromEnumerable(new[] { imageData }));
return new LogoPrediction
{
LogoText = prediction.First().PredictedLabel,
Probability = prediction.First().Score
};
}
}
}
thanks,