Skip to content
This repository was archived by the owner on Aug 11, 2025. It is now read-only.

Commit ccb53bf

Browse files
Dorokhovmigueldeicaza
authored andcommitted
Object Detection Example: Changed URL to Pretrained Model (#154)
The URL of the pre-trained model was changed recently, so I updated it in the example as well and moved to the configuration file.
1 parent c747383 commit ccb53bf

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3-
<startup>
4-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
5-
</startup>
3+
<appSettings>
4+
<add key="DefaultModelUrl" value="http://download.tensorflow.org/models/object_detection/faster_rcnn_inception_resnet_v2_atrous_coco_11_06_2017.tar.gz"/>
5+
<add key="DefaultTextsUrl" value="https://raw.githubusercontent.com/tensorflow/models/master/research/object_detection/data/mscoco_label_map.pbtxt"/>
6+
</appSettings>
7+
<startup>
8+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
9+
</startup>
610
</configuration>

Examples/ExampleObjectDetection/ExampleObjectDetection.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
<HintPath>..\..\packages\Mono.Options.5.3.0.1\lib\net4-client\Mono.Options.dll</HintPath>
4141
</Reference>
4242
<Reference Include="System" />
43+
<Reference Include="System.Configuration" />
4344
<Reference Include="System.Core" />
4445
<Reference Include="System.Drawing" />
4546
<Reference Include="System.IO.Compression" />

Examples/ExampleObjectDetection/Program.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
5+
using System.Configuration;
56
using TensorFlow;
67
using ExampleCommon;
78
using Mono.Options;
8-
using System.IO.Compression;
99
using System.Reflection;
1010
using System.Net;
11-
using ICSharpCode.SharpZipLib.Zip;
1211
using ICSharpCode.SharpZipLib.Tar;
1312
using ICSharpCode.SharpZipLib.GZip;
1413

@@ -94,7 +93,7 @@ static void Main (string [] args)
9493

9594
private static string DownloadDefaultModel (string dir)
9695
{
97-
const string defaultModelUrl = "http://download.tensorflow.org/models/object_detection/faster_rcnn_inception_resnet_v2_atrous_coco_11_06_2017.tar.gz";
96+
string defaultModelUrl = ConfigurationManager.AppSettings["DefaultModelUrl"] ?? throw new ConfigurationErrorsException("'DefaultModelUrl' setting is missing in the configuration file");
9897

9998
var modelFile = Path.Combine (dir, "faster_rcnn_inception_resnet_v2_atrous_coco_11_06_2017/frozen_inference_graph.pb");
10099
var zipfile = Path.Combine (dir, "faster_rcnn_inception_resnet_v2_atrous_coco_11_06_2017.tar.gz");
@@ -124,7 +123,7 @@ private static void ExtractToDirectory (string file, string targetDir)
124123

125124
private static string DownloadDefaultTexts (string dir)
126125
{
127-
const string defaultTextsUrl = "https://raw.githubusercontent.com/tensorflow/models/master/object_detection/data/mscoco_label_map.pbtxt";
126+
string defaultTextsUrl = ConfigurationManager.AppSettings ["DefaultTextsUrl"] ?? throw new ConfigurationErrorsException ("'DefaultTextsUrl' setting is missing in the configuration file");
128127
var textsFile = Path.Combine (dir, "mscoco_label_map.pbtxt");
129128
var wc = new WebClient ();
130129
wc.DownloadFile (defaultTextsUrl, textsFile);

0 commit comments

Comments
 (0)