@@ -226,64 +226,9 @@ static mxArray* vgps_forward(const mxArray* const bottom) {
226
226
return mx_out;
227
227
}
228
228
229
- // Input is a cell array of 2 4-D arrays containing image and joint info
230
- static mxArray* vgps_forwarda_only (const mxArray* const bottom) {
231
- vector<shared_ptr<Blob<float > > > input_blobs;
232
- input_blobs.resize (1 );
233
-
234
- const mxArray* const rgb = mxGetCell (bottom, 0 );
235
- const float * const rgb_ptr = reinterpret_cast <const float * const >(mxGetPr (rgb));
236
- CHECK (mxIsSingle (rgb))
237
- << " MatCaffe require single-precision float point data" ;
238
-
239
- const int num_samples = mxGetDimensions (rgb)[3 ];
240
- const int channels = mxGetDimensions (rgb)[2 ];
241
- const int height = mxGetDimensions (rgb)[0 ];
242
- const int width = mxGetDimensions (rgb)[0 ];
243
- CHECK_EQ (channels, 3 );
244
- CHECK_EQ (height, 240 );
245
-
246
- input_blobs[0 ] = shared_ptr<Blob<float > >(new Blob<float >());
247
-
248
- input_blobs[0 ]->Reshape (num_samples, channels, height, width);
249
-
250
- caffe_copy (input_blobs[0 ]->count (), rgb_ptr, input_blobs[0 ]->mutable_cpu_data ());
251
-
252
- shared_ptr<MemoryDataLayer<float > > md_layer =
253
- boost::dynamic_pointer_cast<MemoryDataLayer<float > >(net_->layers ()[0 ]);
254
- vector<float *> inputs;
255
- inputs.push_back (input_blobs[0 ]->mutable_cpu_data ());
256
- md_layer->Reset (inputs, num_samples);
257
-
258
- float initial_loss;
259
- LOG (INFO) << " Running forward pass" ;
260
- const vector<Blob<float >*>& output_blobs = net_->ForwardPrefilled (&initial_loss);
261
- CHECK_EQ (output_blobs.size (), 1 );
262
-
263
- // output of fc is the only output blob.
264
- mxArray* mx_out = mxCreateCellMatrix (1 , 1 );
265
- mwSize dims[4 ] = {output_blobs[0 ]->width (), output_blobs[0 ]->height (),
266
- output_blobs[0 ]->channels (), output_blobs[0 ]->num ()};
267
- mxArray* mx_blob = mxCreateNumericArray (4 , dims, mxSINGLE_CLASS, mxREAL);
268
- mxSetCell (mx_out, 0 , mx_blob);
269
- float * data_ptr = reinterpret_cast <float *>(mxGetPr (mx_blob));
270
- switch (Caffe::mode ()) {
271
- case Caffe::CPU:
272
- caffe_copy (output_blobs[0 ]->count (), output_blobs[0 ]->cpu_data (),
273
- data_ptr);
274
- break ;
275
- case Caffe::GPU:
276
- caffe_copy (output_blobs[0 ]->count (), output_blobs[0 ]->gpu_data (),
277
- data_ptr);
278
- break ;
279
- default :
280
- mex_error (" Unknown Caffe mode." );
281
- } // switch (Caffe::mode())
282
-
283
- return mx_out;
284
- }
285
229
// Input is a cell array of 2 4-D arrays containing image and joint info
286
230
static mxArray* vgps_forward_only (const mxArray* const bottom) {
231
+ LOG (INFO) << " Running forward pass" ;
287
232
// vector<shared_ptr<Blob<float> > > input_blobs;
288
233
// input_blobs.resize(2);
289
234
shared_ptr<MemoryDataLayer<float > > md_layer =
@@ -621,7 +566,7 @@ static void init_train(MEX_ARGS) {
621
566
solver_.reset (GetSolver<float >(solver_param));
622
567
net_ = solver_->net ();
623
568
624
- if (nrhs = = 2 ) {
569
+ if (nrhs > = 2 ) {
625
570
char * model_file = mxArrayToString (prhs[1 ]);
626
571
solver_->net ()->CopyTrainedLayersFrom (string (model_file));
627
572
mxFree (model_file);
@@ -651,7 +596,7 @@ static void init_test_batch(MEX_ARGS) {
651
596
ReadNetParamsFromTextFileOrDie (string (param_file), &net_param);
652
597
653
598
// Alter batch size of memory data layer in net_param
654
- if (nrhs = = 2 ) {
599
+ if (nrhs > = 2 ) {
655
600
const char * batch_size_string = mxArrayToString (prhs[1 ]);
656
601
int batch_size = atoi (batch_size_string);
657
602
@@ -670,7 +615,7 @@ static void init_test_batch(MEX_ARGS) {
670
615
net_state->set_phase (TEST);
671
616
net_.reset (new Net<float >(net_param));
672
617
673
- if (nrhs = = 3 ) {
618
+ if (nrhs > = 3 ) {
674
619
char * model_file = mxArrayToString (prhs[2 ]);
675
620
net_->CopyTrainedLayersFrom (string (model_file));
676
621
mxFree (model_file);
@@ -703,7 +648,7 @@ static void init_forwarda_batch(MEX_ARGS) {
703
648
ReadNetParamsFromTextFileOrDie (string (param_file), &net_param);
704
649
705
650
// Alter batch size of memory data layer in net_param
706
- if (nrhs = = 2 ) {
651
+ if (nrhs > = 2 ) {
707
652
const char * batch_size_string = mxArrayToString (prhs[1 ]);
708
653
int batch_size = atoi (batch_size_string);
709
654
@@ -722,7 +667,7 @@ static void init_forwarda_batch(MEX_ARGS) {
722
667
net_state->set_phase (FORWARDA);
723
668
net_.reset (new Net<float >(net_param));
724
669
725
- if (nrhs = = 3 ) {
670
+ if (nrhs > = 3 ) {
726
671
char * model_file = mxArrayToString (prhs[2 ]);
727
672
net_->CopyTrainedLayersFrom (string (model_file));
728
673
mxFree (model_file);
@@ -752,7 +697,7 @@ static void init_test(MEX_ARGS) {
752
697
solver_.reset ();
753
698
}
754
699
net_.reset (new Net<float >(string (param_file), TEST));
755
- if (nrhs = = 2 ) {
700
+ if (nrhs > = 2 ) {
756
701
char * model_file = mxArrayToString (prhs[1 ]);
757
702
net_->CopyTrainedLayersFrom (string (model_file));
758
703
mxFree (model_file);
@@ -856,15 +801,6 @@ static void vgps_forward_only(MEX_ARGS) {
856
801
plhs[0 ] = vgps_forward_only (prhs[0 ]);
857
802
}
858
803
859
- static void vgps_forwarda_only (MEX_ARGS) {
860
- if (nrhs != 1 ) {
861
- LOG (ERROR) << " Only given " << nrhs << " arguments" ;
862
- mexErrMsgTxt (" Wrong number of arguments" );
863
- }
864
-
865
- plhs[0 ] = vgps_forwarda_only (prhs[0 ]);
866
- }
867
-
868
804
static void backward (MEX_ARGS) {
869
805
if (nrhs != 1 ) {
870
806
LOG (ERROR) << " Only given " << nrhs << " arguments" ;
@@ -927,7 +863,6 @@ static handler_registry handlers[] = {
927
863
// Public API functions
928
864
{ " forward" , vgps_forward },
929
865
{ " forward_only" , vgps_forward_only },
930
- { " forwarda_only" , vgps_forwarda_only },
931
866
{ " backward" , backward },
932
867
{ " init" , init },
933
868
{ " init_test" , init_test },
0 commit comments