Comments (1)
On this sample Yolov7 model is loaded only one time and you keep using the same loaded model instance to handle with your code/inferences.
`
public partial class Form1 : Form
{
Yolov7? yolo = null;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (yolo == null)
{
// init Yolov7 with onnx (include nms results)file path
yolo = new Yolov7("./assets/best.onnx", true);
// setup labels of onnx model
//yolo.SetupYoloDefaultLabels(); // use custom trained model should use your labels like: yolo.SetupLabels(string[] labels)
string[] labels = { "myCustomLabel" };
yolo.SetupLabels(labels);
}
var dirPos = Directory.GetFiles(@"./Assets/val/images/pos");
var dirNeg = Directory.GetFiles(@"./Assets/val/images/neg");
var dtNow = DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
foreach (var item in dirPos)
{
if (Path.GetExtension(item).Equals(".jpg") ||
Path.GetExtension(item).Equals(".png"))
{
using var image = Image.FromFile(item);
var predictions = yolo.Predict(image);
// draw box
using var graphics = Graphics.FromImage(image);
foreach (var prediction in predictions) // iterate predictions to draw results
{
double score = Math.Round(prediction.Score, 2);
graphics.DrawRectangles(new Pen(prediction.Label.Color, 1), new[] { prediction.Rectangle });
var (x, y) = (prediction.Rectangle.X - 3, prediction.Rectangle.Y - 23);
graphics.DrawString($"{prediction.Label.Name} ({score})",
new Font("Consolas", 16, GraphicsUnit.Pixel), new SolidBrush(prediction.Label.Color),
new PointF(x, y));
}
var fileName = Path.GetFileName(item);
var path = Path.GetDirectoryName(item);
image.Save(Path.Combine(path, (fileName + "_" + dtNow + ".png")), ImageFormat.Png);
}
}
}
}
`
from yolov7net.
Related Issues (20)
- Yolov8 by any chanse? HOT 3
- [bug] Yolov8 prediction labels missing HOT 5
- Correct the prediction score
- YOLOv8 Fault! What happen HOT 2
- Utils.ExtractPixels is very slow HOT 6
- NumSharp remove HOT 1
- Multiple GPU HOT 1
- Application - (not responding) HOT 10
- CPU vs GPU HOT 1
- yolov8 自定义的模型,识别出来Label为空是什么原因 HOT 1
- Predict “One or more errors occurred,(Index was outside the bounds of the array)” HOT 2
- 识别结果Y坐标返回负值 HOT 2
- cuda faild HOT 1
- Load image from Bitmap HOT 1
- help HOT 1
- Exception useCuda = true HOT 10
- yolo.Predict 方法错误 System.IndexOutOfRangeException:“Index was outside the bounds of the array.” HOT 1
- inconsistent results HOT 2
- Ddl problem HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yolov7net.