GithubHelp home page GithubHelp logo

yolov7net's Introduction

2024.6.21

1.0.10 released

Fixed the bug where YOLOv10 inference results only contained one prediction. 修正了 yolov10 推理结果只有一个的bug.

2024.6.12

修正了了使用 skiasharp 预测框不准的问题。

移除system.drawing 的支持

主分支已使用 skiasharp.

具体使用方法参考 demo 工程的 Program.cs

最新的性能测试 Performance

work on i13900k + 64Gb Ram + RTX4090

2024.6.9

Usage:

  1. install-package IVilson.AI.Yolov7net
  2. Program.cs
  3. add yolov10 support. Yolov10
// init Yolov8 with onnx (include nms results)file path
using var yolo = new Yolov10("./assets/yolov10n.onnx", true);
// setup labels of onnx model 
yolo.SetupYoloDefaultLabels();   // use custom trained model should use your labels like: yolo.SetupLabels(string[] labels)
using var image = SKBitmap.Decode("Assets/" + fileName);
var predictions = yolo.Predict(image);  // now you can use numsharp to parse output data like this : var ret = yolo.Predict(image,useNumpy:true);
// draw box
using var canvas = new SKCanvas(image);
var paintRect = new SKPaint
{
    Style = SKPaintStyle.Stroke,
    StrokeWidth = 1,
    IsAntialias = true
};

var paintText = new SKPaint
{
    TextSize = 16,
    IsAntialias = true,
    Typeface = SKTypeface.FromFamilyName("Consolas")
};

foreach (var prediction in predictions) // 迭代预测结果并绘制
{
    double score = Math.Round(prediction.Score, 2);
    paintRect.Color = prediction.Label.Color;
    paintText.Color = prediction.Label.Color;

    // 绘制矩形
    canvas.DrawRect(prediction.Rectangle, paintRect);

    // 绘制文本
    var x = prediction.Rectangle.X - 3;
    var y = prediction.Rectangle.Y - 23;
    canvas.DrawText($"{prediction.Label.Name} ({score})", x, y, paintText);
}

yolov10 和 yolov7 保持兼容,包含了NMS 操作,感觉性能上比不上yolov9

2024.5.3 new branch released.

  1. Considering cross-platform compatibility, such as supporting mobile development, I have removed numpy support in this new branch to reduce the size of the program package.
  2. Remove System.Drawing and replace it with SkiaSharp.

HISTORY

2024.4.7 this project upgrade to net8.0

Repository Update Notice As part of our ongoing efforts to improve our project structure and workflow, we have made the following changes to the branches of this repository:

The master branch has been renamed to net6.0. This change reflects our progression and the versioning aligned with the new features and improvements. The net8.0 branch has been renamed to master. This is now the main branch where the latest stable releases and active developments will happen.

Yolov7net Now support yolov9,yolov8,yolov7,yolov5.

.net 6 yolov5, yolov7, yolov8 onnx runtime interface, work for:

  1. yolov9 https://github.com/WongKinYiu/yolov9
  2. yolov8 https://github.com/ultralytics/ultralytics
  3. yolov7 https://github.com/WongKinYiu/yolov7
  4. yolov5 https://github.com/ultralytics/yolov5

References & Acknowledgements

https://github.com/THU-MIG/yolov10

https://github.com/WongKinYiu/yolov9

https://github.com/ultralytics/ultralytics

https://github.com/WongKinYiu/yolov7

https://github.com/ultralytics/yolov5

https://github.com/mentalstack/yolov5-net

https://github.com/ibaiGorordo/ONNX-YOLOv7-Object-Detection

yolov7net's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

yolov7net's Issues

incorrect prediction bounding boxes

Was fine in the windows only/System.Drawing version.
Added to your test case:

[Fact]
public void TestYolov9()
{
	using var yolo = new Yolov9("./assets/yolov9-c.onnx"); //yolov9 模型,需要 nms 操作

	// setup labels of onnx model 
	yolo.SetupYoloDefaultLabels();   // use custom trained model should use your labels like: yolo.SetupLabels(string[] labels)
	Assert.NotNull(yolo);

	foreach (var tuple in _testImages)
	{
		var ret = yolo.Predict(tuple.image, useNumpy: false);
		CheckResult(ret, tuple.label);

		using SKCanvas canvas = new(tuple.image);
		using var paint = new SKPaint
		{
			Style = SKPaintStyle.Stroke,
			Color = SKColors.Blue,
			StrokeWidth = 3,
		};
		foreach (var prediction in ret)
		{
			canvas.DrawRect(prediction.Rectangle, paint);
		}
		using var data = tuple.image.Encode(SKEncodedImageFormat.Png, 100);
		using var stream = File.OpenWrite($"{tuple.label} result.png");
		data.SaveTo(stream);
	}
}

cat result
dog result

[bug] Yolov8 prediction labels missing

Hey great work adding some initial support for the yolov8 series!

I started messing around with your latest nuget release and noticed that the prediction labels are null unless I specified true for the NumSharp parameter.

But setting param to true does produce a different problem which is that it only ever returns 1 prediction/label (the first one, the same 1st prediction that would show without the NumSharp option)

I can provide more details if it helps, but here's what I'm seeing when I mess around in powershell:

Add-Type -AssemblyName "$DEPS_ROOT\Microsoft.ML.OnnxRuntime.Managed.1.14.0\lib\net6.0\Microsoft.ML.OnnxRuntime.dll"
Add-Type -AssemblyName "$DEPS_ROOT\NumSharp.0.30.0\lib\netstandard2.0\NumSharp.dll"
Add-Type -AssemblyName "$DEPS_ROOT\IVilson.AI.Yolov7net.1.0.3\lib\net6.0\IVilson.AI.Yolov7net.dll"

$y8client = [IVilson.AI.Yolov7net.Yolov8]::new($MODEL_PATH)
$y8client.SetupYoloDefaultLabels()

$img = [System.Drawing.Image]::FromFile($IMG_PATH)

$y8client.Predict($img) 

<# Returns with null Label property ->

Label Rectangle                                                 Score
----- ---------                                                 -----
      {X=726.8968,Y=1456.7361,Width=953.0971,Height=2573.4204}   0.93
      {X=1223.8837,Y=1089.3862,Width=884.0172,Height=2938.6584}  0.91
#>


$y8client.Predict($img, 0, 0, $true)

<# When NumSharp param is true, returns with only first prediction ->

Label               Rectangle                                               Score
-----               ---------                                               -----
Yolov7net.YoloLabel {X=923.1725,Y=1456.7361,Width=714.823,Height=2573.4204}  0.93
#>

I'll try poking around at the new updates in the source code to see when I can figure out but just wanted to see if you might know what's happening here, thanks again!

YOLO-NAS Implementation

It would be great if this library included YOLO-NAS. You already have so many YOLO versions, this is great, and it would be nice to have one C# library with a majority of YOLO implementations all in one place.

YOLOv8 Fault! What happen

Microsoft.ML.OnnxRuntime.OnnxRuntimeException:“[ErrorCode:Fail] Load model from ./Assets/yolov8m.onnx failed:D:\a_work\1\s\engine\lotus\onnxruntime\core/graph/model_load_utils.h:57 onnxruntime::model_load_utils::ValidateOpsetForDomain ONNX Runtime only guarantees support for models stamped with official released onnx opset versions. Opset 17 is under development and support for this is limited. The operator schemas and or other functionality may change before next ONNX release and in this case ONNX Runtime will not guarantee backward compatibility. Current official support for domain ai.onnx is till opset 15.

识别结果Y坐标返回负值

作者可以给个邮箱或者其他联系方式吗, 我这里有张图片通过添加这个库引用识别出来的Y坐标为负值, 给您源码看下

inconsistent results

ive had great results on both yolov7net and ONNX-YOLOv7-Object-Detection using models from here but...

i trained a custom model and if i use it in ONNX-YOLOv7-Object-Detection i get results, however if i use Yolov7net i got no results. Im still very new at training custom models but when im seeing results on one library and not on another it makes me question on whether im doing something wrong or if theres something wrong with yolov7net...

Note:

  1. The same image was put into both programs, but they got resized after becuase i had to screen capture them to post here.
  2. the image from ONNX-YOLOv7-Object-Detection says "person" because I didn't know how to change it (I don't really know python).
  3. also when i mean inconsistent i mean that i dont get any results from yolov7net, (multiple images/videos tested)

results from using ONNX-YOLOv7-Object-Detection:
image

results from using Yolov7net:
image

code from yolov7net:

using System.Drawing;
using Yolov7net;
using OpenCvSharp;
using OpenCvSharp.Extensions;

// init Yolov7 with onnx (include nms results)file path
using var yolo = new Yolov7("C:\\Users\\imnot\\Downloads\\yolov7-main\\yolov7-main\\runs\\train\\yolov7-custom2\\weights\\best.onnx", true);
// setup labels of onnx model 
yolo.SetupYoloDefaultLabels();
using var image = (Bitmap)Image.FromFile("C:\\Users\\imnot\\Desktop\\Test.jpg");
var predictions = yolo.Predict(image, 0.01f, 0.5f);

// draw box
Mat img = BitmapConverter.ToMat(image);

foreach (var prediction in predictions) // iterate predictions to draw results
{
    int x = (int)prediction.Rectangle.X;
    int y = (int)prediction.Rectangle.Y;
    int width = (int)prediction.Rectangle.Width;
    int height = (int)prediction.Rectangle.Height;

    Cv2.Rectangle(img, new OpenCvSharp.Rect(x, y, width, height), new Scalar(0, 255, 0), 3);
    Cv2.Rectangle(img, new OpenCvSharp.Rect(x, y - 42, 90, 40), new Scalar(0, 0, 0), -1);
    Cv2.PutText(img, prediction.Label.Name, new OpenCvSharp.Point(x, y - 10), HersheyFonts.HersheySimplex, 1.5, new Scalar(36, 255, 12), 4);

    Console.WriteLine(prediction.Label.Name);
}

var newImg = BitmapConverter.ToBitmap(img);
newImg.Save("C:\\Users\\imnot\\Desktop\\newimage.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

code from ONNX-YOLOv7-Object-Detection:

import cv2
from imread_from_url import imread_from_url

from yolov7 import YOLOv7

# Initialize yolov7 object detector
model_path = "C:/Users/imnot/Downloads/yolov7-main/yolov7-main/runs/train/yolov7-custom2/weights/best.onnx"
yolov7_detector = YOLOv7(model_path, conf_thres=0.02, iou_thres=0.3)

# Read image
img_url = "https://i.imgur.com/P8MBg2M.jpg"
img = imread_from_url(img_url)

# Detect Objects
boxes, scores, class_ids = yolov7_detector(img)

# Draw detections
combined_img = yolov7_detector.draw_detections(img)
cv2.namedWindow("Detected Objects", cv2.WINDOW_NORMAL)
cv2.imshow("Detected Objects", combined_img)
cv2.imwrite("doc/img/detected_objects.jpg", combined_img)
cv2.waitKey(0)

模型测试出错

用你的模型测试没有问题,但是自己训练模型就会提示超出索引,lable是与训练的lable保持一致的。python调用是可以的,可以请教下需要注意什么问题吗

Multiple GPU

Hi!
Can I use multiple GPUs?
Do I need to do some configuration?

NumSharp remove

Please consider removing the numpy dependency, since now it is not faster and only adds an extra dependency (and size) to this package.

Yolov9

Hi! Can I expect any news regarding Yolov9 soon?

Exception useCuda = true

If i choose useCuda = True

Microsoft.ML.OnnxRuntime 1.11.0:
0688_688_2022_12_10_Vision_v1pMV1d0Af

I thought I needed Microsoft.ML.OnnxRuntime.Gpu
Microsoft.ML.OnnxRuntime.Gpu 1.11.0:
0689_689_2022_12_10_Vision_GtZk2jFSA8

Microsoft.ML.OnnxRuntime.Gpu 1.13.1:
0690_690_2022_12_10_Vision_TlLTUM39Vu

I tried on different devices Windows 10/11
Please, help.

预测的框不对位置大小绘制出来不对

使用的OpencvSharp4绘制的, 代码如下, 是SKBitmap坐标系的问题吗

var yolo = new Yolov8("box.onnx", false);
yolo.SetupLabels(new string[] { "box" });
Mat mat = new Mat(dialog.FileName);//AppDomain.CurrentDomain.BaseDirectory+""
RawImage = WriteableBitmapConverter.ToWriteableBitmap(mat);
var image = mat.ToBytes();
var predictResult = yolo.Predict(SKBitmap.Decode(image));
foreach (var predict in predictResult)
{
    Cv2.Rectangle(mat, new Rect(Convert.ToInt32(predict.Rectangle.MidX - predict.Rectangle.Width/2), Convert.ToInt32(predict.Rectangle.MidY - predict.Rectangle.Height/2), Convert.ToInt32(predict.Rectangle.Width), Convert.ToInt32(predict.Rectangle.Height)), Scalar.Red, 2);
}
AfterImage = WriteableBitmapConverter.ToWriteableBitmap(mat);

YoloX implementation

Hi,

this is a great library.
I need to implement inference for YoloX model but I'm having some trouble.

This is python script that I use:

import os
import cv2
import numpy as np
import onnxruntime
import os
import cv2
import numpy as np
import onnxruntime

# Constants
INPUT_SHAPE = (640, 640)  # Adjust this if needed
NMS_THRESHOLD = 0.45
SCORE_THRESHOLD = 0.4

# Replace COCO_CLASSES with your class names
CLASS_NAMES = []

_COLORS = np.array(
    [
        0.000, 0.447, 0.741,
        0.850, 0.325, 0.098,
        0.929, 0.694, 0.125,
        0.494, 0.184, 0.556,
        0.466, 0.674, 0.188,
        0.301, 0.745, 0.933,
        0.635, 0.078, 0.184,
        0.300, 0.300, 0.300,
        0.600, 0.600, 0.600,
        1.000, 0.000, 0.000,
        1.000, 0.500, 0.000,
        0.749, 0.749, 0.000,
        0.000, 1.000, 0.000,
        0.000, 0.000, 1.000,
        0.667, 0.000, 1.000,
        0.333, 0.333, 0.000,
        0.333, 0.667, 0.000,
        0.333, 1.000, 0.000,
        0.667, 0.333, 0.000,
        0.667, 0.667, 0.000,
        0.667, 1.000, 0.000,
        1.000, 0.333, 0.000,
        1.000, 0.667, 0.000,
        1.000, 1.000, 0.000,
        0.000, 0.333, 0.500,
        0.000, 0.667, 0.500,
        0.000, 1.000, 0.500,
        0.333, 0.000, 0.500,
        0.333, 0.333, 0.500,
        0.333, 0.667, 0.500,
        0.333, 1.000, 0.500,
        0.667, 0.000, 0.500,
        0.667, 0.333, 0.500,
        0.667, 0.667, 0.500,
        0.667, 1.000, 0.500,
        1.000, 0.000, 0.500,
        1.000, 0.333, 0.500,
        1.000, 0.667, 0.500,
        1.000, 1.000, 0.500,
        0.000, 0.333, 1.000,
        0.000, 0.667, 1.000,
        0.000, 1.000, 1.000,
        0.333, 0.000, 1.000,
        0.333, 0.333, 1.000,
        0.333, 0.667, 1.000,
        0.333, 1.000, 1.000,
        0.667, 0.000, 1.000,
        0.667, 0.333, 1.000,
        0.667, 0.667, 1.000,
        0.667, 1.000, 1.000,
        1.000, 0.000, 1.000,
        1.000, 0.333, 1.000,
        1.000, 0.667, 1.000,
        0.333, 0.000, 0.000,
        0.500, 0.000, 0.000,
        0.667, 0.000, 0.000,
        0.833, 0.000, 0.000,
        1.000, 0.000, 0.000,
        0.000, 0.167, 0.000,
        0.000, 0.333, 0.000,
        0.000, 0.500, 0.000,
        0.000, 0.667, 0.000,
        0.000, 0.833, 0.000,
        0.000, 1.000, 0.000,
        0.000, 0.000, 0.167,
        0.000, 0.000, 0.333,
        0.000, 0.000, 0.500,
        0.000, 0.000, 0.667,
        0.000, 0.000, 0.833,
        0.000, 0.000, 1.000,
        0.000, 0.000, 0.000,
        0.143, 0.143, 0.143,
        0.286, 0.286, 0.286,
        0.429, 0.429, 0.429,
        0.571, 0.571, 0.571,
        0.714, 0.714, 0.714,
        0.857, 0.857, 0.857,
        0.000, 0.447, 0.741,
        0.314, 0.717, 0.741,
        0.50, 0.5, 0
    ]
).astype(np.float32).reshape(-1, 3)

def preprocess(img, input_size, swap=(2, 0, 1)):
    if len(img.shape) == 3:
        padded_img = np.ones((input_size[0], input_size[1], 3), dtype=np.uint8) * 114
    else:
        padded_img = np.ones(input_size, dtype=np.uint8) * 114

    r = min(input_size[0] / img.shape[0], input_size[1] / img.shape[1])
    resized_img = cv2.resize(
        img,
        (int(img.shape[1] * r), int(img.shape[0] * r)),
        interpolation=cv2.INTER_LINEAR,
    ).astype(np.uint8)
    padded_img[: int(img.shape[0] * r), : int(img.shape[1] * r)] = resized_img

    padded_img = padded_img.transpose(swap)
    padded_img = np.ascontiguousarray(padded_img, dtype=np.float32)
    return padded_img, r

def demo_postprocess(outputs, img_size, p6=False):
    grids = []
    expanded_strides = []
    strides = [8, 16, 32] if not p6 else [8, 16, 32, 64]

    hsizes = [img_size[0] // stride for stride in strides]
    wsizes = [img_size[1] // stride for stride in strides]

    for hsize, wsize, stride in zip(hsizes, wsizes, strides):
        xv, yv = np.meshgrid(np.arange(wsize), np.arange(hsize))
        grid = np.stack((xv, yv), 2).reshape(1, -1, 2)
        grids.append(grid)
        shape = grid.shape[:2]
        expanded_strides.append(np.full((*shape, 1), stride))

    grids = np.concatenate(grids, 1)
    expanded_strides = np.concatenate(expanded_strides, 1)
    outputs[..., :2] = (outputs[..., :2] + grids) * expanded_strides
    outputs[..., 2:4] = np.exp(outputs[..., 2:4]) * expanded_strides

    return outputs

def nms(boxes, scores, nms_thr):
    x1 = boxes[:, 0]
    y1 = boxes[:, 1]
    x2 = boxes[:, 2]
    y2 = boxes[:, 3]

    areas = (x2 - x1 + 1) * (y2 - y1 + 1)
    order = scores.argsort()[::-1]

    keep = []
    while order.size > 0:
        i = order[0]
        keep.append(i)
        xx1 = np.maximum(x1[i], x1[order[1:]])
        yy1 = np.maximum(y1[i], y1[order[1:]])
        xx2 = np.minimum(x2[i], x2[order[1:]])
        yy2 = np.minimum(y2[i], y2[order[1:]])

        w = np.maximum(0.0, xx2 - xx1 + 1)
        h = np.maximum(0.0, yy2 - yy1 + 1)
        inter = w * h
        ovr = inter / (areas[i] + areas[order[1:]] - inter)

        inds = np.where(ovr <= nms_thr)[0]
        order = order[inds + 1]

    return keep

def multiclass_nms(boxes, scores, nms_thr, score_thr, class_agnostic=True):
    if class_agnostic:
        return multiclass_nms_class_agnostic(boxes, scores, nms_thr, score_thr)
    # else:
    #     return multiclass_nms_class_aware(boxes, scores, nms_thr, score_thr)

def multiclass_nms_class_agnostic(boxes, scores, nms_thr, score_thr):
    cls_inds = scores.argmax(1)
    cls_scores = scores[np.arange(len(cls_inds)), cls_inds]

    valid_score_mask = cls_scores > score_thr
    if valid_score_mask.sum() == 0:
        return None
    valid_scores = cls_scores[valid_score_mask]
    valid_boxes = boxes[valid_score_mask]
    valid_cls_inds = cls_inds[valid_score_mask]
    keep = nms(valid_boxes, valid_scores, nms_thr)
    if keep:
        return np.concatenate(
            [valid_boxes[keep], valid_scores[keep, None], valid_cls_inds[keep, None]], 1
        )
    return None

def vis(img, boxes, scores, cls_ids, conf=0.5, class_names=None):
    for i in range(len(boxes)):
        box = boxes[i]
        cls_id = int(cls_ids[i])
        score = scores[i]
        if score < conf:
            continue
        x0 = int(box[0])
        y0 = int(box[1])
        x1 = int(box[2])
        y1 = int(box[3])

        color = (_COLORS[cls_id] * 255).astype(np.uint8).tolist()
        text = '{}:{:.1f}%'.format(class_names[cls_id], score * 100)
        txt_color = (0, 0, 0) if np.mean(_COLORS[cls_id]) > 0.5 else (255, 255, 255)
        font = cv2.FONT_HERSHEY_SIMPLEX

        txt_size = cv2.getTextSize(text, font, 0.4, 1)[0]
        cv2.rectangle(img, (x0, y0), (x1, y1), color, 2)

        txt_bk_color = (_COLORS[cls_id] * 255 * 0.7).astype(np.uint8).tolist()
        cv2.rectangle(
            img,
            (x0, y0 + 1),
            (x0 + txt_size[0] + 1, y0 + int(1.5 * txt_size[1])),
            txt_bk_color,
            -1
        )
        cv2.putText(img, text, (x0, y0 + txt_size[1]), font, 0.4, txt_color, thickness=1)

    return img

def mkdir(path):
    if not os.path.exists(path):
        os.makedirs(path)

def process_images(input_dir, output_dir, model_path):
    mkdir(output_dir)
    session = onnxruntime.InferenceSession(model_path)

    for img_file in os.listdir(input_dir):
        if img_file.lower().endswith(('.jpg', '.png', '.jpeg')):
            img_path = os.path.join(input_dir, img_file)
            origin_img = cv2.imread(img_path)
            img, ratio = preprocess(origin_img, INPUT_SHAPE)

            ort_inputs = {session.get_inputs()[0].name: img[None, :, :, :]}
            output = session.run(None, ort_inputs)
            predictions = demo_postprocess(output[0], INPUT_SHAPE)[0]

            boxes = predictions[:, :4]
            scores = predictions[:, 4:5] * predictions[:, 5:]

            boxes_xyxy = np.ones_like(boxes)
            boxes_xyxy[:, 0] = boxes[:, 0] - boxes[:, 2] / 2.
            boxes_xyxy[:, 1] = boxes[:, 1] - boxes[:, 3] / 2.
            boxes_xyxy[:, 2] = boxes[:, 0] + boxes[:, 2] / 2.
            boxes_xyxy[:, 3] = boxes[:, 1] + boxes[:, 3] / 2.
            boxes_xyxy /= ratio
            dets = multiclass_nms(boxes_xyxy, scores, nms_thr=NMS_THRESHOLD, score_thr=SCORE_THRESHOLD)
            if dets is not None:
                final_boxes, final_scores, final_cls_inds = dets[:, :4], dets[:, 4], dets[:, 5]
                origin_img = vis(origin_img, final_boxes, final_scores, final_cls_inds,
                                 conf=SCORE_THRESHOLD, class_names=CLASS_NAMES)

            output_path = os.path.join(output_dir, img_file)
            cv2.imwrite(output_path, origin_img)
            print(f"Saved result to {output_path}")

if __name__ == "__main__":
    input_dir = './new-dataset/temp'
    output_dir = './new-dataset/temp/output_folder_latest14'
    model_path = "./model/model_yolox.onnx"

    process_images(input_dir, output_dir, model_path)

I don't know how to convert in C#.

Any help?

CPU vs GPU

Hello, when using useCuda = true the Yolo7 does use the GPU.
However there is no performance gain at all. The result is same as when using CPU.

What could be the reason?

I am using Microsoft.ML.OnnxRuntime.Gpu version 1.6.0
which works with Nvidia Cuda 10.2 and my card GT 710 2GB.

useCuda = false (CPU 40%, GPU 0%)
useCuda = true (CPU 10%, GPU 50%)

Thanks!

help

image
please help me

调用异常

使用自己的模型报错信息: lable与训练的lable是一致的 yolov5 类文件

System.IndexOutOfRangeException
HResult=0x80131508
Message=Index was outside the bounds of the array.
Source=System.Private.CoreLib
StackTrace:
在 System.ThrowHelper.ThrowIndexOutOfRangeException()
在 System.Span1.get_Item(Int32 index) 在 Microsoft.ML.OnnxRuntime.Tensors.DenseTensor1.GetValue(Int32 index)
在 Microsoft.ML.OnnxRuntime.Tensors.Tensor1.get_Item(ReadOnlySpan1 indices)
在 Microsoft.ML.OnnxRuntime.Tensors.Tensor1.get_Item(Int32[] indices) 在 Yolov7net.Yolov5.<>c__DisplayClass9_0.<ParseDetect>b__0(Int32 i) 在 System.Threading.Tasks.Parallel.<>c__DisplayClass19_01.b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)

使用自己的模型报错信息: lable与训练的lable是一致的 yolov7 类文件
System.IndexOutOfRangeException
HResult=0x80131508
Message=Index was outside the bounds of the array.
Source=System.Private.CoreLib
StackTrace:
在 System.ThrowHelper.ThrowIndexOutOfRangeException()
在 System.Span1.get_Item(Int32 index) 在 Microsoft.ML.OnnxRuntime.Tensors.DenseTensor1.GetValue(Int32 index)
在 Microsoft.ML.OnnxRuntime.Tensors.Tensor1.get_Item(ReadOnlySpan1 indices)
在 Microsoft.ML.OnnxRuntime.Tensors.Tensor1.get_Item(Int32[] indices) 在 Yolov7net.Yolov7.<>c__DisplayClass6_0.<ParseDetect>b__0(Int32 i) 在 System.Threading.Tasks.Parallel.<>c__DisplayClass19_01.b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)

Application - (not responding)

Hello! your library works nicely. However I am facing some issues when looping over images. Say 20 or more.

_yolov8 = new Yolov8("./yolov8n.onnx", false);
_yolov8.SetupYoloDefaultLabels();

var imgFiles = info.GetFiles().OrderBy(p => p.CreationTime).ToArray();

foreach (var imgFile in imgFiles)
{
using var inputImage = Image.FromFile(imgFile.FullName);
var items = _yolov8.Predict(inputImage).Where(i => i.Score >= 0.70).ToList();

 // more code goes here....

}

The application is a windows form, .net 6.0. It runs okay when in visual studio debugger.
However when running the same compiled EXE alone, out of the visual studio environment.

The applications gets hung "not responding"

Are you aware of any such issues? or differentiation between visual studio debug mode run / and normal exe run?

Thanks!

Ddl problem

Hello

While running my program I constanty have this error :
Exception thrown: 'System.EntryPointNotFoundException' in Microsoft.ML.OnnxRuntime.dll .
Has anyone encountered this and found a solution?

Greetings

yolov10 only detects 1 class

all works perfect, but the output is always only one "prediction". if there is a bench and a person in an image, it detects only one of them.

Utils.ExtractPixels is very slow

Utils.ExtractPixels is very slow. On my machine it is 300-500ms. Nested Parallel processing is unnecessary, it makes the function only slower. If I remove the Parallel loops, the result is 70ms.. which is still quite a lot. (Tensor indexer is very slow, use the tensor.Buffer)

In your code you already assume that the bitmapData is ARGB, 4 byte per pixel, so using the Stride is unnecerrasy, since (from the documetation):

The stride is the width of a single row of pixels (a scan line), rounded up to a four-byte boundary.

And in this case the width of a single row is always multiple of 4.

I rewrote the function, this is only 3ms and not an "unsafe" code:
int pixelCount = width * height;
var spanR = tensor.Buffer.Span;
var spanG = spanR.Slice(pixelCount);
var spanB = spanG.Slice(pixelCount);

    int sidx = 0;
    int didx = 0;
    for (int i = 0; i < pixelCount; i++)
    {
        spanR[didx] = data[sidx + 2] / 255.0F;
        spanG[didx] = data[sidx + 1] / 255.0F;
        spanB[didx] = data[sidx] / 255.0F;
        didx++;
        sidx += 4;
    }

Maybe you can make it even faster by using unsafe code.

This is just an idea how you could make it faster. If you expect higher models in the future (like 8K * 8K), you can keep the outer parallel loop or make "my" single loop parallel... but a nested parallel loop is overkill.... And for 640x640 pixels the parallel loop is unnecessary.

Load image from Bitmap

using var image = Image.FromFile("Assets/demo.jpg")
可不可不從檔案讀取Image來源,而直接取自某一PictureBox或System.Drawing.Bitmap物件內容?

新的跨平台分支,识别上好像有些问题。

同样的模型,用这个分支识别起来精度特别差,用以前的还有其他yolov8库是没问题的。目前大部分yolo的库用的是ImageSharp,在MAUI Android下面性能特别差。这个项目选择的SkiaSharp没这个问题。但目前精度较差,不知道是不是图片预处理方面还有点问题。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.