Object Detection with Pytorch

Hello
I’m a beginner in DNN. I’m using Jetson Nano.
I managed to do transfer learning on a ResNet-18 model with my custom dataset for object detection. It seems quite straight forward with Pytorch.

What I’m struggling with is the deployment of my model.

My question is simple: Is it possible to deploy the model that I trained in Pytorch and run object detection inference on it? Or do I absolutely need to export it to some other format such as Caffe?

It it is possible to do it in Pytorch, and if so, is there a sample code in Python?

Thanks!

if you are using Jetson Nano, you can directly run the model trained in PyTorch on the Nano.

If you want to speed the model up on Nano, you can use something like https://github.com/NVIDIA-AI-IOT/torch2trt to offload part of the model to TensorRT

here are links to pytorch binaries on Jetson platforms: https://github.com/pytorch/pytorch#nvidia-jetson-platforms

hey thanks for a quick reply smth.
When you say “if you are using Jetson Nano, you can directly run the model trained in PyTorch on the Nano.” what libraries/modules shall I use?
Do you mean I have to use the .pth file without converting it to ONNX? Could you be a bit more specific?

just use pytorch directly, without converting to ONNX. it runs on jetson nano.

That’s great to know that it’s possible!!
Could you direct me to a specific snippet, piece of code or something written in Python so I can take it from there?

seems like you already have some code?

either ways, feel free to use something like https://pytorch.org/hub/pytorch_vision_deeplabv3_resnet101/

there might be some samples at https://github.com/NVIDIA-AI-IOT

I took the code from Jetson Inference examples, which was meant for transfer learning and used it to train on my dataset.
But I didn’t have any code to run the inference.
I will look into the code you sent me. I really appreciate it!!

Hi Smth. I tried DEEPLABV3-RESNET101. It works very well!
Except this is segmentation, and I don’t know how to build a bounding box around the drawn mask over the detected object.

Could you please show me an example that actually draws the bounding boxes around the detected object?

Thanks again!!

I just realized that Resnet18 is not for object detection but for image classification.
Since I need Object Detection, I will have to write a new script to train for instance Faster RCNN.