ML.NET-API(一)_常用代码片段
1.详细Anaconda+Pycharm配置YoloV5环境笔记2.Pytorch学习笔记-(二)搭建Pytorch环境(Pytorch2.1+CUDA12.1+Anaconda3_2023+Pycharm2023)3.yolov5-OSError: [WinError 1455] 页面文件太小,无法完成操作。 Error loading "C:\Anaconda3\lib\site-packages\torch\lib\caffe2_detectron_ops_gpu.dll"4.YoloV5_RuntimeError: CUDA out of memory. Tried to allocate 100.00 MiB (GPU 0; 2.00 GiB total capacity; 1.15 GiB already allocated; 0 bytes free; 1.19 GiB reserved in total by PyTorch)5.C#调用YoloV5与YoloV8示例6.C#实现控制台传参调用YoloV5模型进行人体识别
7.ML.NET-API(一)_常用代码片段
8.ML.NET-模型生成器工具(二)-对象检测教程1、训练图像
//Append ImageClassification trainer to your pipeline containing any preprocessing transforms
pipeline
.Append(mlContext.MulticlassClassification.Trainers.ImageClassification(featureColumnName: "Image")
.Append(mlContext.Transforms.Conversion.MapKeyToValue("PredictedLabel");
// 训练模型
var model = pipeline.Fit(trainingData);
// 预测
var predictedData = model.Transform(newData).GetColumn<string>("PredictedLabel");
2、训练文本
// Define training pipeline using TextClassification trainer
var pipeline =
mlContext.Transforms.Conversion.MapValueToKey("Label","Sentiment")
.Append(mlContext.MulticlassClassification.Trainers.TextClassification(sentence1ColumnName: "Text"))
.Append(mlContext.Transforms.Conversion.MapKeyToValue("PredictedLabel"));
// 训练模型
var model = pipeline.Fit(trainingData);
// 预测
var predictedData = model.Transform(newData).GetColumn<string>("PredictedLabel");
3、句子相似性
// Define your pipeline
var pipeline = mlContext.Regression.Trainers.SentenceSimilarity(sentence1ColumnName: "Sentence", sentence2ColumnName: "Sentence2");
// 训练模型
var model = pipeline.Fit(trainingData);
// 预测
var score = model.Transform(newData).GetColumn<float>("Score");
4、使用预先训练的TensorFlow模型
// Load TensorFlow model
TensorFlowModel tensorFlowModel = mlContext.Model.LoadTensorFlowModel(_modelPath);
//Append ScoreTensorFlowModel transform to your pipeline containing any preprocessing transforms
pipeline.Append(tensorFlowModel.ScoreTensorFlowModel(outputColumnName: "Prediction/Softmax", inputColumnName:"Features"))
// 训练
ITransformer model = pipeline.Fit(dataView);
// 预测方式一
var predictions = pipeline.Fit(data).GetColumn<float[]>(TinyYoloModelSettings.ModelOutput);
// 预测方式二:
var predictions = model.Transform(dataView).GetColumn<float>("Prediction/Softmax");
5、使用预先训练的ONNX模型
// Append ApplyOnnxModel transform to pipeline containing any preprocessing transforms
pipeline.Append((modelFile: modelLocation, outputColumnNames: new[] { TinyYoloModelSettings.ModelOutput }, inputColumnNames: new[] { TinyYoloModelSettings.ModelInput })
// 训练
var model = pipeline.Fit(data);
// 预测方式一
var predictions = pipeline.Fit(data).GetColumn<float[]>(TinyYoloModelSettings.ModelOutput);
// 预测方式二:
IDataView scoredData = model.Transform(imageDataView);
6、使用‘模型生成器工具’的代码进行预测
MLModel1.Predict(sampleData); // 预测
MLModel1.PredictAllLabels(sampleData); // 预测标签
本文来自博客园,作者:꧁执笔小白꧂,转载请注明原文链接:https://www.cnblogs.com/qq2806933146xiaobai/p/18297590
合集:
机器视觉-Yolo
分类:
C#+深度学习ML.NET
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
2019-07-12 网摘-按键精灵屏幕找色原理分析