You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why do the following models use the same method but have different results? Is it a C # issue?
How can C # achieve code with the same effect as Python?
// See https://aka.ms/new-console-template for more information
using System.Drawing;
using ConsoleApp3;
using Microsoft.ML.OnnxRuntime;
InferenceSession session = new InferenceSession("D:\\yolov5\\yolov5x.onnx");
List<NamedOnnxValue> inputs = new List<NamedOnnxValue>();
var bit=(Bitmap)Bitmap.FromFile("C:\\Users\\47013\\Desktop\\2.jpeg");
inputs.Add(NamedOnnxValue.CreateFromTensor<float>("images",test.PreprocessImage(bit)));
var results = session.Run(inputs);
var output=results.First().AsTensor<float>();
var boxes = new List<float[]>();
for (int i = 0; i < output.Dimensions[1]; i++)
{
var boxData = new float[85];
for (int j = 0; j < 85; j++)
{
boxData[j] = output[0, i, j];
}
boxes.Add(boxData);
}
var asd=test.DrawBoundingBoxes(bit,boxes,0.1f);
asd.Save("test.jpg");
var m=boxes.Max(s => s[4]);
List<float> ll = new List<float>();
foreach (var box in boxes)
{
float confidence = box[4];
ll.Add(confidence);
}
var sasd=ll.Max();
Console.WriteLine();
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Why do the following models use the same method but have different results? Is it a C # issue?
How can C # achieve code with the same effect as Python?
Beta Was this translation helpful? Give feedback.
All reactions