# YOLO3 (Detection, Training, and Evaluation)
## Dataset and Model
Dataset | mAP | Config | Model | Demo
:---:|:---:|:---:|:---:|:---:
Kangaroo Detection (1 class) (https://github.com/experiencor/kangaroo) | 95% | check zoo | check zoo | https://youtu.be/URO3UDHvoLY
Raccoon Detection (1 class) (https://github.com/experiencor/raccoon_dataset) | 98% | check zoo | check zoo | https://youtu.be/lxLyLIL7OsU
Red Blood Cell Detection (3 classes) (https://github.com/experiencor/BCCD_Dataset) | 84% | check zoo | check zoo | https://imgur.com/a/uJl2lRI
VOC (20 classes) (http://host.robots.ox.ac.uk/pascal/VOC/voc2012/) | 72% | check zoo | check zoo | https://youtu.be/0RmOI6hcfBI
## Todo list:
- [x] Yolo3 detection
- [x] Yolo3 training (warmup and multi-scale)
- [x] mAP Evaluation
- [x] Multi-GPU training
- [x] Evaluation on VOC
- [ ] Evaluation on COCO
- [ ] MobileNet, DenseNet, ResNet, and VGG backends
## Detection
Grab the pretrained weights of yolo3 from https://pjreddie.com/media/files/yolov3.weights.
```python yolo3_one_file_to_detect_them_all.py -w yolo3.weights -i dog.jpg```
## Training
### 1. Data preparation
Download the Raccoon dataset from from https://github.com/experiencor/raccoon_dataset.
Organize the dataset into 4 folders:
+ train_image_folder <= the folder that contains the train images.
+ train_annot_folder <= the folder that contains the train annotations in VOC format.
+ valid_image_folder <= the folder that contains the validation images.
+ valid_annot_folder <= the folder that contains the validation annotations in VOC format.
There is a one-to-one correspondence by file name between images and annotations. If the validation set is empty, the training set will be automatically splitted into the training set and validation set using the ratio of 0.8.
### 2. Edit the configuration file
The configuration file is a json file, which looks like this:
```python
{
"model" : {
"min_input_size": 352,
"max_input_size": 448,
"anchors": [10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326],
"labels": ["raccoon"]
},
"train": {
"train_image_folder": "/home/andy/data/raccoon_dataset/images/",
"train_annot_folder": "/home/andy/data/raccoon_dataset/anns/",
"train_times": 10, # the number of time to cycle through the training set, useful for small datasets
"pretrained_weights": "", # specify the path of the pretrained weights, but it's fine to start from scratch
"batch_size": 16, # the number of images to read in each batch
"learning_rate": 1e-4, # the base learning rate of the default Adam rate scheduler
"nb_epoch": 50, # number of epoches
"warmup_epochs": 3, # the number of initial epochs during which the sizes of the 5 boxes in each cell is forced to match the sizes of the 5 anchors, this trick seems to improve precision emperically
"ignore_thresh": 0.5,
"gpus": "0,1",
"saved_weights_name": "raccoon.h5",
"debug": true # turn on/off the line that prints current confidence, position, size, class losses and recall
},
"valid": {
"valid_image_folder": "",
"valid_annot_folder": "",
"valid_times": 1
}
}
```
The ```labels``` setting lists the labels to be trained on. Only images, which has labels being listed, are fed to the network. The rest images are simply ignored. By this way, a Dog Detector can easily be trained using VOC or COCO dataset by setting ```labels``` to ```['dog']```.
Download pretrained weights for backend at:
https://1drv.ms/u/s!ApLdDEW3ut5fgQXa7GzSlG-mdza6
**This weights must be put in the root folder of the repository. They are the pretrained weights for the backend only and will be loaded during model creation. The code does not work without this weights.**
### 3. Generate anchors for your dataset (optional)
`python gen_anchors.py -c config.json`
Copy the generated anchors printed on the terminal to the ```anchors``` setting in ```config.json```.
### 4. Start the training process
`python train.py -c config.json`
By the end of this process, the code will write the weights of the best model to file best_weights.h5 (or whatever name specified in the setting "saved_weights_name" in the config.json file). The training process stops when the loss on the validation set is not improved in 3 consecutive epoches.
### 5. Perform detection using trained weights on image, set of images, video, or webcam
`python predict.py -c config.json -i /path/to/image/or/video`
It carries out detection on the image and write the image with detected bounding boxes to the same folder.
## Evaluation
`python evaluate.py -c config.json`
Compute the mAP performance of the model defined in `saved_weights_name` on the validation dataset defined in `valid_image_folder` and `valid_annot_folder`.
没有合适的资源?快使用搜索试试~ 我知道了~
yolo3物体检测源代码
共26个文件
py:15个
json:5个
h5:3个
5星 · 超过95%的资源 需积分: 50 387 下载量 79 浏览量
2018-05-09
17:03:21
上传
评论 28
收藏 35KB ZIP 举报
温馨提示
基于keras和tensorflow的物体检测python源代码,可以直接使用!
资源推荐
资源详情
资源评论
收起资源包目录
keras-yolo3-master.zip (26个子文件)
keras-yolo3-master
callbacks.py 3KB
.gitattributes 41B
train.py 10KB
utils
colors.py 2KB
utils.py 12KB
__init__.py 0B
bbox.py 3KB
multi_gpu_model.py 2KB
image.py 3KB
predict.py 5KB
yolo.py 19KB
generator.py 9KB
gen_anchors.py 4KB
yolo3_one_file_to_detect_them_all.py 18KB
config.json 1KB
README.md 5KB
voc.py 3KB
zoo
kangaroo.h5 134B
raccoon.h5 134B
config_voc.json 1KB
rbc.h5 134B
config_raccoon.json 1KB
config_kangaroo.json 1KB
config_rbc.json 1KB
evaluate.py 2KB
.gitignore 28B
共 26 条
- 1
TomHardy
- 粉丝: 2835
- 资源: 37
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页