In 2014 Joseph Redmon started working on Darknet, the backbone of YOLO,
a real-time object detector model. He created a C++/CUDA implementation
that remained “official” for a few years. A couple months back he
stopped working on the project altogether over privacy concerns.
Over time several forks have spawned, with AlexeyAB’s one
gaining the spotlight. The fork, daily maintained, added several
features (Windows support, half-precision, additional layers, etc) and
gathered a rich list of models and variants. Thanks to constant
attention and improvements, Darknet/YOLO remains one of the benchmarks
for its problem category.
At
the end of April 2020, Alexey and his team released the next iteration
of Yolo, which improves both AP and FPS of YOLOv3 by about 10%.
With
the system configuration behind us, we can now work on YOLO. Luckily
for us, the Nvidia image ships with CUDA 10 and OpenCV 4.1.1 already
installed: this saves us at least 1h of compilation time and plenty of
headaches…
As explained above, you need OpenCV, Cuda, etc. software to build YOLOv4. All of these software are already installed in JetPack 4.4 that we will use.
The first method is to use CMake. To use this method, you must upgrade the version of CMake installed in JetPack 4.4. CMake 3.12 or higher is required to install YOLOv4, but JetPack 4.4 provides version 3.10.2 of CMake.
And the next method is to compile the source code immediately after modifying the Makefile.
Now, after downloading the source code from gitgub, we will compile.
First, download the codes.
git clone https://github.com/AlexeyAB/darknet.git
cd darknet
Next, modify the Makefile as follows. We will use Jetson Nano's GPU, so enable GPU options. We also use Cuda and OpenCV, so enable the CUDNN and OPENCV options. OPENMP improves execution speed through parallel processing in a multi-CPU environment, so enable this option too. LIBSO option builds libdarknet.so file that is necessary for python programming, so enable it too. Last thing you must do is changing the ARCH parameter that defines CPU architecture.
As with the darknet executable above, after loading the model, search for the image of the ./data/dog.jpg file.
root@jetpack-4:/usr/local/src/darknet# python3 darknet.py detector testTry to load cfg: ./cfg/yolov4.cfg, weights: ./weights/yolov4.weights, clear= 0
0 : compute_capability= 530, cudnn_half= 0, GPU: NVIDIA Tegra X1
net.optimized_memory = 0
mini_batch= 1, batch= 8, time_steps= 1, train= 0
layer filters size/strd(dil) input output
0 conv 32 3 x 3/ 1 608 x 608 x 3 -> 608 x 608 x 32 0.639 BF
1 conv 64 3 x 3/ 2 608 x 608 x 32 -> 304 x 304 x 64 3.407 BF
2 conv 64 1 x 1/ 1 304 x 304 x 64 -> 304 x 304 x 64 0.757 BF
3 route 1 -> 304 x 304 x 64
4 conv 64 1 x 1/ 1 304 x 304 x 64 -> 304 x 304 x 64 0.757 BF
5 conv 32 1 x 1/ 1 304 x 304 x 64 -> 304 x 304 x 32 0.379 BF
6 conv 64 3 x 3/ 1 304 x 304 x 32 -> 304 x 304 x 64 3.407 BF
7 Shortcut Layer: 4, wt= 0, wn= 0, outputs: 304 x 304 x 64 0.006 BF
8 conv 64 1 x 1/ 1 304 x 304 x 64 -> 304 x 304 x 64 0.757 BF
9 route 8 2 -> 304 x 304 x 128
....
....
....
[yolo] params: iou loss: ciou (4), iou_norm: 0.07, cls_norm: 1.00, scale_x_y: 1.05
nms_kind: greedynms (1), beta= 0.600000
Total BFLOPS 128.459
avg_outputs= 1068395
Allocate additional workspace_size= 106.46 MB
Try to load weights: ./weights/yolov4.weights
Loading weights from ./weights/yolov4.weights...
seen 64, trained: 32032 K-images (500 Kilo-batches_64)
Done! Loaded 162 layers from weights-file
Loaded - names_list: data/coco.names, classes= 80
Unable to show image: No module named 'skimage'[('dog', 0.9787506461143494, (220.9882049560547, 383.2079772949219, 184.41786193847656, 316.509033203125)), ('bicycle', 0.9217984080314636, (343.4819641113281, 276.87603759765625, 458.06488037109375, 298.71209716796875)), ('truck', 0.9183095097541809, (574.2606201171875, 123.24830627441406, 220.67367553710938, 93.20551300048828)), ('pottedplant', 0.33072125911712646, (699.326416015625, 131.88845825195312, 36.53395080566406, 45.44673538208008))]
Since we haven't installed the skimage package yet, it doesn't print, but the console output shows that there is a dog, a bike, a truck, and a potted plant.
<darknet/data/dog.jpg>
In YOLO, Python programs load and use C-coded so files directly for faster processing speed.
Wrapping up
So far, we have seen how to install YOLOv4 on Jetson Nano and have tested it simply. Next time, I'll create Python code that I can use for my purposes.
댓글 없음:
댓글 쓰기