FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

init commit for YOLOv3. · feelsyt/TensorFlow.NET@5e43f4d · GitHub

Commit 5e43f4d

Browse files
committed
init commit for YOLOv3.
1 parent 683aeed commit 5e43f4d

7 files changed

Lines changed: 177 additions & 2 deletions

File tree

src/TensorFlowNET.Core/Train/tf.optimizers.cs renamed to src/TensorFlowNET.Core/APIs/tf.train.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ public Optimizer GradientDescentOptimizer(float learning_rate)
3131
public Optimizer AdamOptimizer(float learning_rate, string name = "Adam")
3232
=> new AdamOptimizer(learning_rate, name: name);
3333

34+
public object ExponentialMovingAverage(float decay)
35+
=> new ExponentialMovingAverage(decay);
36+
3437
public Saver Saver(VariableV1[] var_list = null) => new Saver(var_list: var_list);
3538

3639
public string write_graph(Graph graph, string logdir, string name, bool as_text = true)

‎src/TensorFlowNET.Core/TensorFlowNET.Core.csproj‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
<PackageTags>TensorFlow, NumSharp, SciSharp, MachineLearning, TensorFlow.NET, C#</PackageTags>
1818
<Description>Google's TensorFlow full binding in .NET Standard.
1919
Docs: https://tensorflownet.readthedocs.io</Description>
20-
<AssemblyVersion>0.11.10.0</AssemblyVersion>
20+
<AssemblyVersion>0.11.0.0</AssemblyVersion>
2121
<PackageReleaseNotes>Changes since v0.10.0:</PackageReleaseNotes>
2222
<LangVersion>7.3</LangVersion>
23-
<FileVersion>0.11.10.0</FileVersion>
23+
<FileVersion>0.11.0.0</FileVersion>
2424
<PackageLicenseFile>LICENSE</PackageLicenseFile>
2525
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
2626
<SignAssembly>true</SignAssembly>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Tensorflow.Train
6+
{
7+
public class ExponentialMovingAverage
8+
{
9+
float _decay;
10+
int? _num_updates;
11+
bool _zero_debias;
12+
string _name;
13+
public string name => _name;
14+
15+
public ExponentialMovingAverage(float decay, int? num_updates = null, bool zero_debias = false,
16+
string name = "ExponentialMovingAverage")
17+
{
18+
_decay = decay;
19+
_num_updates = num_updates;
20+
_zero_debias = zero_debias;
21+
_name = name;
22+
}
23+
24+
/// <summary>
25+
/// Maintains moving averages of variables.
26+
/// </summary>
27+
/// <param name="var_list"></param>
28+
/// <returns></returns>
29+
public Operation apply(VariableV1[] var_list = null)
30+
{
31+
throw new NotImplementedException("");
32+
}
33+
34+
35+
}
36+
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Text;
5+
using Tensorflow;
6+
using static Tensorflow.Binding;
7+
8+
namespace TensorFlowNET.Examples.ImageProcessing.YOLO
9+
{
10+
/// <summary>
11+
/// Implementation of YOLO v3 object detector in Tensorflow
12+
/// https://github.com/YunYang1994/tensorflow-yolov3
13+
/// </summary>
14+
public class Main : IExample
15+
{
16+
public bool Enabled { get; set; } = true;
17+
public bool IsImportingGraph { get; set; } = false;
18+
19+
public string Name => "YOLOv3";
20+
21+
Dictionary<int, string> classes;
22+
Config config;
23+
24+
Tensor input_data;
25+
Tensor label_sbbox;
26+
Tensor label_mbbox;
27+
Tensor label_lbbox;
28+
Tensor true_sbboxes;
29+
Tensor true_mbboxes;
30+
Tensor true_lbboxes;
31+
Tensor trainable;
32+
33+
public bool Run()
34+
{
35+
PrepareData();
36+
37+
var graph = IsImportingGraph ? ImportGraph() : BuildGraph();
38+
39+
using (var sess = tf.Session(graph))
40+
{
41+
Train(sess);
42+
}
43+
44+
return true;
45+
}
46+
47+
public void Train(Session sess)
48+
{
49+
50+
}
51+
52+
public void Test(Session sess)
53+
{
54+
throw new NotImplementedException();
55+
}
56+
57+
public Graph BuildGraph()
58+
{
59+
var graph = new Graph().as_default();
60+
61+
tf_with(tf.name_scope("define_input"), scope =>
62+
{
63+
input_data = tf.placeholder(dtype: tf.float32, name: "input_data");
64+
label_sbbox = tf.placeholder(dtype: tf.float32, name: "label_sbbox");
65+
label_mbbox = tf.placeholder(dtype: tf.float32, name: "label_mbbox");
66+
label_lbbox = tf.placeholder(dtype: tf.float32, name: "label_lbbox");
67+
true_sbboxes = tf.placeholder(dtype: tf.float32, name: "sbboxes");
68+
true_mbboxes = tf.placeholder(dtype: tf.float32, name: "mbboxes");
69+
true_lbboxes = tf.placeholder(dtype: tf.float32, name: "lbboxes");
70+
trainable = tf.placeholder(dtype: tf.@bool, name: "training");
71+
});
72+
73+
tf_with(tf.name_scope("define_loss"), scope =>
74+
{
75+
//model = new YOLOv3(input_data, trainable);
76+
});
77+
78+
return graph;
79+
}
80+
81+
public Graph ImportGraph()
82+
{
83+
throw new NotImplementedException();
84+
}
85+
86+
public void Predict(Session sess)
87+
{
88+
throw new NotImplementedException();
89+
}
90+
91+
public void PrepareData()
92+
{
93+
config = new Config(Name);
94+
95+
string dataDir = Path.Combine(Name, "data");
96+
Directory.CreateDirectory(dataDir);
97+
98+
classes = new Dictionary<int, string>();
99+
foreach (var line in File.ReadAllLines(config.CLASSES))
100+
classes[classes.Count] = line;
101+
}
102+
}
103+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace TensorFlowNET.Examples.ImageProcessing.YOLO
6+
{
7+
public class YOLOv3
8+
{
9+
}
10+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Text;
5+
6+
namespace TensorFlowNET.Examples.ImageProcessing.YOLO
7+
{
8+
public class Config
9+
{
10+
string _root;
11+
public string CLASSES;
12+
13+
public Config(string root)
14+
{
15+
_root = root;
16+
CLASSES = Path.Combine(_root, "data", "classes", "coco.names");
17+
}
18+
}
19+
}

‎test/TensorFlowNET.Examples/TensorFlowNET.Examples.csproj‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
77
</PropertyGroup>
88

9+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
10+
<DefineConstants>DEBUG;TRACE</DefineConstants>
11+
</PropertyGroup>
12+
913
<ItemGroup>
1014
<PackageReference Include="Colorful.Console" Version="1.2.9" />
1115
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL