---
title: 影像辨識 - YOLO
tags: self-learning, YOLO, opencv
---
{%hackmd BkVfcTxlQ %}
# **_影像辨識 - YOLO_**
> [name=BessyHuang] [time=Sat, Apr 4, 2020]
# **課程大綱**
[TOC]
:::warning
**_Reference:_**
* [YOLO 官網](https://pjreddie.com/darknet/yolo/)
* [Tutorial: Build an object detection system using YOLO](https://mc.ai/tutorial-build-an-object-detection-system-using-yolo/#8895)
* [A Gentle Introduction to YOLO v4 for Object detection in Ubuntu 20.04](https://robocademy.com/2020/05/01/a-gentle-introduction-to-yolo-v4-for-object-detection-in-ubuntu-20-04/)
* [largitdata/code/Course_126.ipynb](https://github.com/ywchiu/largitdata/blob/master/code/Course_126.ipynb); [Youtube - [深度學習] 如何使用 YOLO 製作即時口罩檢測系統(一) - YOLO簡介?](https://www.youtube.com/watch?v=vGhIhitQHBE)
* [Tkinter: renamings and reorganizations of the standard library](http://python3porting.com/stdlib.html)
* [Opencv](https://docs.opencv.org/master/d2/de6/tutorial_py_setup_in_ubuntu.html)
:::
---
## **基本安裝、設定與測試**
1. Open Terminal and enter the following lines:
```
$ mkdir yolo_test
$ cd yolo_test/
$ git clone https://github.com/pjreddie/darknet
$ cd darknet
$ make
```
> [`make` 的功能:可以簡化編譯過程裡面所下達的指令。](http://linux.vbird.org/linux_basic/0520source_code_and_tarball.php#make)
> `make` 會去`讀取 makefile 的內容`,並根據內容直接去給他編譯相關的檔案!
>
* Run `./darknet` , Output => `usage: ./darknet <function>`
2. Using GPU for training and have CUDA configured correctly
```
$ gedit Makefile
```
* Then, set `GPU=1`, save the file, and run `make` again.
```
$ sed -i "s/GPU=0/GPU=1/g" darknet/Makefile
```
* Remember to run make every time you make changes to files!
3. Testing YOLO
```
$ wget https://pjreddie.com/media/files/yolov3.weights
$ ./darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg
```
* A visualization should be saved as `predictions.jpg` in your Darknet directory.
![](https://i.imgur.com/mf1BQ3N.jpg)
* Example
```
$ wget https://pjreddie.com/media/files/yolov3.weights
$ ./darknet detect cfg/yolov3.cfg yolov3.weights data/111.jpg
```
![](https://i.imgur.com/qEXYIfZ.jpg)
![](https://i.imgur.com/L8bRXoi.jpg)
---
## **進階:訓練自己的 Model**
* [Tool: LabelImg](https://github.com/tzutalin/labelImg)
* [[機器學習 ML NOTE]YOLO!!!如何簡單使用YOLO訓練出自己的物件偵測!!! (Windows+Anaconda)](https://medium.com/%E9%9B%9E%E9%9B%9E%E8%88%87%E5%85%94%E5%85%94%E7%9A%84%E5%B7%A5%E7%A8%8B%E4%B8%96%E7%95%8C/%E6%A9%9F%E5%99%A8%E5%AD%B8%E7%BF%92-ml-note-yolo-%E5%88%A9%E7%94%A8%E5%BD%B1%E5%83%8F%E8%BE%A8%E8%AD%98%E5%81%9A%E7%89%A9%E4%BB%B6%E5%81%B5%E6%B8%AC-object-detection-%E7%9A%84%E6%8A%80%E8%A1%93-3ad34a4cac70)
* [Yolo實作教學 — train出屬於自己的model使用darkflow (windows)](https://medium.com/@wayne18308/yolo%E5%AF%A6%E4%BD%9C%E6%95%99%E5%AD%B8-train%E5%87%BA%E5%B1%AC%E6%96%BC%E8%87%AA%E5%B7%B1%E7%9A%84model%E4%BD%BF%E7%94%A8darkflow-windows-9b633b7350d8)
* [【AI_Column】如何以YOLOv3訓練自己的資料集 ─ 以小蕃茄為例](https://makerpro.cc/2019/12/train-your-dataset-with-yolov3/)