Low Frame Rate in Real-Time Object Detection Example

I was following this tutorial for real-time object detection on the Jetson Nano: https://www.youtube.com/watch?v=bcM5AQSAzUY&list=PLldOcWjuNTu_yQcOvOO_ue8SxsjbqoLRP&index=13&t=1015s

I tried using both a Raspberry Pi Camera v2 and a Logitech C525 USB Camera. I was able to run the example fine using both cameras. However, in the video of the example the program was able to achieve a frame rate of 22 fps. When I ran the program, I only got it to run at 8 fps with the pi camera and 5 fps with the Logitech camera. What should I do to improve the frame rate?