Browse Source

added ConfigUtil empty file.

tags/v0.12
Oceania2018 6 years ago
parent
commit
c8991d4f84
6 changed files with 78 additions and 4 deletions
  1. +19
    -0
      src/TensorFlowNET.Core/Contrib/Train/HParams.cs
  2. +14
    -0
      src/TensorFlowNET.Core/Train/SessionRunContext.cs
  3. +10
    -0
      src/TensorFlowNET.Core/Train/_MonitoredSession.cs
  4. +6
    -1
      src/TensorFlowNET.Models/ObjectDetection/ModelLib.cs
  5. +14
    -0
      src/TensorFlowNET.Models/ObjectDetection/Utils/ConfigUtil.cs
  6. +15
    -3
      test/TensorFlowNET.Examples/ImageProcessing/ObjectDetection/Main.cs

+ 19
- 0
src/TensorFlowNET.Core/Contrib/Train/HParams.cs View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Contrib.Train
{
/// <summary>
/// Class to hold a set of hyperparameters as name-value pairs.
/// </summary>
public class HParams
{
public bool load_pretrained { get; set; }

public HParams(bool load_pretrained)
{
this.load_pretrained = load_pretrained;
}
}
}

+ 14
- 0
src/TensorFlowNET.Core/Train/SessionRunContext.cs View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Train
{
public class SessionRunContext
{
public SessionRunContext(Session session)
{

}
}
}

+ 10
- 0
src/TensorFlowNET.Core/Train/_MonitoredSession.cs View File

@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Train
{
internal class _MonitoredSession
{
}
}

+ 6
- 1
src/TensorFlowNET.Models/ObjectDetection/ModelLib.cs View File

@@ -4,13 +4,18 @@ using System.Text;
using static Tensorflow.Binding;
using Tensorflow.Estimators;
using System.Linq;
using Tensorflow.Contrib.Train;

namespace Tensorflow.Models.ObjectDetection
{
public class ModelLib
{
public TrainAndEvalDict create_estimator_and_inputs(RunConfig run_config,
int train_steps = 1)
HParams hparams = null,
string pipeline_config_path = null,
int train_steps = 0,
int sample_1_of_n_eval_examples = 0,
int sample_1_of_n_eval_on_train_examples = 1)
{
var estimator = tf.estimator.Estimator(config: run_config);



+ 14
- 0
src/TensorFlowNET.Models/ObjectDetection/Utils/ConfigUtil.cs View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Tensorflow.Models.ObjectDetection.Utils
{
public class ConfigUtil
{
public object get_configs_from_pipeline_file(string pipeline_config_path)
{
throw new NotImplementedException("");
}
}
}

+ 15
- 3
test/TensorFlowNET.Examples/ImageProcessing/ObjectDetection/Main.cs View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Text;
using Tensorflow;
using Tensorflow.Contrib.Train;
using Tensorflow.Estimators;
using Tensorflow.Models.ObjectDetection;
using static Tensorflow.Binding;
@@ -18,12 +19,23 @@ 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";
int num_train_steps = 1;
int sample_1_of_n_eval_examples = 1;
int sample_1_of_n_eval_on_train_examples = 5;

public bool Run()
{
string model_dir = "D:/Projects/PythonLab/tf-models/research/object_detection/models/model";

var config = tf.estimator.RunConfig(model_dir: model_dir);
var train_and_eval_dict = model_lib.create_estimator_and_inputs(run_config: config);

var train_and_eval_dict = model_lib.create_estimator_and_inputs(run_config: config,
hparams: new HParams(true),
pipeline_config_path: pipeline_config_path,
train_steps: num_train_steps,
sample_1_of_n_eval_examples: sample_1_of_n_eval_examples,
sample_1_of_n_eval_on_train_examples: sample_1_of_n_eval_on_train_examples);

var estimator = train_and_eval_dict.estimator;
var train_input_fn = train_and_eval_dict.train_input_fn;
var eval_input_fns = train_and_eval_dict.eval_input_fns;


Loading…
Cancel
Save