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