Обнаружение объектов в TensorFlow Lite C ++ с моделью MobileNet-SSD v1 - PullRequest
0 голосов
/ 17 мая 2018

Согласно этой информации ссылка , TensorFlow Lite теперь поддерживает обнаружение объектов с использованием модели MobileNet-SSD v1. В этой ссылке есть пример для Java, но как можно проанализировать вывод в C ++? Я не могу найти документацию по этому поводу. Этот код показывает пример.

.......
(fill inputs)
.......

intepreter->Invoke();
const std::vector<int>& results = interpreter->outputs();
TfLiteTensor* outputLocations = interpreter->tensor(results[0]);
TfLiteTensor* outputClasses   = interpreter->tensor(results[1]);
float *data = tflite::GetTensorData<float>(outputClasses);
for(int i=0;i<NUM_RESULTS;i++)
{
   for(int j=1;j<NUM_CLASSES;j++)
   {
      float score = expit(data[i*NUM_CLASSES+j]); // ¿? This does not seem to be correct.
    }
}

1 Ответ

0 голосов
/ 27 июля 2018

Если вам нужно вычислить expit, вам нужно определить функцию для этого.Добавьте вверху:

#include <cmath>

, а затем

intepreter->Invoke();
const std::vector<int>& results = interpreter->outputs();
TfLiteTensor* outputLocations = interpreter->tensor(results[0]);
TfLiteTensor* outputClasses   = interpreter->tensor(results[1]);
float *data = tflite::GetTensorData<float>(outputClasses);
for(int i=0;i<NUM_RESULTS;i++)
{
   for(int j=1;j<NUM_CLASSES;j++)
   {
      auto expit = [](float x) {return 1.f/(1.f + std::exp(-x));};
      float score = expit(data[i*NUM_CLASSES+j]); // ¿? This does not seem to be correct.
    }
}
...