@@ -219,7 +219,7 @@ class DetectionOutputLayerImpl : public DetectionOutputLayer
219
219
_shareLocation, &allLocationPredictions);
220
220
221
221
// Retrieve all confidences.
222
- std::vector<std::map< int , std::vector<float > > > allConfidenceScores;
222
+ std::vector<std::vector< std::vector<float > > > allConfidenceScores;
223
223
GetConfidenceScores (confidenceData, num, numPriors, _numClasses,
224
224
&allConfidenceScores);
225
225
@@ -241,7 +241,7 @@ class DetectionOutputLayerImpl : public DetectionOutputLayer
241
241
for (int i = 0 ; i < num; ++i)
242
242
{
243
243
const LabelBBox& decodeBBoxes = allDecodedBBoxes[i];
244
- const std::map< int , std::vector<float > >& confidenceScores =
244
+ const std::vector< std::vector<float > >& confidenceScores =
245
245
allConfidenceScores[i];
246
246
std::map<int , std::vector<int > > indices;
247
247
int numDetections = 0 ;
@@ -252,13 +252,13 @@ class DetectionOutputLayerImpl : public DetectionOutputLayer
252
252
// Ignore background class.
253
253
continue ;
254
254
}
255
- if (confidenceScores.find (c) == confidenceScores. end () )
255
+ if (confidenceScores.size () <= c )
256
256
{
257
257
// Something bad happened if there are no predictions for current label.
258
258
util::make_error<int >(" Could not find confidence predictions for label " , c);
259
259
}
260
260
261
- const std::vector<float >& scores = confidenceScores. find (c)-> second ;
261
+ const std::vector<float >& scores = confidenceScores[c] ;
262
262
int label = _shareLocation ? -1 : c;
263
263
if (decodeBBoxes.find (label) == decodeBBoxes.end ())
264
264
{
@@ -280,13 +280,13 @@ class DetectionOutputLayerImpl : public DetectionOutputLayer
280
280
{
281
281
int label = it->first ;
282
282
const std::vector<int >& labelIndices = it->second ;
283
- if (confidenceScores.find (label) == confidenceScores. end () )
283
+ if (confidenceScores.size () <= label )
284
284
{
285
285
// Something bad happened for current label.
286
286
util::make_error<int >(" Could not find location predictions for label " , label);
287
287
continue ;
288
288
}
289
- const std::vector<float >& scores = confidenceScores. find ( label)-> second ;
289
+ const std::vector<float >& scores = confidenceScores[ label] ;
290
290
for (size_t j = 0 ; j < labelIndices.size (); ++j)
291
291
{
292
292
size_t idx = labelIndices[j];
@@ -329,20 +329,20 @@ class DetectionOutputLayerImpl : public DetectionOutputLayer
329
329
int count = 0 ;
330
330
for (int i = 0 ; i < num; ++i)
331
331
{
332
- const std::map< int , std::vector<float > >& confidenceScores =
332
+ const std::vector< std::vector<float > >& confidenceScores =
333
333
allConfidenceScores[i];
334
334
const LabelBBox& decodeBBoxes = allDecodedBBoxes[i];
335
335
for (std::map<int , std::vector<int > >::iterator it = allIndices[i].begin ();
336
336
it != allIndices[i].end (); ++it)
337
337
{
338
338
int label = it->first ;
339
- if (confidenceScores.find (label) == confidenceScores. end () )
339
+ if (confidenceScores.size () <= label )
340
340
{
341
341
// Something bad happened if there are no predictions for current label.
342
342
util::make_error<int >(" Could not find confidence predictions for label " , label);
343
343
continue ;
344
344
}
345
- const std::vector<float >& scores = confidenceScores. find ( label)-> second ;
345
+ const std::vector<float >& scores = confidenceScores[ label] ;
346
346
int locLabel = _shareLocation ? -1 : label;
347
347
if (decodeBBoxes.find (locLabel) == decodeBBoxes.end ())
348
348
{
@@ -642,13 +642,14 @@ class DetectionOutputLayerImpl : public DetectionOutputLayer
642
642
// confidence prediction for an image.
643
643
void GetConfidenceScores (const float * confData, const int num,
644
644
const int numPredsPerClass, const int numClasses,
645
- std::vector<std::map< int , std::vector<float > > >* confPreds)
645
+ std::vector<std::vector< std::vector<float > > >* confPreds)
646
646
{
647
647
confPreds->clear ();
648
648
confPreds->resize (num);
649
649
for (int i = 0 ; i < num; ++i)
650
650
{
651
- std::map<int , std::vector<float > >& labelScores = (*confPreds)[i];
651
+ std::vector<std::vector<float > >& labelScores = (*confPreds)[i];
652
+ labelScores.resize (numClasses);
652
653
for (int p = 0 ; p < numPredsPerClass; ++p)
653
654
{
654
655
int startIdx = p * numClasses;
0 commit comments