Skip to content

Commit e30555c

Browse files
add obj-detection automl sweeper (#6633)
* add wrapper * add more options * disable format check for generated code
1 parent cb2e495 commit e30555c

File tree

7 files changed

+132
-6
lines changed

7 files changed

+132
-6
lines changed

.editorconfig

+4-1
Original file line numberDiff line numberDiff line change
@@ -341,4 +341,7 @@ dotnet_style_readonly_field = false
341341
[test/Microsoft.ML.TestFrameworkCommon/Utility/*.cs]
342342
# IDE0073: Dont want license file header in code we are using from elsewhere
343343
dotnet_diagnostic.IDE0073.severity = none
344-
file_header_template = unset
344+
file_header_template = unset
345+
346+
[**/*.generated.cs]
347+
generated_code = true

src/Microsoft.ML.AutoML/CodeGen/estimator-schema.json

+11-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
"Naive",
7373
"ForecastBySsa",
7474
"TextClassifcation",
75-
"SentenceSimilarity"
75+
"SentenceSimilarity",
76+
"ObjectDetection"
7677
]
7778
},
7879
"nugetDependencies": {
@@ -187,7 +188,15 @@
187188
"confidenceLevel",
188189
"variableHorizon",
189190
"modelFactory",
190-
"sentence1ColumnName"
191+
"sentence1ColumnName",
192+
"boundingBoxColumnName",
193+
"imageColumnName",
194+
"maxEpoch",
195+
"iOUThreshold",
196+
"scoreThreshold",
197+
"steps",
198+
"initLearningRate",
199+
"weightDecay"
191200
]
192201
},
193202
"argumentType": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"$schema": "./search-space-schema.json#",
3+
"name": "object_detection_option",
4+
"search_space": [
5+
{
6+
"name": "LabelColumnName",
7+
"type": "string",
8+
"default": "Label"
9+
},
10+
{
11+
"name": "PredictedLabelColumnName",
12+
"type": "string",
13+
"default": "PredictedLabel"
14+
},
15+
{
16+
"name": "PredictedBoundingBoxColumnName",
17+
"type": "string",
18+
"default": "PredictedBoundingBoxes"
19+
},
20+
{
21+
"name": "BoundingBoxColumnName",
22+
"type": "string",
23+
"default": "BoundingBoxes"
24+
},
25+
{
26+
"name": "ImageColumnName",
27+
"type": "string",
28+
"default": "Image"
29+
},
30+
{
31+
"name": "ScoreColumnName",
32+
"type": "string",
33+
"default": "Score"
34+
},
35+
{
36+
"name": "MaxEpoch",
37+
"type": "integer",
38+
"default": 10
39+
},
40+
{
41+
"name": "InitLearningRate",
42+
"type": "double",
43+
"default": 1.0
44+
},
45+
{
46+
"name": "WeightDecay",
47+
"type": "double",
48+
"default": 0.0
49+
},
50+
{
51+
"name": "IOUThreshold",
52+
"type": "double",
53+
"default": 0.5
54+
},
55+
{
56+
"name": "ScoreThreshold",
57+
"type": "double",
58+
"default": 0.5
59+
}
60+
]
61+
}

src/Microsoft.ML.AutoML/CodeGen/search-space-schema.json

+13-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@
145145
"matrix_factorization_option",
146146
"dnn_featurizer_image_option",
147147
"text_classification_option",
148-
"sentence_similarity_option"
148+
"sentence_similarity_option",
149+
"object_detection_option"
149150
]
150151
},
151152
"option_name": {
@@ -198,7 +199,17 @@
198199
"Epoch",
199200
"Architecture",
200201
"AddKeyValueAnnotationsAsText",
201-
"Arch"
202+
"Arch",
203+
"PredictedLabelColumnName",
204+
"PredictedBoundingBoxColumnName",
205+
"BoundingBoxColumnName",
206+
"ImageColumnName",
207+
"IOUThreshold",
208+
"ScoreThreshold",
209+
"Steps",
210+
"MaxEpoch",
211+
"InitLearningRate",
212+
"WeightDecay"
202213
]
203214
},
204215
"option_type": {

src/Microsoft.ML.AutoML/CodeGen/trainer-estimators.json

+7
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,13 @@
525525
"usingStatements": [ "Microsoft.ML", "Microsoft.ML.Trainers", "Microsoft.ML.TorchSharp" ],
526526
"searchOption": "sentence_similarity_option"
527527
},
528+
{
529+
"functionName": "ObjectDetection",
530+
"estimatorTypes": [ "MultiClassification" ],
531+
"nugetDependencies": [ "Microsoft.ML", "Microsoft.ML.TorchSharp" ],
532+
"usingStatements": [ "Microsoft.ML", "Microsoft.ML.Trainers", "Microsoft.ML.TorchSharp" ],
533+
"searchOption": "object_detection_option"
534+
},
528535
{
529536
"functionName": "ForecastBySsa",
530537
"estimatorTypes": [ "Forecasting" ],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Text;
8+
using Microsoft.ML.TorchSharp;
9+
using Microsoft.ML.TorchSharp.AutoFormerV2;
10+
11+
namespace Microsoft.ML.AutoML.CodeGen
12+
{
13+
internal partial class ObjectDetectionMulti
14+
{
15+
public override IEstimator<ITransformer> BuildFromOption(MLContext context, ObjectDetectionOption param)
16+
{
17+
var option = new ObjectDetectionTrainer.Options
18+
{
19+
LabelColumnName = param.LabelColumnName,
20+
PredictedLabelColumnName = param.PredictedLabelColumnName,
21+
BoundingBoxColumnName = param.BoundingBoxColumnName,
22+
ImageColumnName = param.ImageColumnName,
23+
ScoreColumnName = param.ScoreColumnName,
24+
MaxEpoch = param.MaxEpoch,
25+
InitLearningRate = param.InitLearningRate,
26+
WeightDecay = param.WeightDecay,
27+
PredictedBoundingBoxColumnName = param.PredictedBoundingBoxColumnName,
28+
ScoreThreshold = param.ScoreThreshold,
29+
IOUThreshold = param.IOUThreshold,
30+
};
31+
32+
return context.MulticlassClassification.Trainers.ObjectDetection(option);
33+
}
34+
}
35+
}

tools-local/Microsoft.ML.AutoML.SourceGenerator/SearchSpaceGenerator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public void Execute(GeneratorExecutionContext context)
128128
Properties = options,
129129
}.TransformText();
130130

131-
context.AddSource($"{className}.cs", code);
131+
context.AddSource($"{className}.generated.cs", code);
132132
}
133133
}
134134

0 commit comments

Comments
 (0)