yolov4 3.2.0
YOLOv4: Optimal Speed and Accuracy of Object Detection
License: MIT
Keywords: tensorflow,yolo,AI,TPU

![license](https://img.shields.io/github/license/hhk7734/tensorflow-yolov4)
![pypi](https://img.shields.io/pypi/v/yolov4)
![language](https://img.shields.io/github/languages/top/hhk7734/tensorflow-yolov4)

# tensorflow-yolov4

YOLOv4 Implemented in Tensorflow 2.

`>=v3`, :exclamation: Do not try to train. Not yet stable.

Docs: [https://wiki.loliot.net/docs/lang/python/libraries/yolov4/python-yolov4-about](https://wiki.loliot.net/docs/lang/python/libraries/yolov4/python-yolov4-about)

## Installation

```shell
python3 -m pip install yolov4
```

## Changelog

Ref: CHANGELOG

tensorflow-yolov4 (3.2.0) unstable; urgency=medium

  * config: add yolov4-tiny-relu-new_coords.cfg
  * c_src: layers: add yolo_tpu_layer_new_coords
  * c_src, common, tf, tflite, mAP: add prob_thresh
  * config: add yolov4-tiny-relu-new_coords-tpu.cfg
  * common: base_class: modify text

 -- Hyeonki Hong <hhk7734@gmail.com>  Mon, 22 Feb 2021 01:30:53 +0900

tensorflow-yolov4 (3.1.0) unstable; urgency=medium

  * tf: layers: yolo_layer: remove some operations
  * common: metalayer: yolo_layer: add `new_coords`
  * tf: layers: yolo_layer: implement `_coords_1` for `new_coords`
  * tf: layers: convolutional_layer: add logistic activation
  * c_src: py_box: add `get_yolo_*_detections`
  * config: add yolov4-csp.cfg and yolov4x-mish.cfg
  * c_src: layers: modify yolo_tpu_layer
  * tf, tflite: reflect v3.1.0 changes

 -- Hyeonki Hong <hhk7734@gmail.com>  Sun, 21 Feb 2021 02:37:18 +0900

tensorflow-yolov4 (3.0.1) unstable; urgency=medium

  * pypi: add 'pyproject.toml' and update 'setup.*'
  * common: parser: update error message
  * c_src: modify extended operator synonyms
  * c_src: change c-header to cpp-header

 -- Hyeonki Hong <hhk7734@gmail.com>  Thu, 18 Feb 2021 19:02:01 +0900

tensorflow-yolov4 (3.0.0) unstable; urgency=medium

  * common: parser: add parse_cfg()
  * common: config: implement YOLOConfig
  * common: metalayer: implement metalayers
  * common: metalayer: add YoloTpuLayer
  * tf: layers: implement layers
  * tf: layers: redefine BatchNormalization for transfer learning
  * tf: layers: add YoloTpuLayer
  * tf: dataset: refactor YOLODataset
  * tf: dataset: add '_augmentation_cache'
  * tf: training: refactor YOLOv4Loss
  * tf: training: implement YOLOCallbackAtEachStep
  * tf: training: refactor SaveWeightsCallback
  * tf: utils: move weights.py from tf
  * tf: utils: move mAP part from tf
  * tf: utils: move tflite part from tf and fix converting issue
  * c_src: py_box: add 'yolo_diou_nms'
  * c_src: py_box: add convert_dataset_to_ground_truth
  * c_src: layers: implement 'yolo_layer'
  * tf, tflite: reflect v3.0.0 changes

 -- Hyeonki Hong <hhk7734@gmail.com>  Mon, 15 Feb 2021 00:15:08 +0900

tensorflow-yolov4 (2.1.0) unstable; urgency=medium

  * tflite: add edgetpu_lib argument to load_tflite()

 -- Hyeonki Hong <hhk7734@gmail.com>  Wed, 27 Jan 2021 11:09:02 +0900

tensorflow-yolov4 (2.0.3) unstable; urgency=medium

  * common: allow media_path to be video stream id
  * tflite: fix problem of not finding load_delegate()

 -- Hyeonki Hong <hhk7734@gmail.com>  Thu, 07 Jan 2021 21:34:35 +0900

tensorflow-yolov4 (2.0.2) ustable; urgency=medium

  * tf: set converter.experimental_new_converter to False
  * tf: set converter.inference_in/output_type to tf.uint8
  * tflite: fix problem of not finding load_delegate()

 -- Hyeonki Hong <hhk7734@gmail.com>  Sun, 20 Dec 2020 13:06:08 +0900

tensorflow-yolov4 (2.0.1) unstable; urgency=medium

  * tf: set memory growth to True when using GPU
  * model: head: correct line ending
  * tf: add **kwargs parameter to compile() and fit()
  * tf: fix strange ground truth values issue

 -- Hyeonki Hong <hhk7734@gmail.com>  Sat, 05 Dec 2020 18:26:08 +0900

tensorflow-yolov4 (2.0.0) unstable; urgency=medium

  * tf:dataset: add data format check
  * common: base_class: change input_size from integer to (width, height)
  * common: base_class: set default arguments for candidates_to_pred_bboxes
  * tf: dataset: modify variable initialization according to input_size type change
  * common: predict: reflect input_size type change
  * common: media: reflect input_size type change to resize_image
  * tf:dataset: reflect input_size type change to data augmentation
  * common: base_class: reflect predict.fit_pred_bboxes_to_original change
  * common: predict: fix problem that occurred because image size change was not considered
  * tf: reflect input_size type change
  * model: head: reflect input_size type change
  * tf: train: reflect input_size type change
  * common: base_class: change strides to immutable constant
  * common: base_class: add cap.release() to release resources
  * tflite: reflect input_size type change
  * tf: optimize predict() using @tf.function
  * common: predict: fix problem caused by incorrect iou calculation

 -- Hyeonki Hong <hhk7734@gmail.com>  Tue, 27 Oct 2020 00:11:59 +0900

tensorflow-yolov4 (1.2.1) unstable; urgency=medium

  * tf: set num_sample to the number of dataset, if not specified
  * tf: modify to bring images in order on post-training
  * common: base_class: add iou/score_threshold argument
  * tf: add images_optional argument in save_dataset_for_mAP()
  * common: base_class: modify to call cv2.namedWindow once
  * common: media: modify to create colors once
  * tf: dataset: update docs

 -- Hyeonki Hong <hhk7734@gmail.com>  Fri, 04 Sep 2020 20:21:56 +0900

tensorflow-yolov4 (1.2.0) unstable; urgency=medium

  * model: remove tpu argument
  * tf: reflect model changes
  * tflite: remove tpu_hair
  * tf, tflite: move inference into BaseClass
  * model: yolov4: remove unused import
  * pylint: update .pylintrc
  * common: base_class: modify inference() to be able to use cam
  * common: base_class: add fps display to screen

 -- Hyeonki Hong <hhk7734@gmail.com>  Tue, 11 Aug 2020 21:43:29 +0900

tensorflow-yolov4 (1.1.0) unstable; urgency=medium

  * model: add kernel_regularizer argument
  * tf: remove subdivision
  * tf: dataset: fix issue where coordinates become 0 due to repeated division
  * tf: dataset: modify to shuffle when augmentation
  * tf: train: modify order of declaration
  * tf: train: give xiou_loss to more weight
  * tf: train: use keras.losses.BinaryCrossentropy to avoid nan problem
  * tf: train: add verbose argument
  * tf: dataset: change converted_coco format
  * tf: add image_path_prefix argument to load_dataset()
  * tf: add loss_verbose argument to compile()
  * tf: reflect dataset format change to save_dataset_for_mAP()

 -- Hyeonki Hong <hhk7734@gmail.com>  Mon, 10 Aug 2020 19:09:15 +0900

tensorflow-yolov4 (1.0.0) unstable; urgency=medium

  * tf: dataset: add `label smooting` argument
  * tf: add label_smooting argument to load_dataset()
  * tf: train: set truth_conf threshold to 0.5 because of label smoothing

 -- Hyeonki Hong <hhk7734@gmail.com>  Wed, 05 Aug 2020 13:05:02 +0900

tensorflow-yolov4 (0.24.0) unstable; urgency=medium

  * tf: set default num of sample for mAP to 1000
  * tf: fix error handling when image is empty

 -- Hyeonki Hong <hhk7734@gmail.com>  Tue, 04 Aug 2020 12:40:25 +0900

tensorflow-yolov4 (0.23.0) unstable; urgency=medium

  * tf: dataset: add error handling when bboxes are empty
  * common: media: replace space of class name to underbar
  * tf: implement save_dataset_for_mAP()
  * tf: dataset: add error handling when image is empty

 -- Hyeonki Hong <hhk7734@gmail.com>  Mon, 03 Aug 2020 20:49:51 +0900

tensorflow-yolov4 (0.22.0) unstable; urgency=medium

  * tf: add TFLITE_BUILTINS, SELECT_TF_OPS to default supported_ops
  * tf: dataset: modify to check if image exists when creating a dataset
  * tf: dataset: remove preprocess_dataset
  * tf: dataset: add cut_out
  * tf: dataset: add _next_random_augmentation_data()
  * tf: dataset: add mix_up
  * tf: dataset: implement mosaic

 -- Hyeonki Hong <hhk7734@gmail.com>  Sun, 02 Aug 2020 17:22:43 +0900

tensorflow-yolov4 (0.21.0) unstable; urgency=medium

  * tf: train: set epsilon used for division to 1e-8
  * tf: train: add giou and iou to iou_type
  * tf: train: fix loss function of bbox_probabilities

 -- Hyeonki Hong <hhk7734@gmail.com>  Thu, 30 Jul 2020 05:18:12 +0900

tensorflow-yolov4 (0.20.0) unstable; urgency=medium

  * tf: train: modify epsilon to 1e-9
  * tf: train: remove weight for conf_noobj_loss
  * tf: add arguments to fit()
  * tf: dataset: fix problem of not finding images
  * tf: add SaveWeightsCallback

 -- Hyeonki Hong <hhk7734@gmail.com>  Wed, 29 Jul 2020 05:06:25 +0900

tensorflow-yolov4 (0.19.0) unstable; urgency=medium

  * tf: weights: modify 'set' to 'load'
  * tf: weights: implement *_save_weights
  * tf: add save_weights()

 -- Hyeonki Hong <hhk7734@gmail.com>  Fri, 24 Jul 2020 06:22:14 +0900

tensorflow-yolov4 (0.18.0) unstable; urgency=medium

  * yolov4: clarify batch number
  * tf: remove by_name in load_weights
  * tf: dataset: simplify code
  * tf: dataset: fix problem of making a batch with same image

 -- Hyeonki Hong <hhk7734@gmail.com>  Thu, 23 Jul 2020 20:30:23 +0900

tensorflow-yolov4 (0.17.0) unstable; urgency=medium

  * tf: dataset: fix index range for Tiny
  * tf: remove expect_partial() in load_weights()
  * tflite: fix issue with the number of outputs by model
  * model: add tpu argument in Tiny
  * tflite: add tpu argument
  * utility: rename to common
  * common: implement BaseClass
  * tflite: add tensorflow.lite
  * model: head: change dimension from 4D to 3D in Tiny
  * tflite: add tpu_hair
  * common: media: add type cast in resize_image
  * tf: add num_calibration_steps argument in save_as_tflite
  * common: base_class: move strides property from tf
  * tf: set by_name to True in load_weights

  Thanks to @RealHandy

 -- Hyeonki Hong <hhk7734@gmail.com>  Thu, 23 Jul 2020 15:43:08 +0900

tensorflow-yolov4 (0.16.0) unstable; urgency=medium

  * tf: add tiny argument to __init__ and remove from others

 -- Hyeonki Hong <hhk7734@gmail.com>  Wed, 15 Jul 2020 13:21:12 +0900

tensorflow-yolov4 (0.15.0) unstable; urgency=medium

  * tf: add quantization and data_set args to save_as_tflite
  * utility: media: add string length check
  * model: add activation args
  * model: head: remove for loop
  * model: backbone: implement CSPDarknet53Tiny
  * model: neck: implement PANetTiny
  * model: head: implement YOLOv3HeadTiny
  * model: yolov4: implement YOLOv4Tiny
  * tf: weights: implement *_tiny_* funcs
  * tf: reflect YOLOv4Tiny

 -- Hyeonki Hong <hhk7734@gmail.com>  Wed, 15 Jul 2020 03:43:03 +0900

tensorflow-yolov4 (0.14.0) unstable; urgency=medium

  * github: add python publish action
  * model: neck: use bilinear in UpSampling2D
  * test: update script
  * tflite: refactor YOLOv4
  * utility: predict: fix according to pylint warning
  * pylint: update .pylintrc
  * model: head: use tf.constant to avoid broadcasting
  * github: add python lint action

 -- Hyeonki Hong <hhk7734@gmail.com>  Tue, 14 Jul 2020 02:14:12 +0900

tensorflow-yolov4 (0.13.0) unstable; urgency=medium

  * tf: remove tensorboard callback
  * tf: modify compile() and fit() to be similar to model
  * yolov4: rename 'data' to 'test'
  * utility: media: update docs and variable name
  * utility: predict: remove batch_size
  * utility: media: rename funcs
  * tf: add utility funcs to YOLOv4 member funcs
  * test: add test script

 -- Hyeonki Hong <hhk7734@gmail.com>  Mon, 13 Jul 2020 13:36:32 +0900

tensorflow-yolov4 (0.12.0) unstable; urgency=medium

  * utility: train: refactor bbox_*iou and remove duplicate funcs
  * yolov4: rename parameters
  * yolov4: remove utils
  * tf: add FileNotFoundError in YOLOv4.inference()
  * utility: predict: add dimension for batch size
  * pylint: update .pylintrc
  * tf: add YOLOv4.save_as_tflite()
  * model: clean up
  * utility: weights: move to tf.weights
  * utility: train: move to tf.train
  * model: neck: implement PANet
  * mdel: head: implement YOLOv3Head
  * model: yolov4: Apply neck and head class
  * yolov4: reflect model changes
  * tf: dataset: add batch_size
  * tf: train: implement YOLOv4Loss
  * utility: media: modify rectangle thickness
  * model: common: use softplus instead of ln(1+exp(x))
  * tf: train: use epsilon instead of tf.math.divide_no_nan
  * tf: refactor YOLOv4.fit() and .compile()

 -- Hyeonki Hong <hhk7734@gmail.com>  Sun, 12 Jul 2020 03:50:50 +0900

tensorflow-yolov4 (0.11.0) unstable; urgency=medium

  * tf: remove utils.draw_bbox in predict()
  * yolov4: rename files and functions and change order
  * utility: utils: remove get_anchors()
  * utility: media: impelment resize(), draw_bbox()
  * utility: utils: implement DIoU_NMS
  * utility: utils: fix dimensional calculation problems
  * utility: refactor dataset
  * tf: remove train
  * utility: train: implement make_compiled_loss()
  * utility: media: fix bug that could not resize some images
  * utility: train: remove problem of division by zero

 -- Hyeonki Hong <hhk7734@gmail.com>  Mon, 29 Jun 2020 21:05:39 +0900

tensorflow-yolov4 (0.10.0) unstable; urgency=medium

  * core: yolov4: refactor decode()
  * core: utils: remove sigmoid in postprocess_bbboxe()
  * tf: apply YOLOv4 changes to make_model()
  * core: yolov4: move decode_train() to tf.YOLOv4.train()

 -- Hyeonki Hong <hhk7734@gmail.com>  Thu, 25 Jun 2020 00:48:44 +0900

tensorflow-yolov4 (0.9.0) unstable; urgency=medium

  * tf: modify hyperparameters as properties
  * tf: add weights_type argument to load_weights()
  * core: utils: implement _np_fromfile()
  * core: utils: implement a way to partially load weights
  * tf: train: move learning_rate_* to argument
  * core: move YOLOConv2D to common
  * core: common: remove bn argument of YOLOConv2D
  * core: utils: refactor yolo_conv2d_set_weights
  * core: yolov4: refactor YOLOv4
  * core: utils: refactor load_weights
  * tf: refactor make_model
  * yolov4: change YoloV4 to YOLOv4

 -- Hyeonki Hong <hhk7734@gmail.com>  Wed, 24 Jun 2020 02:58:27 +0900

tensorflow-yolov4 (0.8.0) unstable; urgency=medium

  * core: use tf.keras.layers.UpSampling2D
  * core: refactor Mish
  * core: common: remove residual_block
  * core: remove sequential in _ResBlock
  * core: backbone: Set LeakyReLU's alpha to 0.1

 -- Hyeonki Hong <hhk7734@gmail.com>  Tue, 23 Jun 2020 02:21:01 +0900

tensorflow-yolov4 (0.7.0) unstable; urgency=medium

  * tf: fix to proceed to the next step even if an error occurs
  * tf: modify video_interval_ms to cv_waitKey_delay
  * core: backbone: refactor CSPDarknet53
  * core: utils: implement csp_darknet53_set_weights()

 -- Hyeonki Hong <hhk7734@gmail.com>  Mon, 22 Jun 2020 23:01:32 +0900

tensorflow-yolov4 (0.6.0) unstable; urgency=medium

  * tf: set first_step_epochs according to the weight usage
  * tf: fix syntax error

 -- Hyeonki Hong <hhk7734@gmail.com>  Fri, 19 Jun 2020 17:09:57 +0900

tensorflow-yolov4 (0.5.0) unstable; urgency=medium

  * core: dataset: add yolo type
  * tf: add dataset_type parameter to YoloV4.train
  * tf: add epochs parameter to train
  * tf: add save_interval parameter to train

 -- Hyeonki Hong <hhk7734@gmail.com>  Fri, 19 Jun 2020 14:30:50 +0900

tensorflow-yolov4 (0.4.0) unstable; urgency=medium

  * core: dataset: remove cfg module
  * tf: implement YoloV4.train

 -- Hyeonki Hong <hhk7734@gmail.com>  Thu, 11 Jun 2020 17:45:44 +0900

tensorflow-yolov4 (0.3.0) unstable; urgency=medium

  * core: utils: use numpy instead of tensorflow
  * pypi: remove install_requires and change to manual installation
  * yolov4: add video_interval_ms

 -- Hyeonki Hong <hhk7734@gmail.com>  Mon, 08 Jun 2020 23:59:41 +0900

tensorflow-yolov4 (0.2.0) unstable; urgency=medium

  * pylint: create .pylintrc and run black
  * core: remove config.py
  * yolov4: change tfyolov4 to yolov4
  * yolov4: remove detect**.py and implement YoloV4.inference

 -- Hyeonki Hong <hhk7734@gmail.com>  Mon, 08 Jun 2020 02:20:49 +0900

tensorflow-yolov4 (0.1.0) unstable; urgency=medium

  * yolov4: fork from 'hunglc007/tensorflow-yolov4-tflite'

 -- Hyeonki Hong <hhk7734@gmail.com>  Fri, 05 Jun 2020 20:17:45 +0900