Skip to content

Commit

Permalink
add obj-detection automl sweeper (#6633)
Browse files Browse the repository at this point in the history
* add wrapper

* add more options

* disable format check for generated code
  • Loading branch information
LittleLittleCloud committed Apr 28, 2023
1 parent cb2e495 commit e30555c
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,7 @@ dotnet_style_readonly_field = false
[test/Microsoft.ML.TestFrameworkCommon/Utility/*.cs]
# IDE0073: Dont want license file header in code we are using from elsewhere
dotnet_diagnostic.IDE0073.severity = none
file_header_template = unset
file_header_template = unset

[**/*.generated.cs]
generated_code = true
13 changes: 11 additions & 2 deletions src/Microsoft.ML.AutoML/CodeGen/estimator-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
"Naive",
"ForecastBySsa",
"TextClassifcation",
"SentenceSimilarity"
"SentenceSimilarity",
"ObjectDetection"
]
},
"nugetDependencies": {
Expand Down Expand Up @@ -187,7 +188,15 @@
"confidenceLevel",
"variableHorizon",
"modelFactory",
"sentence1ColumnName"
"sentence1ColumnName",
"boundingBoxColumnName",
"imageColumnName",
"maxEpoch",
"iOUThreshold",
"scoreThreshold",
"steps",
"initLearningRate",
"weightDecay"
]
},
"argumentType": {
Expand Down
61 changes: 61 additions & 0 deletions src/Microsoft.ML.AutoML/CodeGen/object_detection_search_space.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"$schema": "./search-space-schema.json#",
"name": "object_detection_option",
"search_space": [
{
"name": "LabelColumnName",
"type": "string",
"default": "Label"
},
{
"name": "PredictedLabelColumnName",
"type": "string",
"default": "PredictedLabel"
},
{
"name": "PredictedBoundingBoxColumnName",
"type": "string",
"default": "PredictedBoundingBoxes"
},
{
"name": "BoundingBoxColumnName",
"type": "string",
"default": "BoundingBoxes"
},
{
"name": "ImageColumnName",
"type": "string",
"default": "Image"
},
{
"name": "ScoreColumnName",
"type": "string",
"default": "Score"
},
{
"name": "MaxEpoch",
"type": "integer",
"default": 10
},
{
"name": "InitLearningRate",
"type": "double",
"default": 1.0
},
{
"name": "WeightDecay",
"type": "double",
"default": 0.0
},
{
"name": "IOUThreshold",
"type": "double",
"default": 0.5
},
{
"name": "ScoreThreshold",
"type": "double",
"default": 0.5
}
]
}
15 changes: 13 additions & 2 deletions src/Microsoft.ML.AutoML/CodeGen/search-space-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@
"matrix_factorization_option",
"dnn_featurizer_image_option",
"text_classification_option",
"sentence_similarity_option"
"sentence_similarity_option",
"object_detection_option"
]
},
"option_name": {
Expand Down Expand Up @@ -198,7 +199,17 @@
"Epoch",
"Architecture",
"AddKeyValueAnnotationsAsText",
"Arch"
"Arch",
"PredictedLabelColumnName",
"PredictedBoundingBoxColumnName",
"BoundingBoxColumnName",
"ImageColumnName",
"IOUThreshold",
"ScoreThreshold",
"Steps",
"MaxEpoch",
"InitLearningRate",
"WeightDecay"
]
},
"option_type": {
Expand Down
7 changes: 7 additions & 0 deletions src/Microsoft.ML.AutoML/CodeGen/trainer-estimators.json
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,13 @@
"usingStatements": [ "Microsoft.ML", "Microsoft.ML.Trainers", "Microsoft.ML.TorchSharp" ],
"searchOption": "sentence_similarity_option"
},
{
"functionName": "ObjectDetection",
"estimatorTypes": [ "MultiClassification" ],
"nugetDependencies": [ "Microsoft.ML", "Microsoft.ML.TorchSharp" ],
"usingStatements": [ "Microsoft.ML", "Microsoft.ML.Trainers", "Microsoft.ML.TorchSharp" ],
"searchOption": "object_detection_option"
},
{
"functionName": "ForecastBySsa",
"estimatorTypes": [ "Forecasting" ],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.ML.TorchSharp;
using Microsoft.ML.TorchSharp.AutoFormerV2;

namespace Microsoft.ML.AutoML.CodeGen
{
internal partial class ObjectDetectionMulti
{
public override IEstimator<ITransformer> BuildFromOption(MLContext context, ObjectDetectionOption param)
{
var option = new ObjectDetectionTrainer.Options
{
LabelColumnName = param.LabelColumnName,
PredictedLabelColumnName = param.PredictedLabelColumnName,
BoundingBoxColumnName = param.BoundingBoxColumnName,
ImageColumnName = param.ImageColumnName,
ScoreColumnName = param.ScoreColumnName,
MaxEpoch = param.MaxEpoch,
InitLearningRate = param.InitLearningRate,
WeightDecay = param.WeightDecay,
PredictedBoundingBoxColumnName = param.PredictedBoundingBoxColumnName,
ScoreThreshold = param.ScoreThreshold,
IOUThreshold = param.IOUThreshold,
};

return context.MulticlassClassification.Trainers.ObjectDetection(option);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void Execute(GeneratorExecutionContext context)
Properties = options,
}.TransformText();

context.AddSource($"{className}.cs", code);
context.AddSource($"{className}.generated.cs", code);
}
}

Expand Down

0 comments on commit e30555c

Please sign in to comment.