Small change to demo to allow bench marking without showing window and ability to run directly from terminal. #24
@@ -17,9 +17,10 @@ M. Verucchi, L. Bartoli, F. Bagni, F. Gatti, P. Burgio and M. Bertogna, "Real-Ti
|
|||||||
- [2)Export weights for DLA34 and ResNet101](#2export-weights-for-dla34-and-resnet101)
|
- [2)Export weights for DLA34 and ResNet101](#2export-weights-for-dla34-and-resnet101)
|
||||||
- [3)Export weights for CenterNet](#3export-weights-for-centernet)
|
- [3)Export weights for CenterNet](#3export-weights-for-centernet)
|
||||||
- [4)Export weights for MobileNetSSD](#4export-weights-for-mobilenetssd)
|
- [4)Export weights for MobileNetSSD](#4export-weights-for-mobilenetssd)
|
||||||
- [Run the demo](#run-the-demo)
|
- [How to convert weights](#how-to-convert-weights)
|
||||||
- [FP16 inference](#fp16-inference)
|
- [FP16 inference](#fp16-inference)
|
||||||
- [INT8 inference](#int8-inference)
|
- [INT8 inference](#int8-inference)
|
||||||
|
- [Run the demo](#run-the-demo)
|
||||||
- [mAP demo](#map-demo)
|
- [mAP demo](#map-demo)
|
||||||
- [Existing tests and supported networks](#existing-tests-and-supported-networks)
|
- [Existing tests and supported networks](#existing-tests-and-supported-networks)
|
||||||
- [References](#references)
|
- [References](#references)
|
||||||
@@ -113,26 +114,8 @@ cd pytorch-ssd
|
|||||||
conda env create -f env_mobv2ssd.yml
|
conda env create -f env_mobv2ssd.yml
|
||||||
python run_ssd_live_demo.py mb2-ssd-lite <pth-model-fil> <labels-file>
|
python run_ssd_live_demo.py mb2-ssd-lite <pth-model-fil> <labels-file>
|
||||||
```
|
```
|
||||||
## Run the demo
|
|
||||||
|
|
||||||
To run the an object detection demo follow these steps (example with yolov3):
|
## How to convert weights
|
||||||
```
|
|
||||||
rm yolo3_fp32.rt # be sure to delete(or move) old tensorRT files
|
|
||||||
./test_yolo3 # run the yolo test (is slow)
|
|
||||||
./demo yolo3_fp32.rt ../demo/yolo_test.mp4 y
|
|
||||||
```
|
|
||||||
In general the demo program takes 4 parameters:
|
|
||||||
```
|
|
||||||
./demo <network-rt-file> <path-to-video> <kind-of-network> <number-of-classes>
|
|
||||||
```
|
|
||||||
where
|
|
||||||
* ```<network-rt-file>``` is the rt file generated by a test
|
|
||||||
* ```<<path-to-video>``` is the path to a video file or a camera input
|
|
||||||
* ```<kind-of-network>``` is the type of network. Thee types are currently supported: ```y``` (YOLO family), ```c``` (CenterNet family) and ```m``` (MobileNet-SSD family)
|
|
||||||
* ```<number-of-classes>```is the number of classes the network is trained on
|
|
||||||
N.b. By default it is used FP32 inference
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
### FP16 inference
|
### FP16 inference
|
||||||
|
|
||||||
@@ -187,6 +170,29 @@ rm yolo3_fp32.rt # be sure to delete(or move) old tensorRT fil
|
|||||||
./test_rtinference yolo3_fp32.rt 4 # test with a batch size of 4
|
./test_rtinference yolo3_fp32.rt 4 # test with a batch size of 4
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Run the demo
|
||||||
|
|
||||||
|
To run the an object detection demo follow these steps (example with yolov3):
|
||||||
|
```
|
||||||
|
rm yolo3_fp32.rt # be sure to delete(or move) old tensorRT files
|
||||||
|
./test_yolo3 # run the yolo test (is slow)
|
||||||
|
./demo yolo3_fp32.rt ../demo/yolo_test.mp4 y # add parameter y for yolo. c for CNET & m for Mobilenet.
|
||||||
|
./demo yolo3_fp32.rt ../demo/yolo_test.mp4 y 1 #if number of classes not 80. Add class number parameter.
|
||||||
|
```
|
||||||
|
In general the demo program takes 5 parameters:
|
||||||
|
```
|
||||||
|
./demo <network-rt-file> <path-to-video> <kind-of-network> <number-of-classes> <output-type>
|
||||||
|
```
|
||||||
|
where
|
||||||
|
* ```<network-rt-file>``` is the rt file generated by a test
|
||||||
|
* ```<<path-to-video>``` is the path to a video file or a camera input
|
||||||
|
* ```<kind-of-network>``` is the type of network. Thee types are currently supported: ```y``` (YOLO family), ```c``` (CenterNet family) and ```m``` (MobileNet-SSD family)
|
||||||
|
* ```<number-of-classes>```is the number of classes the network is trained on
|
||||||
|
N.b. By default it is used FP32 inference
|
||||||
|
* ```<output-type>``` benchmark or save_result. Adding benchmark will not show opencv detection video allowing demo to be run from terminal, providing performance results without showing the video. Adding save_result will save output of detection to results.mp4.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## mAP demo
|
## mAP demo
|
||||||
|
|
||||||
To compute mAP, precision, recall and f1score, run the map_demo.
|
To compute mAP, precision, recall and f1score, run the map_demo.
|
||||||
|
|||||||
+16
-4
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
bool gRun;
|
bool gRun;
|
||||||
bool SAVE_RESULT = false;
|
bool SAVE_RESULT = false;
|
||||||
|
bool BENCHMARK = false;
|
||||||
|
|
||||||
void sig_handler(int signo) {
|
void sig_handler(int signo) {
|
||||||
std::cout<<"request gateway stop\n";
|
std::cout<<"request gateway stop\n";
|
||||||
@@ -33,7 +34,13 @@ int main(int argc, char *argv[]) {
|
|||||||
ntype = argv[3][0];
|
ntype = argv[3][0];
|
||||||
int n_classes = 80;
|
int n_classes = 80;
|
||||||
if(argc > 4)
|
if(argc > 4)
|
||||||
n_classes = atoi(argv[4]);
|
n_classes = atoi(argv[4]);
|
||||||
|
if(argc > 5 && strcmp(argv[5], "benchmark") == 0) {
|
||||||
|
BENCHMARK = true;
|
||||||
|
}
|
||||||
|
if(argc > 5 && strcmp(argv[5], "save_result") == 0) {
|
||||||
|
SAVE_RESULT = true;
|
||||||
|
}
|
||||||
|
|
||||||
tk::dnn::Yolo3Detection yolo;
|
tk::dnn::Yolo3Detection yolo;
|
||||||
tk::dnn::CenternetDetection cnet;
|
tk::dnn::CenternetDetection cnet;
|
||||||
@@ -76,8 +83,9 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
cv::Mat frame;
|
cv::Mat frame;
|
||||||
cv::Mat dnn_input;
|
cv::Mat dnn_input;
|
||||||
|
if(!BENCHMARK) {
|
||||||
cv::namedWindow("detection", cv::WINDOW_NORMAL);
|
cv::namedWindow("detection", cv::WINDOW_NORMAL);
|
||||||
|
}
|
||||||
std::vector<tk::dnn::box> detected_bbox;
|
std::vector<tk::dnn::box> detected_bbox;
|
||||||
|
|
||||||
while(gRun) {
|
while(gRun) {
|
||||||
@@ -91,9 +99,13 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
//inference
|
//inference
|
||||||
detNN->update(dnn_input);
|
detNN->update(dnn_input);
|
||||||
|
if(!BENCHMARK) {
|
||||||
frame = detNN->draw(frame);
|
frame = detNN->draw(frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!BENCHMARK) {
|
||||||
cv::imshow("detection", frame);
|
cv::imshow("detection", frame);
|
||||||
|
}
|
||||||
cv::waitKey(1);
|
cv::waitKey(1);
|
||||||
if(SAVE_RESULT)
|
if(SAVE_RESULT)
|
||||||
resultVideo << frame;
|
resultVideo << frame;
|
||||||
@@ -106,9 +118,9 @@ int main(int argc, char *argv[]) {
|
|||||||
std::cout<<"Min: "<<*std::min_element(detNN->stats.begin(), detNN->stats.end())<<" ms\n";
|
std::cout<<"Min: "<<*std::min_element(detNN->stats.begin(), detNN->stats.end())<<" ms\n";
|
||||||
std::cout<<"Max: "<<*std::max_element(detNN->stats.begin(), detNN->stats.end())<<" ms\n";
|
std::cout<<"Max: "<<*std::max_element(detNN->stats.begin(), detNN->stats.end())<<" ms\n";
|
||||||
for(int i=0; i<detNN->stats.size(); i++) mean += detNN->stats[i]; mean /= detNN->stats.size();
|
for(int i=0; i<detNN->stats.size(); i++) mean += detNN->stats[i]; mean /= detNN->stats.size();
|
||||||
std::cout<<"Avg: "<<mean<<" ms\n"<<COL_END;
|
std::cout<<"Avg: "<<mean<<" ms\n";
|
||||||
|
std::cout<<"Avg FPS: " << 1000 / mean <<COL_END;
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user