Tiny YOLO v2 with TensorRT

Hi.
I developed a very simple object detection application with TensorRT. This application downloads the tiny YOLO v2 model from Open Neural Network eXchange (ONNX) Model Zoo and converts it to NVIDIA TensorRT plan, then starts the object detection for camera captured image.

[url]https://github.com/tsutof/tiny_yolov2_onnx_cam[/url]

4 Likes

Hi, I have got your code running on my nano. However, I couldn’t connect the followed link:
https: //raw.githubusercontent.com/pjreddie/darknet/master/data/voc.names

Can you help me to solve this problem?

Thank you

Hi, Thank you for the contact.

I tested my application today and it download the file from the link without any problem.
My application just download the label file with the wget module. Please try the following on your Nano and check if it works.

$ python3
Python 3.6.9 (default, Nov  7 2019, 10:44:02) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import wget
>>> url='https://raw.githubusercontent.com/pjreddie/darknet/master/data/voc.names'
>>> wget.download(url)
100% [..............................................................] 135 / 135'voc.names'
1 Like

Hi, Thanks for your reply.
I have run the commands on my nano following your method. However, it still displayed an error, and the notice is as follows:

$ python3
Python 3.6.9 (default, Nov 7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import wget
url=‘https://raw.githubusercontent.com/pjreddie/darknet/master/data/voc.names
wget.download(url)
Traceback (most recent call last):
File “/usr/lib/python3.6/urllib/request.py”, line 1318, in do_open
encode_chunked=req.has_header(‘Transfer-encoding’))
File “/usr/lib/python3.6/http/client.py”, line 1254, in request
self._send_request(method, url, body, headers, encode_chunked)
File “/usr/lib/python3.6/http/client.py”, line 1300, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File “/usr/lib/python3.6/http/client.py”, line 1249, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File “/usr/lib/python3.6/http/client.py”, line 1036, in _send_output
self.send(msg)
File “/usr/lib/python3.6/http/client.py”, line 974, in send
self.connect()
File “/usr/lib/python3.6/http/client.py”, line 1407, in connect
super().connect()
File “/usr/lib/python3.6/http/client.py”, line 946, in connect
(self.host,self.port), self.timeout, self.source_address)
File “/usr/lib/python3.6/socket.py”, line 724, in create_connection
raise err
File “/usr/lib/python3.6/socket.py”, line 713, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “”, line 1, in
File “/home/limx59/.local/lib/python3.6/site-packages/wget.py”, line 526, in download
(tmpfile, headers) = ulib.urlretrieve(binurl, tmpfile, callback)
File “/usr/lib/python3.6/urllib/request.py”, line 248, in urlretrieve
with contextlib.closing(urlopen(url, data)) as fp:
File “/usr/lib/python3.6/urllib/request.py”, line 223, in urlopen
return opener.open(url, data, timeout)
File “/usr/lib/python3.6/urllib/request.py”, line 526, in open
response = self._open(req, data)
File “/usr/lib/python3.6/urllib/request.py”, line 544, in _open
‘_open’, req)
File “/usr/lib/python3.6/urllib/request.py”, line 504, in _call_chain
result = func(*args)
File “/usr/lib/python3.6/urllib/request.py”, line 1361, in https_open
context=self._context, check_hostname=self._check_hostname)
File “/usr/lib/python3.6/urllib/request.py”, line 1320, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 111] Connection refused>

Thank you for the report.
I suppose that you are accessing the URL from behind a firewall.
If so, you need to set proxy settings on your Nano.
I think you can use the https_proxy environment variable for it.

I can access the Github website normally, but when I access raw on github.com, it also prompts an error.

Or do I need to disable my nano’s firewalld?

I have just tried to access the link on my laptop, and it seems that the link is available. I will try it on my nano later.

aeroplane
bicycle
bird
boat
bottle
bus
car
cat
chair
cow
diningtable
dog
horse
motorbike
person
pottedplant
sheep
sofa
train
tvmonitor

Thank you!

Hi.
I’m not familiar with firewall.
Manual download of the label file and ONNX model is easy solution.
If my program detects those files locally, it doesn’t try to dowonload.
Thanks.

Thanks very much for the reply, the problem of downloading has been solved, it seems that it is because of the problem of accessing github websit, and now there is currently an error of starting the camera. The prompt message is as follows. The camera I use is not a Raspberry Pi camera, but a CSI camera of IMX219-160. I want to confirm whether the CSI camera must be a RaspberryPi camera v2. Thank you!

GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connected…
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 3280 x 2464 FR = 21.000000 fps Duration = 47619048 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 3280 x 1848 FR = 28.000001 fps Duration = 35714284 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1920 x 1080 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1280 x 720 FR = 59.999999 fps Duration = 16666667 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: 1280 x 720 FR = 120.000005 fps Duration = 8333333 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;

GST_ARGUS: Running with following settings:
Camera index = 0
Camera mode = 4
Output Stream W = 1280 H = 720
seconds to Run = 0
Frame Rate = 120.000005
GST_ARGUS: PowerService: requested_clock_Hz=6048000
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
Reading engine from file model.trt
./setup.sh: line 11: 13951 Segmentation fault (core dumped) python3 tiny_yolov2_onnx_cam.py --camera -1

Hi.
I’m not sure if other CSI camera models works on my application.
I suppose that you can edit the GStreamer pipeline defined at GST_STR_CSI to support your camera.
But I think you need to find which line in the source code, triggers the failure at first.