https://github.com/artificialzeng/yolo-v3-tensorflow

:construction_worker: :construction_worker::construction_worker: YOLO V3(Tensorflow 1.x) 安全帽 识别 | 提供数据集下载和与预训练模型

https://github.com/artificialzeng/yolo-v3-tensorflow

Science Score: 10.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (7.8%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

:construction_worker: :construction_worker::construction_worker: YOLO V3(Tensorflow 1.x) 安全帽 识别 | 提供数据集下载和与预训练模型

Basic Info
  • Host: GitHub
  • Owner: ArtificialZeng
  • Default Branch: dev
  • Homepage:
  • Size: 939 KB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Fork of DataXujing/YOLO-V3-Tensorflow
Created almost 6 years ago · Last pushed over 6 years ago

https://github.com/ArtificialZeng/YOLO-V3-Tensorflow/blob/dev/

## Tensorflow YOLO V3

**Xu Jing**

YOLO V3


### 1.  

Google([SafetyHelmetWearing-Dataset, SHWD](https://github.com/njvisionpower/Safety-Helmet-Wearing-Dataset))75819044bounding box111514bounding box()labelimgbounding boxhatpersonbounding boxperson[SCUT-HEAD](https://github.com/HCIILAB/SCUT-HEAD-Dataset-Release)

1.

GooglewebGooglegoogle-images-downloadsafety Helmetsafety hathard hat

2.

ROI

(1)ROI

(2)zooImageNet

(3)

3.bounding box

labelImg****bounding box,xmlbounding boxxmlannotation


### 2. 

Tensorflow[YOLOv3](https://pjreddie.com/media/files/papers/YOLOv3.pdf). pipeline. :

-  tf.data pipeline
- COCO
- GPUNMS.
- .
- Kmeansanchor.


Python : 2 or 3

Packages:

- tensorflow >= 1.8.0 (tf.data)
- opencv-python
- tqdm

darknet,weight`./data/darknet_weights/`darknetTensorflow

```shell
python convert_weight.py
# yolo_anchor[anchorKmeansanchors]
```

Tensorflow checkpoint`./data/darknet_weights/`[GitHub Release](https://github.com/DataXujing/YOLO-V3-Tensorflow/releases/tag/1.0)


### 3. 

VOCVOC

(1) annotation



```shell
python data_pro.py
```
`./data/my_data/labal``train.txt/val.txt/test.txt``image_index`,`image_absolute_path`, `img_width`, `img_height`,`box_1`,`box_2`,...,`box_n`,:

+ `image_index`
+ `image_absolute_path` 
+ `img_width`, `img_height`,`box_1`,`box_2`,...,`box_n`int
+ `box_x``label_index, x_min,y_min,x_max,y_max`()
+ `label_index`labelindex([0~class_num-1]),YOLOSSDlabelbackground



```
0 xxx/xxx/a.jpg 1920,1080,0 453 369 473 391 1 588 245 608 268
1 xxx/xxx/b.jpg 1920,1080,1 466 403 485 422 2 793 300 809 320
...
```

(2) class_names:

`coco.names` `./data/` label name,

```
hat
person
```

(3) anchor:

Kmeansanchors:

```
python get_kmeans.py
```
9anchorsIOU,anchors`./data/yolo_anchors.txt`, **: KmeansYOLO Anchors** ### 4. `arg.py`
arg.py

### Some paths
train_file = './data/my_data/label/train.txt'  # The path of the training txt file.
val_file = './data/my_data/label/val.txt'  # The path of the validation txt file.
restore_path = './data/darknet_weights/yolov3.ckpt'  # The path of the weights to restore.
save_dir = './checkpoint/'  # The directory of the weights to save.
log_dir = './data/logs/'  # The directory to store the tensorboard log files.
progress_log_path = './data/progress.log'  # The path to record the training progress.
anchor_path = './data/yolo_anchors.txt'  # The path of the anchor txt file.
class_name_path = './data/coco.names'  # The path of the class names.
### Training releated numbers
batch_size = 32  #6
img_size = [416, 416]  # Images will be resized to `img_size` and fed to the network, size format: [width, height]
letterbox_resize = True  # Whether to use the letterbox resize, i.e., keep the original aspect ratio in the resized image.
total_epoches = 500
train_evaluation_step = 100  # Evaluate on the training batch after some steps.
val_evaluation_epoch = 50  # Evaluate on the whole validation dataset after some epochs. Set to None to evaluate every epoch.
save_epoch = 10  # Save the model after some epochs.
batch_norm_decay = 0.99  # decay in bn ops
weight_decay = 5e-4  # l2 weight decay
global_step = 0  # used when resuming training
### tf.data parameters
num_threads = 10  # Number of threads for image processing used in tf.data pipeline.
prefetech_buffer = 5  # Prefetech_buffer used in tf.data pipeline.
### Learning rate and optimizer
optimizer_name = 'momentum'  # Chosen from [sgd, momentum, adam, rmsprop]
save_optimizer = True  # Whether to save the optimizer parameters into the checkpoint file.
learning_rate_init = 1e-4
lr_type = 'piecewise'  # Chosen from [fixed, exponential, cosine_decay, cosine_decay_restart, piecewise]
lr_decay_epoch = 5  # Epochs after which learning rate decays. Int or float. Used when chosen `exponential` and `cosine_decay_restart` lr_type.
lr_decay_factor = 0.96  # The learning rate decay factor. Used when chosen `exponential` lr_type.
lr_lower_bound = 1e-6  # The minimum learning rate.
# only used in piecewise lr type
pw_boundaries = [30, 50]  # epoch based boundaries
pw_values = [learning_rate_init, 3e-5, 1e-5]
### Load and finetune
# Choose the parts you want to restore the weights. List form.
# restore_include: None, restore_exclude: None  => restore the whole model
# restore_include: None, restore_exclude: scope  => restore the whole model except `scope`
# restore_include: scope1, restore_exclude: scope2  => if scope1 contains scope2, restore scope1 and not restore scope2 (scope1 - scope2)
# choise 1: only restore the darknet body
# restore_include = ['yolov3/darknet53_body']
# restore_exclude = None
# choise 2: restore all layers except the last 3 conv2d layers in 3 scale
restore_include = None
restore_exclude = ['yolov3/yolov3_head/Conv_14', 'yolov3/yolov3_head/Conv_6', 'yolov3/yolov3_head/Conv_22']
# Choose the parts you want to finetune. List form.
# Set to None to train the whole model.
update_part = ['yolov3/yolov3_head']
### other training strategies
multi_scale_train = True  # Whether to apply multi-scale training strategy. Image size varies from [320, 320] to [640, 640] by default.
use_label_smooth = True # Whether to use class label smoothing strategy.
use_focal_loss = True  # Whether to apply focal loss on the conf loss.
use_mix_up = True  # Whether to use mix up data augmentation strategy. 
use_warm_up = True  # whether to use warm up strategy to prevent from gradient exploding.
warm_up_epoch = 3  # Warm up training epoches. Set to a larger value if gradient explodes.
### some constants in validation
# nms
nms_threshold = 0.45  # iou threshold in nms operation
score_threshold = 0.01  # threshold of the probability of the classes in nms operation, i.e. score = pred_confs * pred_probs. set lower for higher recall.
nms_topk = 150  # keep at most nms_topk outputs after nms
# mAP eval
eval_threshold = 0.5  # the iou threshold applied in mAP evaluation
use_voc_07_metric = False  # whether to use voc 2007 evaluation metric, i.e. the 11-point metric
### parse some params
anchors = parse_anchors(anchor_path)
classes = read_class_names(class_name_path)
class_num = len(classes)
train_img_cnt = len(open(train_file, 'r').readlines())
val_img_cnt = len(open(val_file, 'r').readlines())
train_batch_num = int(math.ceil(float(train_img_cnt) / batch_size))
lr_decay_freq = int(train_batch_num * lr_decay_epoch)
pw_boundaries = [float(i) * train_batch_num + global_step for i in pw_boundaries]
```shell CUDA_VISIBLE_DEVICES=GPU_ID python train.py ``` + ubuntu 16.04 + Tesla V100 32G ### 5. `test_single_image.py``video_test.py`Demo`6.Demo`[GitHub Release](https://github.com/DataXujing/YOLO-V3-Tensorflow/releases/tag/model) ``` python3 test_single_image.py /home/myuser/xujing/YOLO_V3_hat/data/my_data/JPEGImages/000002.jpg ``` ### 6.Demo
### 7.Trick Trick (1) two-stageone-stage: + Two-stage training: - COCOckeckpointsdarknet53_bodyweightsYOLO V3head0.001 - 0.0001 + One-stage training: Conv_6,Conv_14Conv_22()LossnanOne-stage training (2) args.py: + decay(Cosine decay of lr (SGDR)) + Multi-scale training + Label smoothing + Mix up data augmentation + Focal lossRetinaNetunblance . (3) gluon-cv[paper](https://arxiv.org/abs/1902.04103) YOLO V3, work,mAP (4) Loss nan? Loss nanwarm_up_epochone-stageadamnanmomentum optimizer ### 8. Name | GitHub | :-: | :-: | :shipit: **Wizyoung** | | :shipit: **njvisionpower** || :shipit: **HCIILAB** | |

Owner

  • Name: Dr. Artificial曾小健
  • Login: ArtificialZeng
  • Kind: user
  • Location: Beijing

LLM practitioner/engineer, AI/ML/DL Quant

GitHub Events

Total
Last Year