# PyTorch-YOLOv3
A minimal PyTorch implementation of YOLOv3, with support for training, inference and evaluation.
## Installation
##### Clone and install requirements
$ git clone https://github.com/eriklindernoren/PyTorch-YOLOv3
$ cd PyTorch-YOLOv3/
$ sudo pip3 install -r requirements.txt
##### Download pretrained weights
$ cd weights/
$ bash download_weights.sh
##### Download COCO
$ cd data/
$ bash get_coco_dataset.sh
## Test
Evaluates the model on COCO test.
$ python3 test.py --weights_path weights/yolov3.weights
| Model | mAP (min. 50 IoU) |
| ----------------------- |:-----------------:|
| YOLOv3 608 (paper) | 57.9 |
| YOLOv3 608 (this impl.) | 57.3 |
| YOLOv3 416 (paper) | 55.3 |
| YOLOv3 416 (this impl.) | 55.5 |
## Inference
Uses pretrained weights to make predictions on images. Below table displays the inference times when using as inputs images scaled to 256x256. The ResNet backbone measurements are taken from the YOLOv3 paper. The Darknet-53 measurement marked shows the inference time of this implementation on my 1080ti card.
| Backbone | GPU | FPS |
| ----------------------- |:--------:|:--------:|
| ResNet-101 | Titan X | 53 |
| ResNet-152 | Titan X | 37 |
| Darknet-53 (paper) | Titan X | 76 |
| Darknet-53 (this impl.) | 1080ti | 74 |
$ python3 detect.py --image_folder data/samples/
<p align="center"><img src="assets/giraffe.png" width="480"\></p>
<p align="center"><img src="assets/dog.png" width="480"\></p>
<p align="center"><img src="assets/traffic.png" width="480"\></p>
<p align="center"><img src="assets/messi.png" width="480"\></p>
## Train
```
$ train.py [-h] [--epochs EPOCHS] [--batch_size BATCH_SIZE]
[--gradient_accumulations GRADIENT_ACCUMULATIONS]
[--model_def MODEL_DEF] [--data_config DATA_CONFIG]
[--pretrained_weights PRETRAINED_WEIGHTS] [--n_cpu N_CPU]
[--img_size IMG_SIZE]
[--checkpoint_interval CHECKPOINT_INTERVAL]
[--evaluation_interval EVALUATION_INTERVAL]
[--compute_map COMPUTE_MAP]
[--multiscale_training MULTISCALE_TRAINING]
```
#### Example (COCO)
To train on COCO using a Darknet-53 backend pretrained on ImageNet run:
```
$ python3 train.py --data_config config/coco.data --pretrained_weights weights/darknet53.conv.74
```
#### Training log
```
---- [Epoch 7/100, Batch 7300/14658] ----
+------------+--------------+--------------+--------------+
| Metrics | YOLO Layer 0 | YOLO Layer 1 | YOLO Layer 2 |
+------------+--------------+--------------+--------------+
| grid_size | 16 | 32 | 64 |
| loss | 1.554926 | 1.446884 | 1.427585 |
| x | 0.028157 | 0.044483 | 0.051159 |
| y | 0.040524 | 0.035687 | 0.046307 |
| w | 0.078980 | 0.066310 | 0.027984 |
| h | 0.133414 | 0.094540 | 0.037121 |
| conf | 1.234448 | 1.165665 | 1.223495 |
| cls | 0.039402 | 0.040198 | 0.041520 |
| cls_acc | 44.44% | 43.59% | 32.50% |
| recall50 | 0.361111 | 0.384615 | 0.300000 |
| recall75 | 0.222222 | 0.282051 | 0.300000 |
| precision | 0.520000 | 0.300000 | 0.070175 |
| conf_obj | 0.599058 | 0.622685 | 0.651472 |
| conf_noobj | 0.003778 | 0.004039 | 0.004044 |
+------------+--------------+--------------+--------------+
Total Loss 4.429395
---- ETA 0:35:48.821929
```
#### Tensorboard
Track training progress in Tensorboard:
* Initialize training
* Run the command below
* Go to http://localhost:6006/
```
$ tensorboard --logdir='logs' --port=6006
```
## Train on Custom Dataset
#### Custom model
Run the commands below to create a custom model definition, replacing `<num-classes>` with the number of classes in your dataset.
```
$ cd config/ # Navigate to config dir
$ bash create_custom_model.sh <num-classes> # Will create custom model 'yolov3-custom.cfg'
```
#### Classes
Add class names to `data/custom/classes.names`. This file should have one row per class name.
#### Image Folder
Move the images of your dataset to `data/custom/images/`.
#### Annotation Folder
Move your annotations to `data/custom/labels/`. The dataloader expects that the annotation file corresponding to the image `data/custom/images/train.jpg` has the path `data/custom/labels/train.txt`. Each row in the annotation file should define one bounding box, using the syntax `label_idx x_center y_center width height`. The coordinates should be scaled `[0, 1]`, and the `label_idx` should be zero-indexed and correspond to the row number of the class name in `data/custom/classes.names`.
#### Define Train and Validation Sets
In `data/custom/train.txt` and `data/custom/valid.txt`, add paths to images that will be used as train and validation data respectively.
#### Train
To train on the custom dataset run:
```
$ python3 train.py --model_def config/yolov3-custom.cfg --data_config config/custom.data
```
Add `--pretrained_weights weights/darknet53.conv.74` to train using a backend pretrained on ImageNet.
## Credit
### YOLOv3: An Incremental Improvement
_Joseph Redmon, Ali Farhadi_ <br>
**Abstract** <br>
We present some updates to YOLO! We made a bunch
of little design changes to make it better. We also trained
this new network that’s pretty swell. It’s a little bigger than
last time but more accurate. It’s still fast though, don’t
worry. At 320 × 320 YOLOv3 runs in 22 ms at 28.2 mAP,
as accurate as SSD but three times faster. When we look
at the old .5 IOU mAP detection metric YOLOv3 is quite
good. It achieves 57.9 AP50 in 51 ms on a Titan X, compared
to 57.5 AP50 in 198 ms by RetinaNet, similar performance
but 3.8× faster. As always, all the code is online at
https://pjreddie.com/yolo/.
[[Paper]](https://pjreddie.com/media/files/papers/YOLOv3.pdf) [[Project Webpage]](https://pjreddie.com/darknet/yolo/) [[Authors' Implementation]](https://github.com/pjreddie/darknet)
```
@article{yolov3,
title={YOLOv3: An Incremental Improvement},
author={Redmon, Joseph and Farhadi, Ali},
journal = {arXiv},
year={2018}
}
```
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
毕设&课设&项目&实训-基于4种轻量级深度卷积网络的无场景约束全自动车牌识别,轻量级车牌检测,轻量级车牌识别,pyqt5可视化界面 【项目资源】: 包含前端、后端、移动开发、操作系统、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源、音视频、网站开发等各种技术项目的源码。 包括STM32、ESP8266、PHP、QT、Linux、iOS、C++、Java、python、web、C#、EDA、proteus、RTOS等项目的源码。 【项目质量】: 所有源码都经过严格测试,可以直接运行。 功能在确认正常工作后才上传。 【适用人群】: 适用于希望学习不同技术领域的小白或进阶学习者。 可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。 【附加价值】: 项目具有较高的学习借鉴价值,也可直接拿来修改复刻。 对于有一定基础或热衷于研究的人来说,可以在这些基础代码上进行修改和扩展,实现其他功能。 【沟通交流】: 有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 鼓励下载和使用,并欢迎大家互相学习,共同进步。
资源推荐
资源详情
资源评论
收起资源包目录
毕设&课设&项目&实训-基于4种轻量级深度卷积网络的无场景约束全自动车牌识别.zip (159个子文件)
yolov3.cfg 8KB
car.cfg 2KB
yolov3-tiny.cfg 2KB
car.data 133B
coco.data 115B
custom.data 99B
.gitignore 104B
LPRNet_Pytorch-master.iml 536B
PyTorch-YOLOv3.iml 453B
Vehicle-Car-detection-and-multilabel-classification.iml 453B
Pytorch_Retina_License_Plate-master.iml 453B
ui.JPG 438KB
test_3.jpg 393KB
test_0.jpg 366KB
test_0.jpg 161KB
test_0.jpg 161KB
0.jpg 130KB
8.JPG 76KB
3.jpg 61KB
3.jpg 58KB
0.jpg 55KB
6.jpg 42KB
12.jpg 41KB
icon1.jpg 40KB
8.jpg 39KB
test_1.jpg 37KB
14.jpg 37KB
0.jpg 37KB
14.jpg 37KB
11.jpg 34KB
che2.jpg 31KB
che3.jpg 30KB
0.jpg 24KB
13.JPG 23KB
che.jpg 22KB
1.jpg 17KB
4.JPG 13KB
2.jpg 6KB
3.jpg 4KB
4.jpg 4KB
6.jpg 3KB
test.jpg 3KB
豫FSQ818.jpg 3KB
5.jpg 2KB
Q67876.jpg 2KB
鲁VQV767.jpg 2KB
Q67876.jpg 2KB
7.jpg 2KB
lastfailed 28B
LICENSE 34KB
LICENSE 11KB
README.md 6KB
README.md 6KB
README.md 3KB
README.md 2KB
vid_te.mp4 6.26MB
coco.names 625B
car.names 4B
epoch_39.pth 61.69MB
Final_LPRNet_model.pth 1.72MB
mobilenet0.25_epoch_20_ccpd.pth 1.71MB
Clipper.py 31KB
train_vehicle_multilabel.py 24KB
my_alpr.py 23KB
CamShow.py 19KB
darknet.py 16KB
models.py 15KB
mobile_net_v3.py 13KB
box_utils.py 13KB
VehicleDC.py 13KB
darknet_util.py 13KB
utils.py 12KB
train_LPRNet.py 11KB
pll_detect.py 9KB
mobilenetv3.py 8KB
car_detect.py 7KB
data_augment.py 7KB
train.py 7KB
inference_LPR.py 6KB
multibox_loss.py 5KB
retina.py 5KB
datasets.py 5KB
dataset.py 5KB
net.py 4KB
test.py 4KB
wider_lp.py 4KB
open_pr_det.py 3KB
LPRNet.py 3KB
bbox.py 3KB
load_data.py 3KB
preprocess.py 2KB
utils.py 1KB
prior_box.py 1KB
parse_config.py 1KB
timer.py 1KB
py_cpu_nms.py 1KB
config.py 929B
logger.py 673B
augmentations.py 207B
__init__.py 165B
共 159 条
- 1
- 2
资源评论
妄北y
- 粉丝: 1w+
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功