diff --git a/csharp/sample/Microsoft.ML.OnnxRuntime.FasterRcnnSample/Program.cs b/csharp/sample/Microsoft.ML.OnnxRuntime.FasterRcnnSample/Program.cs index 88edca5c77..df5b2bc8d1 100644 --- a/csharp/sample/Microsoft.ML.OnnxRuntime.FasterRcnnSample/Program.cs +++ b/csharp/sample/Microsoft.ML.OnnxRuntime.FasterRcnnSample/Program.cs @@ -22,13 +22,11 @@ namespace Microsoft.ML.OnnxRuntime.FasterRcnnSample string outImageFilePath = args[2]; // Read image - using Image image = Image.Load(imageFilePath, out IImageFormat format); + using Image image = Image.Load(imageFilePath); // Resize image float ratio = 800f / Math.Min(image.Width, image.Height); - using Stream imageStream = new MemoryStream(); image.Mutate(x => x.Resize((int)(ratio * image.Width), (int)(ratio * image.Height))); - image.Save(imageStream, format); // Preprocess image var paddedHeight = (int)(Math.Ceiling(image.Height / 32f) * 32f); @@ -101,7 +99,7 @@ namespace Microsoft.ML.OnnxRuntime.FasterRcnnSample x.DrawText($"{p.Label}, {p.Confidence:0.00}", font, Color.White, new PointF(p.Box.Xmin, p.Box.Ymin)); }); } - image.Save(outputImage, format); + image.SaveAsJpeg(outputImage); } } } \ No newline at end of file diff --git a/csharp/sample/Microsoft.ML.OnnxRuntime.ResNet50v2Sample/Program.cs b/csharp/sample/Microsoft.ML.OnnxRuntime.ResNet50v2Sample/Program.cs index 65afa6186c..7339d1dbbd 100644 --- a/csharp/sample/Microsoft.ML.OnnxRuntime.ResNet50v2Sample/Program.cs +++ b/csharp/sample/Microsoft.ML.OnnxRuntime.ResNet50v2Sample/Program.cs @@ -1,10 +1,8 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using Microsoft.ML.OnnxRuntime.Tensors; using SixLabors.ImageSharp; -using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; @@ -19,10 +17,9 @@ namespace Microsoft.ML.OnnxRuntime.ResNet50v2Sample string imageFilePath = args[1]; // Read image - using Image image = Image.Load(imageFilePath, out IImageFormat format); + using Image image = Image.Load(imageFilePath); // Resize image - using Stream imageStream = new MemoryStream(); image.Mutate(x => { x.Resize(new ResizeOptions @@ -31,7 +28,6 @@ namespace Microsoft.ML.OnnxRuntime.ResNet50v2Sample Mode = ResizeMode.Crop }); }); - image.Save(imageStream, format); // Preprocess image Tensor input = new DenseTensor(new[] { 1, 3, 224, 224 });