Add script for inference FPS

Signed-off-by: Micaela Verucchi <micaelaverucchi@gmail.com>
This commit is contained in:
Micaela Verucchi
2020-06-11 16:09:01 +02:00
parent c4e955eab5
commit e094a3e0fc
2 changed files with 73 additions and 3 deletions
+51
View File
@@ -0,0 +1,51 @@
#!/bin/bash
function test_inference {
./test_$1
./test_rtinference $1_$2.rt 1
./test_rtinference $1_$2.rt 4
}
sudo jeston_clock
# modes=( 1 ) # only FP32
# modes=( 1 2 ) # FP32 and FP16
modes=( 1 2 3 ) # FP32, FP16 and INT8
rm times_rtinference.csv
for i in "${modes[@]}"
do
rm *rt
if [ $i -eq 1 ]
then
export TKDNN_MODE=FP32
mode=fp32
echo -e "${ORANGE}Test FP32${NC}"
fi
if [ $i -eq 2 ]
then
export TKDNN_MODE=FP16
mode=fp16
echo -e "${ORANGE}Test FP16${NC}"
fi
if [ $i -eq 3 ]
then
export TKDNN_MODE=INT8
export TKDNN_CALIB_LABEL_PATH=../demo/COCO_val2017/all_labels.txt
export TKDNN_CALIB_IMG_PATH=../demo/COCO_val2017/all_images.txt
mode=int8
echo -e "${ORANGE}Test INT8${NC}"
fi
export TKDNN_BATCHSIZE=4
echo -e "${ORANGE}Batch $TKDNN_BATCHSIZE ${NC}"
test_inference yolo4_320 $mode
test_inference yolo4_416 $mode
test_inference yolo4_512 $mode
test_inference yolo4_608 $mode
done
+22 -3
View File
@@ -18,6 +18,8 @@ int main(int argc, char *argv[]) {
//convert network to tensorRT
tk::dnn::NetworkRT netRT(NULL, argv[1]);
tk::dnn::dataDim_t idim = netRT.input_dim;
tk::dnn::dataDim_t odim = netRT.output_dim;
@@ -63,11 +65,28 @@ int main(int argc, char *argv[]) {
}
}
}
std::cout<<"Min: "<<*std::min_element(stats.begin(), stats.end())/BATCH_SIZE<<" ms\n";
std::cout<<"Max: "<<*std::max_element(stats.begin(), stats.end())/BATCH_SIZE<<" ms\n";
double min = *std::min_element(stats.begin(), stats.end())/BATCH_SIZE;
double max = *std::max_element(stats.begin(), stats.end())/BATCH_SIZE;
double mean =0;
for(int i=0; i<stats.size(); i++) mean += stats[i]; mean /= stats.size();
std::cout<<"Avg: "<<mean/BATCH_SIZE<<" ms\t"<<1000/(mean/BATCH_SIZE)<<" FPS\n"<<COL_END;
mean /=BATCH_SIZE;
std::cout<<"Min: "<<min<<" ms\n";
std::cout<<"Max: "<<max<<" ms\n";
std::cout<<"Avg: "<<mean<<" ms\t"<<1000/(mean)<<" FPS\n"<<COL_END;
std::ofstream times;
times.open("times_rtinference.csv", std::ios_base::app);
std::string net_name;
removePathAndExtension(argv[1], net_name);
times << net_name<< "_" << BATCH_SIZE << ";" << mean << ";" << min << ";" << max << ";" << 1000./mean << "\n";
times.close();
return ret_tensorrt;
}