FrederikARVOO

Untitled

Jul 11th, 2019
494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. #include "../network_config.h"
  2. #include "../trt_utils.h"
  3. #include "../yolov3-tiny.h"
  4. #include "../yolo.h"
  5.  
  6. #include <fstream>
  7. #include <iterator>
  8. #include <vector>
  9.  
  10. using namespace std;
  11.  
  12. int main(int argc, char** argv) {
  13.     ifstream inputStream( "input.raw", ios::binary);
  14.     vector<unsigned char> input(istreambuf_iterator<char>(inputStream), {});
  15.  
  16.     Yolo* m_inferNet(new YoloV3Tiny("custom_model.engine", 16, 0.5));
  17.  
  18.     m_inferNet->doInference(input.data());
  19.  
  20.     struct timeval inferStart, inferEnd;
  21.         gettimeofday(&inferStart, NULL);
  22.  
  23.     for (int j = 0; j < 50; j++) {
  24.         m_inferNet->doInference(input.data());
  25.  
  26.         for (int i = 0; i < m_batchSize; i++) {
  27.             auto binfo = m_inferNet->decodeDetections(i, 1080, 1920);
  28.             auto remaining = nonMaximumSuppression(m_inferNet->getNMSThresh(), binfo);
  29.         }
  30.     }
  31.  
  32.     gettimeofday(&inferEnd, NULL);
  33.     double inferElapsed = ((inferEnd.tv_sec - inferStart.tv_sec) +
  34.         (inferEnd.tv_usec - inferStart.tv_usec) / 1000000.0) * 1000 /
  35.         (50 * 16);
  36.  
  37.     cout << "Took " << inferElapsed << "ms per image" << endl;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment