diff --git a/src/TensorFlowNET.Core/Estimators/RunConfig.cs b/src/TensorFlowNET.Core/Estimators/RunConfig.cs
index e13d25aa..37c7d4d1 100644
--- a/src/TensorFlowNET.Core/Estimators/RunConfig.cs
+++ b/src/TensorFlowNET.Core/Estimators/RunConfig.cs
@@ -43,13 +43,12 @@ namespace Tensorflow.Estimators
#endregion
- private static readonly object _USE_DEFAULT = new object();
public string model_dir { get; set; }
public ConfigProto session_config { get; set; }
public int? tf_random_seed { get; set; }
public int save_summary_steps { get; set; } = 100;
- public object save_checkpoints_steps { get; set; } = _USE_DEFAULT;
- public object save_checkpoints_secs { get; set; } = _USE_DEFAULT;
+ public int save_checkpoints_steps { get; set; }
+ public int save_checkpoints_secs { get; set; } = 600;
public int keep_checkpoint_max { get; set; } = 5;
public int keep_checkpoint_every_n_hours { get; set; } = 10000;
public int log_step_count_steps{ get; set; } = 100;
@@ -97,23 +96,6 @@ namespace Tensorflow.Estimators
private void Initialize()
{
- if (this.save_checkpoints_steps == _USE_DEFAULT && this.save_checkpoints_secs == _USE_DEFAULT)
- {
- this.save_checkpoints_steps = null;
- this.save_checkpoints_secs = 600;
- }
- else if (this.save_checkpoints_secs == _USE_DEFAULT)
- {
- this.save_checkpoints_secs = null;
- }
- else if (this.save_checkpoints_steps == _USE_DEFAULT)
- {
- this.save_checkpoints_steps = null;
- }
- else if (this.save_checkpoints_steps != null && save_checkpoints_secs != null)
- {
- throw new Exception(_SAVE_CKPT_ERR);
- }
}
}
}
diff --git a/src/TensorFlowNET.Core/Estimators/_TrainingExecutor.cs b/src/TensorFlowNET.Core/Estimators/_TrainingExecutor.cs
index 1e1f0855..88cb7638 100644
--- a/src/TensorFlowNET.Core/Estimators/_TrainingExecutor.cs
+++ b/src/TensorFlowNET.Core/Estimators/_TrainingExecutor.cs
@@ -16,6 +16,8 @@ namespace Tensorflow.Estimators
public _TrainingExecutor(Estimator estimator, TrainSpec train_spec, EvalSpec eval_spec)
{
_estimator = estimator;
+ _train_spec = train_spec;
+ _eval_spec = eval_spec;
}
public void run()
diff --git a/src/TensorFlowNET.Models/ObjectDetection/ModelLib.cs b/src/TensorFlowNET.Models/ObjectDetection/ModelLib.cs
index c68b8815..ee70abc3 100644
--- a/src/TensorFlowNET.Models/ObjectDetection/ModelLib.cs
+++ b/src/TensorFlowNET.Models/ObjectDetection/ModelLib.cs
@@ -5,6 +5,7 @@ using static Tensorflow.Binding;
using Tensorflow.Estimators;
using System.Linq;
using Tensorflow.Contrib.Train;
+using Tensorflow.Models.ObjectDetection.Utils;
namespace Tensorflow.Models.ObjectDetection
{
@@ -19,11 +20,16 @@ namespace Tensorflow.Models.ObjectDetection
{
var estimator = tf.estimator.Estimator(config: run_config);
+ var config = ConfigUtil.get_configs_from_pipeline_file(pipeline_config_path);
+ var eval_input_configs = config.EvalInputReader;
+
+ var eval_input_fns = new Action[eval_input_configs.Count];
+
return new TrainAndEvalDict
{
estimator = estimator,
train_steps = train_steps,
- eval_input_fns = new Action[0]
+ eval_input_fns = eval_input_fns
};
}
diff --git a/src/TensorFlowNET.Models/ObjectDetection/Models/faster_rcnn_resnet101_voc07.config b/src/TensorFlowNET.Models/ObjectDetection/Models/faster_rcnn_resnet101_voc07.config
new file mode 100644
index 00000000..d5ec5f38
--- /dev/null
+++ b/src/TensorFlowNET.Models/ObjectDetection/Models/faster_rcnn_resnet101_voc07.config
@@ -0,0 +1,143 @@
+{
+ "model": {
+ "fasterRcnn": {
+ "numClasses": 20,
+ "imageResizer": {
+ "keepAspectRatioResizer": {
+ "minDimension": 600,
+ "maxDimension": 1024
+ }
+ },
+ "featureExtractor": {
+ "type": "faster_rcnn_resnet101",
+ "firstStageFeaturesStride": 16
+ },
+ "firstStageAnchorGenerator": {
+ "gridAnchorGenerator": {
+ "heightStride": 16,
+ "widthStride": 16,
+ "scales": [
+ 0.25,
+ 0.5,
+ 1.0,
+ 2.0
+ ],
+ "aspectRatios": [
+ 0.5,
+ 1.0,
+ 2.0
+ ]
+ }
+ },
+ "firstStageBoxPredictorConvHyperparams": {
+ "op": "CONV",
+ "regularizer": {
+ "l2Regularizer": {
+ "weight": 0.0
+ }
+ },
+ "initializer": {
+ "truncatedNormalInitializer": {
+ "stddev": 0.009999999776482582
+ }
+ }
+ },
+ "firstStageNmsScoreThreshold": 0.0,
+ "firstStageNmsIouThreshold": 0.699999988079071,
+ "firstStageMaxProposals": 300,
+ "firstStageLocalizationLossWeight": 2.0,
+ "firstStageObjectnessLossWeight": 1.0,
+ "initialCropSize": 14,
+ "maxpoolKernelSize": 2,
+ "maxpoolStride": 2,
+ "secondStageBoxPredictor": {
+ "maskRcnnBoxPredictor": {
+ "fcHyperparams": {
+ "op": "FC",
+ "regularizer": {
+ "l2Regularizer": {
+ "weight": 0.0
+ }
+ },
+ "initializer": {
+ "varianceScalingInitializer": {
+ "factor": 1.0,
+ "uniform": true,
+ "mode": "FAN_AVG"
+ }
+ }
+ },
+ "useDropout": false,
+ "dropoutKeepProbability": 1.0
+ }
+ },
+ "secondStagePostProcessing": {
+ "batchNonMaxSuppression": {
+ "scoreThreshold": 0.0,
+ "iouThreshold": 0.6000000238418579,
+ "maxDetectionsPerClass": 100,
+ "maxTotalDetections": 300
+ },
+ "scoreConverter": "SOFTMAX"
+ },
+ "secondStageLocalizationLossWeight": 2.0,
+ "secondStageClassificationLossWeight": 1.0
+ }
+ },
+ "trainConfig": {
+ "batchSize": 1,
+ "dataAugmentationOptions": [
+ {
+ "randomHorizontalFlip": {}
+ }
+ ],
+ "optimizer": {
+ "momentumOptimizer": {
+ "learningRate": {
+ "manualStepLearningRate": {
+ "initialLearningRate": 9.999999747378752e-05,
+ "schedule": [
+ {
+ "step": 500000,
+ "learningRate": 9.999999747378752e-06
+ },
+ {
+ "step": 700000,
+ "learningRate": 9.999999974752427e-07
+ }
+ ]
+ }
+ },
+ "momentumOptimizerValue": 0.8999999761581421
+ },
+ "useMovingAverage": false
+ },
+ "gradientClippingByNorm": 10.0,
+ "fineTuneCheckpoint": "D:/tmp/faster_rcnn_resnet101_coco/model.ckpt",
+ "fromDetectionCheckpoint": true,
+ "numSteps": 800000
+ },
+ "trainInputReader": {
+ "labelMapPath": "D:/Projects/PythonLab/tf-models/research/object_detection/data/pascal_label_map.pbtxt",
+ "tfRecordInputReader": {
+ "inputPath": [
+ "D:/Projects/PythonLab/tf-models/research/object_detection/data/pascal_train.record"
+ ]
+ }
+ },
+ "evalConfig": {
+ "numExamples": 4952
+ },
+ "evalInputReader": [
+ {
+ "labelMapPath": "D:/Projects/PythonLab/tf-models/research/object_detection/data/pascal_label_map.pbtxt",
+ "shuffle": false,
+ "numReaders": 1,
+ "tfRecordInputReader": {
+ "inputPath": [
+ "D:/Projects/PythonLab/tf-models/research/object_detection/data/pascal_val.record"
+ ]
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/src/TensorFlowNET.Models/ObjectDetection/Utils/ConfigUtil.cs b/src/TensorFlowNET.Models/ObjectDetection/Utils/ConfigUtil.cs
index c71a7d1e..dbb64b0e 100644
--- a/src/TensorFlowNET.Models/ObjectDetection/Utils/ConfigUtil.cs
+++ b/src/TensorFlowNET.Models/ObjectDetection/Utils/ConfigUtil.cs
@@ -1,14 +1,19 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Text;
+using Tensorflow.Models.ObjectDetection.Protos;
namespace Tensorflow.Models.ObjectDetection.Utils
{
public class ConfigUtil
{
- public object get_configs_from_pipeline_file(string pipeline_config_path)
+ public static TrainEvalPipelineConfig get_configs_from_pipeline_file(string pipeline_config_path)
{
- throw new NotImplementedException("");
+ var json = File.ReadAllText(pipeline_config_path);
+ var pipeline_config = TrainEvalPipelineConfig.Parser.ParseJson(json);
+
+ return pipeline_config;
}
}
}
diff --git a/src/TensorFlowNET.Models/TensorFlowNET.Models.csproj b/src/TensorFlowNET.Models/TensorFlowNET.Models.csproj
index e88ea92c..291c7c03 100644
--- a/src/TensorFlowNET.Models/TensorFlowNET.Models.csproj
+++ b/src/TensorFlowNET.Models/TensorFlowNET.Models.csproj
@@ -6,6 +6,16 @@
Tensorflow.Models
+
+
+
+
+
+
+ PreserveNewest
+
+
+
diff --git a/test/TensorFlowNET.Examples/ImageProcessing/ObjectDetection/Main.cs b/test/TensorFlowNET.Examples/ImageProcessing/ObjectDetection/Main.cs
index 03bbab7f..e879ec80 100644
--- a/test/TensorFlowNET.Examples/ImageProcessing/ObjectDetection/Main.cs
+++ b/test/TensorFlowNET.Examples/ImageProcessing/ObjectDetection/Main.cs
@@ -20,7 +20,7 @@ namespace TensorFlowNET.Examples.ImageProcessing.ObjectDetection
ModelLib model_lib = new ModelLib();
string model_dir = "D:/Projects/PythonLab/tf-models/research/object_detection/models/model";
- string pipeline_config_path = "D:/Projects/PythonLab/tf-models/research/object_detection/models/model/faster_rcnn_resnet101_voc07.config";
+ string pipeline_config_path = "ObjectDetection/Models/faster_rcnn_resnet101_voc07.config";
int num_train_steps = 1;
int sample_1_of_n_eval_examples = 1;
int sample_1_of_n_eval_on_train_examples = 5;