Metadata-Version: 2.1
Name: yolov4
Version: 0.24.0
Summary: YOLOv4: Optimal Speed and Accuracy of Object Detection
Home-page: https://github.com/hhk7734/tensorflow-yolov4
Author: Hyeonki Hong
Author-email: hhk7734@gmail.com
License: MIT
Project-URL: Documentation, https://github.com/hhk7734/tensorflow-yolov4
Project-URL: "Source Code", https://github.com/hhk7734/tensorflow-yolov4
Description: ![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
        
        ```shell
        python3 -m pip install yolov4
        ```
        
        YOLOv4 Implemented in Tensorflow 2.
        
        ## Download Weights
        
        - [yolov4-tiny.conv.29](https://drive.google.com/file/d/1WtOuGfUgNyNfALo5_VhQ1kb5QenRE0Gt/view?usp=sharing)
        - [yolov4-tiny.weights](https://drive.google.com/file/d/1GJwGiR7rizY_19c_czuLN8p31BwkhWY5/view?usp=sharing)
        - [yolov4.conv.137](https://drive.google.com/file/d/1li1pUtqpXj_-ZXxA8wJq-nzW8h2HWsrP/view?usp=sharing)
        - [yolov4.weights](https://drive.google.com/file/d/15P4cYyZ2Sd876HKAEWSmeRdFl_j-0upi/view?usp=sharing)
        
        ## Dependencies
        
        ```shell
        python3 -m pip install -U pip setuptools wheel
        ```
        
        ```shell
        python3 -m pip install numpy
        ```
        
        Install OpenCV (cv2)
        
        ### Tensorflow 2
        
        ```shell
        python3 -m pip install tensorflow
        ```
        
        ### TFlite
        
        Ref: [https://www.tensorflow.org/lite/guide/python](https://www.tensorflow.org/lite/guide/python)
        
        ## Objective
        
        - [x] Train and predict using TensorFlow 2 only
        - [x] Run yolov4-tiny-relu on Coral board(TPU).
        - [ ] Train tiny-relu with coco 2017 dataset
        - [ ] Update Docs
        - [ ] Optimize model and operations
        
        ## Performance
        
        ![performance](./test/performance.png)
        
        ![performance-tiny](./test/performance-tiny.png)
        
        ## Help
        
        ```python
        >>> from yolov4.tf import YOLOv4
        >>> help(YOLOv4)
        ```
        
        ## Inference
        
        ### tensorflow
        
        ```python
        from yolov4.tf import YOLOv4
        
        yolo = YOLOv4()
        
        yolo.classes = "coco.names"
        
        yolo.make_model()
        yolo.load_weights("yolov4.weights", weights_type="yolo")
        
        yolo.inference(media_path="kite.jpg")
        
        yolo.inference(media_path="road.mp4", is_image=False)
        ```
        
        [Object detection test jupyter notebook](./test/object_detection_in_image.ipynb)
        
        ```python
        from yolov4.tf import YOLOv4
        
        yolo = YOLOv4(tiny=True)
        
        yolo.classes = "coco.names"
        
        yolo.make_model()
        yolo.load_weights("yolov4-tiny.weights", weights_type="yolo")
        
        yolo.inference(media_path="kite.jpg")
        
        yolo.inference(media_path="road.mp4", is_image=False)
        ```
        
        ### tensorflow lite
        
        ```python
        from yolov4.tf import YOLOv4
        
        yolo = YOLOv4()
        
        yolo.classes = "coco.names"
        
        yolo.make_model()
        yolo.load_weights("yolov4.weights", weights_type="yolo")
        
        yolo.save_as_tflite("yolov4.tflite")
        ```
        
        ```python
        from yolov4.tflite import YOLOv4
        
        yolo = YOLOv4()
        
        yolo.classes = "coco.names"
        
        yolo.load_tflite("yolov4.tflite")
        
        yolo.inference("kite.jpg")
        ```
        
        ## Training
        
        ```python
        from tensorflow.keras import callbacks, optimizers
        from yolov4.tf import SaveWeightsCallback, YOLOv4
        
        yolo = YOLOv4(tiny=True)
        
        yolo.classes = "coco.names"
        yolo.input_size = 608
        yolo.batch_size = 32
        yolo.subdivision = 16
        
        yolo.make_model()
        yolo.load_weights("yolov4-tiny.conv.29", weights_type="yolo")
        
        train_data_set = yolo.load_dataset("train2017.txt")
        val_data_set = yolo.load_dataset("val2017.txt", training=False)
        # data_set = yolo.load_dataset("darknet/data/train.txt", dataset_type="yolo")
        
        lr = 1e-4
        epochs = 30000
        
        optimizer = optimizers.Adam(learning_rate=lr)
        yolo.compile(optimizer=optimizer, loss_iou_type="ciou")
        
        
        def lr_scheduler(epoch):
            if epoch < 1000:
                return (epoch / 1000) * lr
            elif epoch < int(epochs * 0.8):
                return lr
            elif epoch < int(epochs * 0.9):
                return lr * 0.1
            else:
                return lr * 0.01
        
        
        yolo.fit(
            train_data_set,
            epochs=epochs,
            callbacks=[
                callbacks.LearningRateScheduler(lr_scheduler),
                callbacks.TerminateOnNaN(),
                callbacks.TensorBoard(
                    log_dir="/content/drive/My Drive/Hard_Soft/NN/logs",
                ),
                SaveWeightsCallback(
                    yolo=yolo, weights_type="yolo", epoch_per_save=1000
                ),
            ],
            validation_data=val_data_set,
            validation_steps=100,
            validation_freq=100,
        )
        ```
        
        [Custom training on Colab jupyter notebook](./test/custom_training_on_colab.ipynb)
        
        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
        
Keywords: tensorflow,yolo,AI,TPU
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX :: Linux
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development
Description-Content-Type: text/markdown
