Skip to content

Commit

Permalink
added command line parser to detectNet
Browse files Browse the repository at this point in the history
  • Loading branch information
dusty-nv committed Apr 7, 2017
1 parent 3ff53dd commit 20dd22f
Show file tree
Hide file tree
Showing 95 changed files with 278 additions and 164 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Vision primitives, such as [`imageNet`](imageNet.h) for image recognition, [`det

<img src="https://github.com/dusty-nv/jetson-inference/raw/master/docs/images/deep-vision-primitives.png" width="800">

> ![Alt text](https://github.com/dusty-nv/jetson-inference/raw/master/docs/images/new.jpg) See our technical **[Parallel ForAll post](https://devblogs.nvidia.com/parallelforall/jetson-tx2-delivers-twice-intelligence-edge/)**, *NVIDIA Jetson TX2 Delivers Twice the Intelligence to the Edge*.
> ![Alt text](https://github.com/dusty-nv/jetson-inference/raw/master/docs/images/new.jpg) Read our recent **[Parallel ForAll post](https://devblogs.nvidia.com/parallelforall/jetson-tx2-delivers-twice-intelligence-edge/)**, *NVIDIA Jetson TX2 Delivers Twice the Intelligence to the Edge*.
### **Ten Steps to Deep Learning**

Expand Down
88 changes: 76 additions & 12 deletions detectNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,14 @@
#include "cudaOverlay.h"
#include "cudaResize.h"

#include "commandLine.h"

#define OUTPUT_CVG 0
#define OUTPUT_BBOX 1

//#define DEBUG_CLUSTERING


// Create
detectNet* detectNet::Create( NetworkType networkType, float threshold, uint32_t maxBatchSize )
{
if( networkType == PEDNET_MULTI )
return Create("networks/multiped-500/deploy.prototxt", "networks/multiped-500/snapshot_iter_178000.caffemodel", "networks/multiped-500/mean.binaryproto", threshold, DETECTNET_DEFAULT_INPUT, DETECTNET_DEFAULT_COVERAGE, DETECTNET_DEFAULT_BBOX, maxBatchSize );
else if( networkType == FACENET )
return Create("networks/facenet-120/deploy.prototxt", "networks/facenet-120/snapshot_iter_24000.caffemodel", NULL, threshold, DETECTNET_DEFAULT_INPUT, DETECTNET_DEFAULT_COVERAGE, DETECTNET_DEFAULT_BBOX, maxBatchSize );
else /*if( networkTYpe == PEDNET )*/
return Create("networks/ped-100/deploy.prototxt", "networks/ped-100/snapshot_iter_70800.caffemodel", "networks/ped-100/mean.binaryproto", threshold, DETECTNET_DEFAULT_INPUT, DETECTNET_DEFAULT_COVERAGE, DETECTNET_DEFAULT_BBOX, maxBatchSize );
}


// constructor
detectNet::detectNet() : tensorNet()
{
Expand All @@ -52,6 +41,16 @@ detectNet* detectNet::Create( const char* prototxt, const char* model, const cha
if( !net )
return NULL;

printf("\n");
printf("detectNet -- loading segmentation network model from:\n");
printf(" -- prototxt: %s\n", prototxt);
printf(" -- model: %s\n", model);
printf(" -- input_blob '%s'\n", input_blob);
printf(" -- output_cvg '%s'\n", coverage_blob);
printf(" -- output_bbox '%s'\n", bbox_blob);
printf(" -- threshold %f\n", threshold);
printf(" -- batch_size %u\n\n", maxBatchSize);

//net->EnableDebug();

std::vector<std::string> output_blobs;
Expand Down Expand Up @@ -92,6 +91,71 @@ detectNet* detectNet::Create( const char* prototxt, const char* model, const cha
}



// Create
detectNet* detectNet::Create( NetworkType networkType, float threshold, uint32_t maxBatchSize )
{
if( networkType == PEDNET_MULTI )
return Create("networks/multiped-500/deploy.prototxt", "networks/multiped-500/snapshot_iter_178000.caffemodel", "networks/multiped-500/mean.binaryproto", threshold, DETECTNET_DEFAULT_INPUT, DETECTNET_DEFAULT_COVERAGE, DETECTNET_DEFAULT_BBOX, maxBatchSize );
else if( networkType == FACENET )
return Create("networks/facenet-120/deploy.prototxt", "networks/facenet-120/snapshot_iter_24000.caffemodel", NULL, threshold, DETECTNET_DEFAULT_INPUT, DETECTNET_DEFAULT_COVERAGE, DETECTNET_DEFAULT_BBOX, maxBatchSize );
else /*if( networkTYpe == PEDNET )*/
return Create("networks/ped-100/deploy.prototxt", "networks/ped-100/snapshot_iter_70800.caffemodel", "networks/ped-100/mean.binaryproto", threshold, DETECTNET_DEFAULT_INPUT, DETECTNET_DEFAULT_COVERAGE, DETECTNET_DEFAULT_BBOX, maxBatchSize );
}


// Create
detectNet* detectNet::Create( int argc, char** argv )
{
commandLine cmdLine(argc, argv);

const char* modelName = cmdLine.GetString("model");

if( !modelName )
{
modelName = "multiped";

if( argc > 3 )
modelName = argv[3];

detectNet::NetworkType type = detectNet::PEDNET_MULTI;

if( strcasecmp(modelName, "multiped") == 0 || strcasecmp(modelName, "multiped-500") == 0 )
type = detectNet::PEDNET_MULTI;
else if( strcasecmp(modelName, "pednet") == 0 || strcasecmp(modelName, "ped-100") == 0 )
type = detectNet::PEDNET;
else if( strcasecmp(modelName, "facenet") == 0 || strcasecmp(modelName, "facenet-120") == 0 || strcasecmp(modelName, "face-120") == 0 )
type = detectNet::FACENET;

// create segnet from pretrained model
return detectNet::Create(type);
}
else
{
const char* prototxt = cmdLine.GetString("prototxt");
const char* input = cmdLine.GetString("input_blob");
const char* out_cvg = cmdLine.GetString("output_cvg");
const char* out_bbox = cmdLine.GetString("output_bbox");

if( !input ) input = DETECTNET_DEFAULT_INPUT;
if( !out_cvg ) out_cvg = DETECTNET_DEFAULT_COVERAGE;
if( !out_bbox ) out_bbox = DETECTNET_DEFAULT_BBOX;

float threshold = cmdLine.GetFloat("threshold");

if( threshold == 0.0f )
threshold = 0.5f;

int maxBatchSize = cmdLine.GetInt("batch_size");

if( maxBatchSize < 1 )
maxBatchSize = 2;

return detectNet::Create(prototxt, modelName, NULL, threshold, input, out_cvg, out_bbox, maxBatchSize);
}
}


cudaError_t cudaPreImageNetMean( float4* input, size_t inputWidth, size_t inputHeight, float* output, size_t outputWidth, size_t outputHeight, const float3& mean_value );


Expand Down
5 changes: 5 additions & 0 deletions detectNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ class detectNet : public tensorNet
const char* bboxes = DETECTNET_DEFAULT_BBOX,
uint32_t maxBatchSize=2 );

/**
* Load a new network instance by parsing the command line.
*/
static detectNet* Create( int argc, char** argv );

/**
* Destory
*/
Expand Down
2 changes: 1 addition & 1 deletion docs/html/annotated.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Generated on Fri Apr 7 2017 16:20:02 for Deep Vision by
<li class="footer">Generated on Fri Apr 7 2017 17:09:31 for Deep Vision by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/classcommandLine-members.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Generated on Fri Apr 7 2017 16:20:02 for Deep Vision by
<li class="footer">Generated on Fri Apr 7 2017 17:09:31 for Deep Vision by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/classcommandLine.html
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ <h2 class="groupheader">Member Data Documentation</h2>
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="classcommandLine.html">commandLine</a></li>
<li class="footer">Generated on Fri Apr 7 2017 16:20:02 for Deep Vision by
<li class="footer">Generated on Fri Apr 7 2017 17:09:31 for Deep Vision by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/classcudaFont-members.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Generated on Fri Apr 7 2017 16:20:02 for Deep Vision by
<li class="footer">Generated on Fri Apr 7 2017 17:09:31 for Deep Vision by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/classcudaFont.html
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ <h2 class="groupheader">Member Data Documentation</h2>
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="classcudaFont.html">cudaFont</a></li>
<li class="footer">Generated on Fri Apr 7 2017 16:20:02 for Deep Vision by
<li class="footer">Generated on Fri Apr 7 2017 17:09:31 for Deep Vision by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
</ul>
Expand Down
Loading

0 comments on commit 20dd22f

Please sign in to comment.