mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-25 22:26:24 +00:00
Remove unnecessary encoding step
This commit is contained in:
parent
65b2b87f83
commit
aa1ce726aa
2 changed files with 3 additions and 9 deletions
|
|
@ -22,13 +22,11 @@ namespace Microsoft.ML.OnnxRuntime.FasterRcnnSample
|
|||
string outImageFilePath = args[2];
|
||||
|
||||
// Read image
|
||||
using Image<Rgb24> image = Image.Load<Rgb24>(imageFilePath, out IImageFormat format);
|
||||
using Image<Rgb24> image = Image.Load<Rgb24>(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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<Rgb24> image = Image.Load<Rgb24>(imageFilePath, out IImageFormat format);
|
||||
using Image<Rgb24> image = Image.Load<Rgb24>(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<float> input = new DenseTensor<float>(new[] { 1, 3, 224, 224 });
|
||||
|
|
|
|||
Loading…
Reference in a new issue