{"id":20103515,"url":"https://github.com/pythonlessons/tensorflow-2.x-yolov3","last_synced_at":"2025-10-18T18:20:11.674Z","repository":{"id":37440659,"uuid":"257681773","full_name":"pythonlessons/TensorFlow-2.x-YOLOv3","owner":"pythonlessons","description":"YOLOv3 implementation in TensorFlow 2.3.1","archived":false,"fork":false,"pushed_at":"2024-05-03T19:54:25.000Z","size":72491,"stargazers_count":605,"open_issues_count":47,"forks_count":329,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-04-03T14:11:20.564Z","etag":null,"topics":["darknet","detection","pretrained-weights","tensorflow2","tensorrt","tracking","yolo","yolov3","yolov4","yolov4-training"],"latest_commit_sha":null,"homepage":"https://pylessons.com/","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pythonlessons.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-21T18:29:55.000Z","updated_at":"2025-03-19T11:59:07.000Z","dependencies_parsed_at":"2024-08-02T01:26:09.527Z","dependency_job_id":null,"html_url":"https://github.com/pythonlessons/TensorFlow-2.x-YOLOv3","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pythonlessons%2FTensorFlow-2.x-YOLOv3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pythonlessons%2FTensorFlow-2.x-YOLOv3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pythonlessons%2FTensorFlow-2.x-YOLOv3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pythonlessons%2FTensorFlow-2.x-YOLOv3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pythonlessons","download_url":"https://codeload.github.com/pythonlessons/TensorFlow-2.x-YOLOv3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248589868,"owners_count":21129693,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["darknet","detection","pretrained-weights","tensorflow2","tensorrt","tracking","yolo","yolov3","yolov4","yolov4-training"],"created_at":"2024-11-13T17:36:33.806Z","updated_at":"2025-10-18T18:20:11.623Z","avatar_url":"https://github.com/pythonlessons.png","language":"Jupyter Notebook","readme":"# TensorFlow-2.x-YOLOv3 and YOLOv4 tutorials\n\nYOLOv3 and YOLOv4 implementation in TensorFlow 2.x, with support for training, transfer training, object tracking mAP and so on...\nCode was tested with following specs:\n- i7-7700k CPU and Nvidia 1080TI GPU\n- OS Ubuntu 18.04\n- CUDA 10.1\n- cuDNN v7.6.5\n- TensorRT-6.0.1.5\n- Tensorflow-GPU 2.3.1\n- Code was tested on Ubuntu and Windows 10 (TensorRT not supported officially)\n\n## Installation\nFirst, clone or download this GitHub repository.\nInstall requirements and download pretrained weights:\n```\npip install -r ./requirements.txt\n\n# yolov3\nwget -P model_data https://pjreddie.com/media/files/yolov3.weights\n\n# yolov3-tiny\nwget -P model_data https://pjreddie.com/media/files/yolov3-tiny.weights\n\n# yolov4\nwget -P model_data https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v3_optimal/yolov4.weights\n\n# yolov4-tiny\nwget -P model_data https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v4_pre/yolov4-tiny.weights\n```\n\n## Quick start\nStart with using pretrained weights to test predictions on both image and video:\n```\npython detection_demo.py\n```\n\n\u003cp align=\"center\"\u003e\n    \u003cimg width=\"100%\" src=\"IMAGES/city_pred.jpg\" style=\"max-width:100%;\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Quick training for custom mnist dataset\nmnist folder contains mnist images, create training data:\n```\npython mnist/make_data.py\n```\n`./yolov3/configs.py` file is already configured for mnist training.\n\nNow, you can train it and then evaluate your model\n```\npython train.py\ntensorboard --logdir=log\n```\nTrack training progress in Tensorboard and go to http://localhost:6006/:\n\u003cp align=\"center\"\u003e\n    \u003cimg width=\"100%\" src=\"IMAGES/tensorboard.png\" style=\"max-width:100%;\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nTest detection with `detect_mnist.py` script:\n```\npython detect_mnist.py\n```\nResults:\n\u003cp align=\"center\"\u003e\n    \u003cimg width=\"40%\" src=\"IMAGES/mnist_test.jpg\" style=\"max-width:40%;\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Custom YOLOv3 \u0026 YOLOv4 object detection training\nCustom training required to prepare dataset first, how to prepare dataset and train custom model you can read in following link:\u003cbr\u003e\nhttps://pylessons.com/YOLOv3-TF2-custrom-train/\u003cbr\u003e\nMore about YOLOv4 training you can read [on this link](https://pylessons.com/YOLOv4-TF2-training/). I didn’t have time to implement all YOLOv4 Bag-Of-Freebies to improve the training process… Maybe later I’ll find time to do that, but now I leave it as it is. I recommended to use [Alex's Darknet](https://github.com/AlexeyAB/darknet) to train your custom model, if you need maximum performance, otherwise, you can use my implementation.\n\n## Google Colab Custom Yolo v3 training\nTo learn more about Google Colab Free gpu training, visit my [text version tutorial](https://pylessons.com/YOLOv3-TF2-GoogleColab/)\n\n## Yolo v3 Tiny train and detection\nTo get detailed instructions how to use Yolov3-Tiny, follow my text version tutorial [YOLOv3-Tiny support](https://pylessons.com/YOLOv3-TF2-Tiny/). Short instructions:\n- Get YOLOv3-Tiny weights: ```wget -P model_data https://pjreddie.com/media/files/yolov3-tiny.weights```\n- From `yolov3/configs.py` change `TRAIN_YOLO_TINY` from `False` to `True`\n- Run `detection_demo.py` script.\n\n## Yolo v3 Object tracking\nTo learn more about Object tracking with Deep SORT, visit [Following link](https://pylessons.com/YOLOv3-TF2-DeepSort/).\nQuick test:\n- Clone this repository;\n- Make sure object detection works for you;\n- Run object_tracking.py script\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"IMAGES/tracking_results.gif\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## YOLOv3 vs YOLOv4 comparison on 1080TI:\n\nYOLO FPS on COCO 2017 Dataset:\n| Detection    | 320x320 | 416x416 | 512x512 |\n|--------------|---------|---------|---------|\n| YoloV3 FPS   | 24.38   | 20.94   | 18.57   |\n| YoloV4 FPS   | 22.15   | 18.69   | 16.50   |\n\nTensorRT FPS on COCO 2017 Dataset:\n| Detection       | 320x320 | 416x416 | 512x512 | 608x608 |\n|-----------------|---------|---------|---------|---------|\n| YoloV4 FP32 FPS | 31.23   | 27.30   | 22.63   | 18.17   |\n| YoloV4 FP16 FPS | 30.33   | 25.44   | 21.94   | 17.99   |\n| YoloV4 INT8 FPS | 85.18   | 62.02   | 47.50   | 37.32   |\n| YoloV3 INT8 FPS | 84.65   | 52.72   | 38.22   | 28.75   |\n\nmAP on COCO 2017 Dataset:\n| Detection        | 320x320 | 416x416 | 512x512 |\n|------------------|---------|---------|---------|\n| YoloV3 mAP50     | 49.85   | 55.31   | 57.48   |         \n| YoloV4 mAP50     | 48.58   | 56.92   | 61.71   |         \n\nTensorRT mAP on COCO 2017 Dataset:\n| Detection         | 320x320 | 416x416 | 512x512 | 608x608 |\n|-------------------|---------|---------|---------|---------|\n| YoloV4 FP32 mAP50 | 48.58   | 56.92   | 61.71   | 63.92   |\n| YoloV4 FP16 mAP50 | 48.57   | 56.92   | 61.69   | 63.92   |\n| YoloV4 INT8 mAP50 | 40.61   | 48.36   | 52.84   | 54.53   |\n| YoloV3 INT8 mAP50 | 44.19   | 48.64   | 50.10   | 50.69   |\n\n## Converting YOLO to TensorRT\nI will give two examples, both will be for YOLOv4 model,quantize_mode=INT8 and model input size will be 608. Detailed tutorial is on this [link](https://pylessons.com/YOLOv4-TF2-TensorRT/).\n### Default weights from COCO dataset:\n- Download weights from links above;\n- In `configs.py` script choose your `YOLO_TYPE`;\n- In `configs.py` script set `YOLO_INPUT_SIZE = 608`;\n- In `configs.py` script set `YOLO_FRAMEWORK = \"trt\"`;\n- From main directory in terminal type `python tools/Convert_to_pb.py`;\n- From main directory in terminal type `python tools/Convert_to_TRT.py`;\n- In `configs.py` script set `YOLO_CUSTOM_WEIGHTS = f'checkpoints/{YOLO_TYPE}-trt-{YOLO_TRT_QUANTIZE_MODE}–{YOLO_INPUT_SIZE}'`;\n- Now you can run `detection_demo.py`, best to test with `detect_video` function.\n\n### Custom trained YOLO weights:\n- Download weights from links above;\n- In `configs.py` script choose your `YOLO_TYPE`;\n- In `configs.py` script set `YOLO_INPUT_SIZE = 608`;\n- Train custom YOLO model with instructions above;\n- In `configs.py` script set `YOLO_CUSTOM_WEIGHTS = f\"{YOLO_TYPE}_custom\"`;\n- In `configs.py` script make sure that  `TRAIN_CLASSES` is with your custom classes text file;\n- From main directory in terminal type `python tools/Convert_to_pb.py`;\n- From main directory in terminal type `python tools/Convert_to_TRT.py`;\n- In `configs.py` script set `YOLO_FRAMEWORK = \"trt\"`;\n- In `configs.py` script set `YOLO_CUSTOM_WEIGHTS = f'checkpoints/{YOLO_TYPE}-trt-{YOLO_TRT_QUANTIZE_MODE}–{YOLO_INPUT_SIZE}'`;\n- Now you can run `detection_custom.py`, to test custom trained and converted TensorRT model.\n\nWhat is done:\n--------------------\n- [x] Detection with original weights [Tutorial link](https://pylessons.com/YOLOv3-TF2-introduction/)\n- [x] Mnist detection training [Tutorial link](https://pylessons.com/YOLOv3-TF2-mnist/)\n- [x] Custom detection training [Tutorial link1](https://pylessons.com/YOLOv3-TF2-custrom-train/), [link2](https://pylessons.com/YOLOv3-TF2-custrom-images/)\n- [x] Google Colab training [Tutorial link](https://pylessons.com/YOLOv3-TF2-GoogleColab/)\n- [x] YOLOv3-Tiny support [Tutorial link](https://pylessons.com/YOLOv3-TF2-Tiny/)\n- [X] Object tracking [Tutorial link](https://pylessons.com/YOLOv3-TF2-DeepSort/)\n- [X] Mean Average Precision (mAP) [Tutorial link](https://pylessons.com/YOLOv3-TF2-mAP/)\n- [X] Yolo v3 on Raspberry Pi [Tutorial link](https://pylessons.com/YOLOv3-TF2-RaspberryPi/)\n- [X] YOLOv4 and YOLOv4-tiny detection [Tutorial link](https://pylessons.com/YOLOv4-TF2-introduction/)\n- [X] YOLOv4 and YOLOv4-tiny detection training (Not fully) [Tutorial link](https://pylessons.com/YOLOv4-TF2-training/)\n- [X] Convert to TensorRT model [Tutorial link](https://pylessons.com/YOLOv4-TF2-TensorRT/)\n- [X] Add multiprocessing after detection (drawing bbox) [Tutorial link](https://pylessons.com/YOLOv4-TF2-multiprocessing/)\n- [X] Generate YOLO Object Detection training data from its own results [Tutorial link](https://pylessons.com/YOLOv4-TF2-CreateXML/)\n- [X] Counter-strike Global Offensive realtime YOLOv4 Object Detection aimbot [Tutorial link](https://pylessons.com/YOLOv4-TF2-CSGO-aimbot/)\n\nTo be continued... (not anytime soon)\n--------------------\n- [ ] Converting to TensorFlow Lite\n- [ ] YOLO on Android (Leaving it for future, will need to convert everythin to java... not ready for this)\n- [ ] Generating anchors\n- [ ] YOLACT: Real-time Instance Segmentation\n- [ ] Model pruning (Pruning is a technique in deep learning that aids in the development of smaller and more efficient neural networks. It's a model optimization technique that involves eliminating unnecessary values in the weight tensor.)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpythonlessons%2Ftensorflow-2.x-yolov3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpythonlessons%2Ftensorflow-2.x-yolov3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpythonlessons%2Ftensorflow-2.x-yolov3/lists"}