Skip to content

Commit 64b07a6

Browse files
Syn-McJmigueldeicaza
authored andcommitted
Add output for ExampleObjectDetection (migueldeicaza#282)
* added some helpful output for ObjectDetection example * fixed indent * fixed indent
1 parent 1e3ddef commit 64b07a6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Examples/ExampleObjectDetection/Program.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ class Program
1717
{
1818
private static IEnumerable<CatalogItem> _catalog;
1919
private static string _currentDir = Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location);
20-
private static string _input = Path.Combine (_currentDir, "test_images/input.jpg");
21-
private static string _output = Path.Combine (_currentDir, "test_images/output.jpg");
20+
private static string _input_relative = "test_images/input.jpg";
21+
private static string _output_relative = "test_images/output.jpg";
22+
private static string _input = Path.Combine (_currentDir, _input_relative);
23+
private static string _output = Path.Combine (_currentDir, _output_relative);
2224
private static string _catalogPath;
2325
private static string _modelPath;
2426

@@ -66,6 +68,8 @@ static void Main (string [] args)
6668
graph.Import (new TFBuffer (model));
6769

6870
using (var session = new TFSession (graph)) {
71+
Console.WriteLine("Detecting objects");
72+
6973
foreach (var tuple in fileTuples) {
7074
var tensor = ImageUtil.CreateTensorFromImageFile (tuple.input, TFDataType.UInt8);
7175
var runner = session.GetRunner ();
@@ -86,6 +90,7 @@ static void Main (string [] args)
8690
var num = (float [])output [3].GetValue (jagged: false);
8791

8892
DrawBoxes (boxes, scores, classes, tuple.input, tuple.output, MIN_SCORE_FOR_OBJECT_HIGHLIGHTING);
93+
Console.WriteLine($"Done. See {_output_relative}");
8994
}
9095
}
9196
}
@@ -102,6 +107,7 @@ private static string DownloadDefaultModel (string dir)
102107
return modelFile;
103108

104109
if (!File.Exists (zipfile)) {
110+
Console.WriteLine("Downloading default model");
105111
var wc = new WebClient ();
106112
wc.DownloadFile (defaultModelUrl, zipfile);
107113
}
@@ -114,6 +120,8 @@ private static string DownloadDefaultModel (string dir)
114120

115121
private static void ExtractToDirectory (string file, string targetDir)
116122
{
123+
Console.WriteLine("Extracting");
124+
117125
using (Stream inStream = File.OpenRead (file))
118126
using (Stream gzipStream = new GZipInputStream (inStream)) {
119127
TarArchive tarArchive = TarArchive.CreateInputTarArchive (gzipStream);
@@ -123,6 +131,8 @@ private static void ExtractToDirectory (string file, string targetDir)
123131

124132
private static string DownloadDefaultTexts (string dir)
125133
{
134+
Console.WriteLine("Downloading default label map");
135+
126136
string defaultTextsUrl = ConfigurationManager.AppSettings ["DefaultTextsUrl"] ?? throw new ConfigurationErrorsException ("'DefaultTextsUrl' setting is missing in the configuration file");
127137
var textsFile = Path.Combine (dir, "mscoco_label_map.pbtxt");
128138
var wc = new WebClient ();

0 commit comments

Comments
 (0)