Skip to content

add a simple warm_up in yolov5_trt.py#513

Merged
wang-xinyu merged 3 commits into
wang-xinyu:masterfrom
wwqgtxx:patch-2
Apr 28, 2021
Merged

add a simple warm_up in yolov5_trt.py#513
wang-xinyu merged 3 commits into
wang-xinyu:masterfrom
wwqgtxx:patch-2

Conversation

@wwqgtxx

@wwqgtxx wwqgtxx commented Apr 28, 2021

Copy link
Copy Markdown
Contributor

with warm_up:

dji@manifold2:~/yolov5/tensorrtx/yolov5$ python3 yolov5_trt.py build/yolov5s.engine
bingding: data (3, 640, 640)
bingding: prob (6001, 1, 1)
batch size is 1
warm_up->(1, 3, 640, 640), time->147.95ms
warm_up->(1, 3, 640, 640), time->89.42ms
warm_up->(1, 3, 640, 640), time->51.39ms
warm_up->(1, 3, 640, 640), time->31.86ms
warm_up->(1, 3, 640, 640), time->35.34ms
warm_up->(1, 3, 640, 640), time->36.08ms
warm_up->(1, 3, 640, 640), time->28.15ms
warm_up->(1, 3, 640, 640), time->30.32ms
warm_up->(1, 3, 640, 640), time->31.74ms
warm_up->(1, 3, 640, 640), time->28.30ms
input->['samples/bus.jpg'], time->29.53ms, saving into output/
input->['samples/zidane.jpg'], time->28.94ms, saving into output/

without warm_up:

dji@manifold2:~/yolov5/tensorrtx/yolov5$ python3 yolov5_trt.py
bingding: data (3, 640, 640)
bingding: prob (6001, 1, 1)
batch size is 1
input->['samples/bus.jpg'], time->86.08ms, saving into output/
input->['samples/zidane.jpg'], time->103.98ms, saving into output/

@wang-xinyu

Copy link
Copy Markdown
Owner

@wwqgtxx thanks, seems warmup is helpful on your device, and seems no need to warmup on my server. But can we not to modify the infer() function? I think it is not the best solution to add if-else condition in infer().

@wwqgtxx

wwqgtxx commented Apr 28, 2021

Copy link
Copy Markdown
Contributor Author

In my initial thoughts, I copy a new function from infer() to warm_up() but it has so many code repeat. Modify the infer() can share the exists code better, of cource, it maybe cause the normal infer process slower (a little bit?).

@wang-xinyu

Copy link
Copy Markdown
Owner

I think we can move imwrite() out of infer(), so that we can use the same infer() to do warmup.

like:

warmup:

infer(first_batch)
// without saving images

infer:

infer(batch)
save_result()

@wwqgtxx

wwqgtxx commented Apr 28, 2021

Copy link
Copy Markdown
Contributor Author

Another question is should we use the first_batch's image data to do warmup or specific use the all zeros data.
In origin yolov5's detect.py, it use an all zeros data https://github.com/ultralytics/yolov5/blob/v5.0/detect.py#L61 to do warmup
And I am not certain its affect.

@wang-xinyu

Copy link
Copy Markdown
Owner

I think it doesn't matter what's the data feed into network.

@wang-xinyu wang-xinyu merged commit b58a798 into wang-xinyu:master Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants