Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Image classification training convert to onnx file format

未关闭
#1,048 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
csharp

调研方向

从 C# 图像分类示例和 ConvertToOnnx 入口点开始,然后使用 issue 中所示的 pipeline 重现异常。确定哪些阶段可以在 ONNX 中表示,并就预期的 best-effort 行为达成一致;对于此示例,支持的转换路径或所请求的功能已定义并得到演示,即表示完成。

由索引模型根据 Issue 内容生成。

描述

I've been doing experiments with the C# image classification examples, and I've been struggling trying to modify the sample to save an ONNX file without success, since it gives me the usual "The targeted pipeline can not be fully converted into a well-defined ONNX model" exception.

So which would be the steps required to be able to save an onnx file?

I am aware some pipeline might contain ML transformers that are not available in ONNX, but maybe the ConvertToOnnx method could have a "best effort" option that would automatically convert what can be converted.

In other words, I would like to save the raw ONNX model that's in between the transformers that cannot be converted to ONNX.

var trainTestSplit = _mlContext.Data.TrainTestSplit(data, testFraction: 0.2);
var trainData = trainTestSplit.TrainSet;
var testData = trainTestSplit.TestSet;

var pipeline = _mlContext.Transforms.Conversion.MapValueToKey(
outputColumnName: "LabelKey",
inputColumnName: "Label")

.Append(_mlContext.Transforms.LoadRawImageBytes(
outputColumnName: "Image",
imageFolder: null,
inputColumnName: "ImagePath"))
.Append(_mlContext.MulticlassClassification.Trainers.ImageClassification(
new ImageClassificationTrainer.Options()
{
LabelColumnName = "LabelKey",
FeatureColumnName = "Image",
Arch = ImageClassificationTrainer.Architecture.InceptionV3,
Epoch = _settings.Epochs,
BatchSize = _settings.BatchSize,
LearningRate = 0.001f,
MetricsCallback = (metrics) => _logger.LogInformation($"Epoch: {metrics.Train?.Epoch}, Top1Accuracy: {metrics.Train?.Accuracy}")
}))
.Append(_mlContext.Transforms.Conversion.MapKeyToValue(
outputColumnName: "PredictedLabel",
inputColumnName: "PredictedLabel"));

主要语言
PowerShell
星标
4.7k
派生
2.7k
平均合并
2 天 22 小时
30 天内合并 PR
1

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

dotnet/machinelearning-samples 的其他 Issue

查看 dotnet/machinelearning-samples 的全部 Issue

相似的 Issue

更多 Machine Learning Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。