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

ImportGraphDefFromPbFile · attackgithub/TensorFlow.NET@1088e1f · GitHub

Repository navigation

Commit 1088e1f

Browse files
committed
ImportGraphDefFromPbFile
1 parent 4eccba4 commit 1088e1f

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎src/TensorFlowNET.Core/Graphs/Graph.Import.cs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Google.Protobuf;
22
using System;
33
using System.Collections.Generic;
4+
using System.IO;
45
using System.Runtime.InteropServices;
56
using System.Text;
67

@@ -24,5 +25,14 @@ public unsafe TF_Output[] ImportGraphDefWithReturnOutputs(Buffer graph_def, Impo
2425

2526
return return_outputs;
2627
}
28+
29+
public Status Import(string file_path)
30+
{
31+
var bytes = File.ReadAllBytes(file_path);
32+
var graph_def = new Tensorflow.Buffer(bytes);
33+
var opts = c_api.TF_NewImportGraphDefOptions();
34+
c_api.TF_GraphImportGraphDef(_handle, graph_def, opts, Status);
35+
return Status;
36+
}
2737
}
2838
}

‎test/TensorFlowNET.Examples/MetaGraph.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Runtime.InteropServices;
35
using System.Text;
46
using Tensorflow;
57

‎test/TensorFlowNET.UnitTest/TrainSaverTest.cs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Microsoft.VisualStudio.TestTools.UnitTesting;
22
using System;
33
using System.Collections.Generic;
4+
using System.IO;
45
using System.Text;
56
using Tensorflow;
67

@@ -35,6 +36,13 @@ public void ImportSavedModel()
3536
});
3637
}
3738

39+
[TestMethod]
40+
public void ImportGraphDefFromPbFile()
41+
{
42+
var g = new Graph();
43+
var status = g.Import("mobilenet/saved_model.pb");
44+
}
45+
3846
[TestMethod]
3947
public void Save1()
4048
{

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL