diff --git a/src/Redis.OM.Vectorizers.AllMiniLML6V2/Redis.OM.Vectorizers.AllMiniLML6V2.csproj b/src/Redis.OM.Vectorizers.AllMiniLML6V2/Redis.OM.Vectorizers.AllMiniLML6V2.csproj index 568d617e..30badfd0 100644 --- a/src/Redis.OM.Vectorizers.AllMiniLML6V2/Redis.OM.Vectorizers.AllMiniLML6V2.csproj +++ b/src/Redis.OM.Vectorizers.AllMiniLML6V2/Redis.OM.Vectorizers.AllMiniLML6V2.csproj @@ -21,8 +21,9 @@ - - + + + diff --git a/src/Redis.OM.Vectorizers.Resnet18/ImageModelObjects.cs b/src/Redis.OM.Vectorizers.Resnet18/ImageModelObjects.cs index e8fb2cde..5ccf756c 100644 --- a/src/Redis.OM.Vectorizers.Resnet18/ImageModelObjects.cs +++ b/src/Redis.OM.Vectorizers.Resnet18/ImageModelObjects.cs @@ -1,4 +1,3 @@ -using System.Drawing; using Microsoft.ML.Data; using Microsoft.ML.Transforms.Image; @@ -13,5 +12,5 @@ public class ImageInput public class InMemoryImageData { [ImageType(224,224)] - public Bitmap Image; + public MLImage Image; } \ No newline at end of file diff --git a/src/Redis.OM.Vectorizers.Resnet18/ImageVectorizer.cs b/src/Redis.OM.Vectorizers.Resnet18/ImageVectorizer.cs index 374055e6..61781216 100644 --- a/src/Redis.OM.Vectorizers.Resnet18/ImageVectorizer.cs +++ b/src/Redis.OM.Vectorizers.Resnet18/ImageVectorizer.cs @@ -1,4 +1,3 @@ -using System.Drawing; using Microsoft.ML; using Microsoft.ML.Data; using Microsoft.ML.Transforms; @@ -31,9 +30,8 @@ public byte[] Vectorize(string obj) RequestUri = uri, }; var imageStream = Configuration.Instance.Client.Send(request).Content.ReadAsStream(); - var image = Image.FromStream(imageStream); - var bitmap = new Bitmap(image); - var vector = VectorizeBitMaps(new [] { bitmap })[0].SelectMany(BitConverter.GetBytes).ToArray(); + var image = MLImage.CreateFromStream(imageStream); + var vector = VectorizeBitMaps(new [] { image })[0].SelectMany(BitConverter.GetBytes).ToArray(); return vector; } @@ -93,9 +91,9 @@ private static EstimatorChain> Create return pipeline; } - public static float[][] VectorizeBitMaps(IEnumerable bitmaps) + public static float[][] VectorizeBitMaps(IEnumerable mlImages) { - var images = bitmaps.Select(x => new InMemoryImageData { Image = x }); + var images = mlImages.Select(x => new InMemoryImageData { Image = x }); var mlContext = MlContext.Value; var dataView = mlContext.Data.LoadFromEnumerable(images); var transformedData = BitmapPipeline.Value.Fit(dataView).Transform(dataView); diff --git a/src/Redis.OM.Vectorizers.Resnet18/Redis.OM.Vectorizers.Resnet18.csproj b/src/Redis.OM.Vectorizers.Resnet18/Redis.OM.Vectorizers.Resnet18.csproj index fa1a81f9..58d9d1e3 100644 --- a/src/Redis.OM.Vectorizers.Resnet18/Redis.OM.Vectorizers.Resnet18.csproj +++ b/src/Redis.OM.Vectorizers.Resnet18/Redis.OM.Vectorizers.Resnet18.csproj @@ -21,10 +21,10 @@ - - - - + + + +