theAIGuysCode / yolov4-custom-functions

A Wide Range of Custom Functions for YOLOv4, YOLOv4-tiny, YOLOv3, and YOLOv3-tiny Implemented in TensorFlow, TFLite, and TensorRT.
MIT License
602 stars 370 forks source link

--info-function with time measurement #14

Open newbie2X opened 4 years ago

newbie2X commented 4 years ago

Hi there,

first of all, thx for ur work. Thru you i started with python. And now i try to learn more about DL and object detection.

Now i wanna test out how much slower the object detection on my GPU is in comparision to the GPU from Google Colab. In your Colab tutorials u implemented a time measurment for the object detection.

Can u give me a advice how i can implement such a thin in this --info function?

theAIGuysCode commented 4 years ago

For sure, it is actually fairly straightforward. You will just want to use the time.time() function which grabs the current time at any given moment.

start = time.time() # add this line wherever you want to start the timer
end = time.time() # add this wherever you want to stop the timer

total_time = end - start # will give you time taken in milliseconds I believe

Just make sure to add the start and end lines in the proper places within detect.py (this is implemented in detect_video.py so check it out if you get stuck).

Hope this helps and good luck!

newbie2X commented 4 years ago

Thank you very much, it worked nicely. I measure the time im from line 74 to 95 within detect.py. The picture detection speed matches the video detection speed, so all good. My GPU is roughly halve as fast as the Colab GPU.

But what i dont understand is, why is the first frame/picture detection so much slower then all the frames/pictures afterwards? The first picture/frame takes couple of seconds to get detected, after that the speed is around 60ms.

I guess its because of the data transition from my harddrive to my GPU?