Object Recognition Using Yolov7 and TensorRT

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this tutorial we will use tensor RT with jets in agx Xavier tensor RT takes a trained Network which consists of a network definition and a set of trained parameters and produces a highly optimized runtime engine that performs inference for that Network it is particularly useful in indebted systems where computation capabilities are limited due to the size of the device let's see some features of tensor RT tensor RT is an SDK for deep learning inference developed by Nvidia it generates optimized runtime engine which enables increasing throughput and decreasing latency tensor RT performs five types of optimizations the first is weight and activation Precision Calibration by this optimization latency is reduced and it also gives a significant reduction in model size because float Point 32 Precision gets converted into float Point 16 or integer 8. the second is Fusion operations tensor RT uses layer and tensor Fusion to optimize GPU memory and bandwidth by fusing nodes in a kernel the third is Kernel Auto tuning tensor RT selects the best layers algorithms and optimal batch size based on the target GPU to Kernel specific optimization the fourth is dynamic tensor memory allocation tensor RT allocates memory to tensor only for the duration of its usage so it uses only minimum amount of memory required for the operation and the fifth is multiple stream execution this means that tensor RT can process multiple input streams in parallel in this tutorial we will build a tensor RT engine based on YOLO V7 go to the YOLO V7 page and clone the Repository after cloning the code return to the YOLO V7 page and download YOLO V7 weights after downloading the weights move the weights file to YOLO V7 folder to build RT engine we will use this repository so git clone it to build a tensor RT engine we need a WTS file WTS stands for weights to do this conversion we will need several libraries so we are going to install it first ly we are going to install pytorch the basic installation procedure is explained in this page copy this line and execute it then install the required libraries we will execute only a part of this line firstly update the PIP now install aohdtp numpy and scipy AO HTTP allows users to create asynchronous servers and clients for async i o skip installation of the pi torch at this point then upgrade the protobuf library protobaf is a binary message format created by Google and is efficient compared to other message formats like Json and XML we should also check which version of Pi torch is suitable for our jetpack version click here since we are using jetpack 5.02 it will work fine if you install one of these three Pi torch versions go back to the previous page copy this link here we have wheel files for pi torch versions download the wheel file suitable for you move the downloaded will file to the home directory copy the file name and execute the PIP 3 install command we also have to install torch Vision Library for installation of torch Vision we will use this page the link to the page is also in the description below all you have to do is just to copy and paste commands under the torch Vision label firstly install required libraries clone torch Vision version 0.14 note that you have to replace the version strings to actual version number you want to clone move to the torch Vision directory in this line build version variable is set to 0.14 by executing this command torch Vision build will begin we have successfully installed porch vision next install tqdm tqdm is a python library that allows you to Output a smart progress bar by wrapping around any iterable a tqdm progress bar not only shows you how much time has elapsed but also shows the estimated time remaining for the iterable install Seaborn Seabourn is a library for making statistical Graphics in Python it is built on top of matplotlib and closely integrated with pandas data structures install chew pie is an open source array library for GPU accelerated Computing with python shupai utilizes several Cuda toolkit libraries to make full use of the GPU architecture install lib Canberra gtk lib Canberra is a simple abstract interface for playing event sounds we have installed all required libraries the instructions of how to do build and execute tensor RT engines are written in readme file under YOLO V7 directory so we need to follow these instructions firstly move the Gen WTS file to the original YOLO V7 directory then open Terminal and execute genwts Pi script note that weights of the file we want to convert should be selected using command line arguments after waiting several minutes the YOLO V7 WTS file should be generated now move to the YOLO V7 folder under tensor RTX directory create a build folder and move to it firstly execute C make and then make Command since we are using YOLO V7 weights just copy and past this line building engine may take about 10 minutes we have successfully built the engine to do the inference task copy this line and execute it image result will be generated in the build directory now we are going to execute tensor RT using python copy from the build folder the engine file we have previously generated and place it in the YOLO V7 directory also create a sample folder and move images you want to use for the test now execute YOLO V7 trt Pi script the result images will be generated in the output folder now let's see what modifications we made to the original file to make it work with web camera in the original file the reference is done for all images in the directory but in our implementation there is always only one image that is camera frame so we don't need a for Loop here also there are some differences in the infer thread class in the original file we do inference for each image in the batch in our case first of all we Define video capture object and then we read each frame and do inference on it note that image size is changed from original image size to 640 by 480 pixel image size now let's execute our code open a terminal and execute the YOLO V7 trt cam script
Info
Channel: robot mania
Views: 5,511
Rating: undefined out of 5
Keywords: robotics, python, deep learning, nvidia, ROS
Id: NPCJF8YL2Gc
Channel Id: undefined
Length: 12min 43sec (763 seconds)
Published: Sat Dec 24 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.