{"id":13562414,"url":"https://github.com/experiencor/keras-yolo2","last_synced_at":"2025-05-15T11:02:46.724Z","repository":{"id":37852190,"uuid":"85842387","full_name":"experiencor/keras-yolo2","owner":"experiencor","description":"Easy training on custom dataset. Various backends (MobileNet and SqueezeNet) supported. A YOLO demo to detect raccoon run entirely in brower is accessible at https://git.io/vF7vI (not on Windows).","archived":false,"fork":false,"pushed_at":"2023-03-24T22:26:55.000Z","size":55194,"stargazers_count":1737,"open_issues_count":202,"forks_count":781,"subscribers_count":66,"default_branch":"master","last_synced_at":"2025-04-14T16:58:33.116Z","etag":null,"topics":["convolutional-networks","deep-learning","realtime","regression","yolo2"],"latest_commit_sha":null,"homepage":"","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/experiencor.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}},"created_at":"2017-03-22T15:08:29.000Z","updated_at":"2025-04-07T01:52:31.000Z","dependencies_parsed_at":"2022-08-19T09:12:20.284Z","dependency_job_id":"f0007138-1235-497c-b625-769cfd2d0e76","html_url":"https://github.com/experiencor/keras-yolo2","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/experiencor%2Fkeras-yolo2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/experiencor%2Fkeras-yolo2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/experiencor%2Fkeras-yolo2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/experiencor%2Fkeras-yolo2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/experiencor","download_url":"https://codeload.github.com/experiencor/keras-yolo2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254328385,"owners_count":22052632,"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":["convolutional-networks","deep-learning","realtime","regression","yolo2"],"created_at":"2024-08-01T13:01:08.374Z","updated_at":"2025-05-15T11:02:46.701Z","avatar_url":"https://github.com/experiencor.png","language":"Jupyter Notebook","funding_links":[],"categories":["Jupyter Notebook","Other Versions of YOLO"],"sub_categories":[],"readme":"# YOLOv2 in Keras and Applications\n\nThis repo contains the implementation of YOLOv2 in Keras with Tensorflow backend. It supports training YOLOv2 network with various backends such as MobileNet and InceptionV3. Links to demo applications are shown below. Check out https://experiencor.github.io/yolo_demo/demo.html for a Raccoon Detector demo run entirely in brower with DeepLearn.js and MobileNet backend (it somehow breaks in Window). Source code of this demo is located at https://git.io/vF7vG.\n\n## Todo list:\n- [x] Warmup training\n- [x] Raccoon detection, Self-driving car, and Kangaroo detection\n- [x] SqueezeNet, MobileNet, InceptionV3, and ResNet50 backends\n- [x] Support python 2.7 and 3.6\n- [ ] Multiple-GPU training\n- [ ] Multiscale training\n- [ ] mAP Evaluation\n\n## Some example applications (click for videos):\n\n### Raccon detection\n\u003ca href=\"https://www.youtube.com/watch?v=aibuvj2-zxA\" rel=\"some text\"\u003e\u003cp align=\"center\"\u003e\u003cimg src=\"https://i.imgur.com/6okeDjz.jpg\" height=\"300\"\u003e\u003c/p\u003e\u003c/a\u003e\n\nDataset =\u003e https://github.com/experiencor/raccoon_dataset\n\n### Kangaroo detection\n\u003ca href=\"https://youtu.be/vjmFzEP1qZw?t=34\" rel=\"some text\"\u003e\u003cp align=\"center\"\u003e\u003cimg src=\"https://i.imgur.com/v606VZX.jpg\" height=\"300\"\u003e\u003c/p\u003e\u003c/a\u003e\n\nDataset =\u003e https://github.com/experiencor/kangaroo\n\n### Self-driving Car\n\u003ca href=\"https://www.youtube.com/watch?v=oYCaILZxEWM\" rel=\"some text\"\u003e\u003cp align=\"center\"\u003e\u003cimg src=\"https://i.imgur.com/kEc9ptL.jpg\" height=\"300\"\u003e\u003c/p\u003e\u003c/a\u003e\n\nDataset =\u003e http://cocodataset.org/#detections-challenge2017\n\n### Red blod cell detection\n\u003ca href=\"https://www.youtube.com/watch?v=oYCaILZxEWM\" rel=\"some text\"\u003e\u003cp align=\"center\"\u003e\u003cimg src=\"https://i.imgur.com/1vmIJKL.jpg\" height=\"300\"\u003e\u003c/p\u003e\u003c/a\u003e\n\nDataset =\u003e https://github.com/cosmicad/dataset\n\n### Hand detection\n\u003ca href=\"https://www.youtube.com/watch?v=p3-3kN_fIz0\" rel=\"some text\"\u003e\u003cp align=\"center\"\u003e\u003cimg src=\"https://i.imgur.com/75imQQz.jpg\" height=\"300\"\u003e\u003c/p\u003e\u003c/a\u003e\n\nDataset =\u003e http://cvrr.ucsd.edu/vivachallenge/index.php/hands/hand-detection/\n\n## Usage for python code\n\n### 0. Requirement\n\npython 2.7\n\nkeras \u003e= 2.0.8\n\nimgaug\n\n### 1. Data preparation\nDownload the Raccoon dataset from from https://github.com/experiencor/raccoon_dataset.\n\nOrganize the dataset into 4 folders:\n\n+ train_image_folder \u003c= the folder that contains the train images.\n\n+ train_annot_folder \u003c= the folder that contains the train annotations in VOC format.\n\n+ valid_image_folder \u003c= the folder that contains the validation images.\n\n+ valid_annot_folder \u003c= the folder that contains the validation annotations in VOC format.\n    \nThere is a one-to-one correspondence by file name between images and annotations. If the validation set is empty, the training set will be automatically splitted into the training set and validation set using the ratio of 0.8.\n\n### 2. Edit the configuration file\nThe configuration file is a json file, which looks like this:\n\n```python\n{\n    \"model\" : {\n        \"architecture\":         \"Full Yolo\",    # \"Tiny Yolo\" or \"Full Yolo\" or \"MobileNet\" or \"SqueezeNet\" or \"Inception3\"\n        \"input_size\":           416,\n        \"anchors\":              [0.57273, 0.677385, 1.87446, 2.06253, 3.33843, 5.47434, 7.88282, 3.52778, 9.77052, 9.16828],\n        \"max_box_per_image\":    10,        \n        \"labels\":               [\"raccoon\"]\n    },\n\n    \"train\": {\n        \"train_image_folder\":   \"/home/andy/data/raccoon_dataset/images/\",\n        \"train_annot_folder\":   \"/home/andy/data/raccoon_dataset/anns/\",      \n          \n        \"train_times\":          10,             # the number of time to cycle through the training set, useful for small datasets\n        \"pretrained_weights\":   \"\",             # specify the path of the pretrained weights, but it's fine to start from scratch\n        \"batch_size\":           16,             # the number of images to read in each batch\n        \"learning_rate\":        1e-4,           # the base learning rate of the default Adam rate scheduler\n        \"nb_epoch\":             50,             # number of epoches\n        \"warmup_epochs\":        3,              # the number of initial epochs during which the sizes of the 5 boxes in each cell is forced to match the sizes of the 5 anchors, this trick seems to improve precision emperically\n\n        \"object_scale\":         5.0 ,           # determine how much to penalize wrong prediction of confidence of object predictors\n        \"no_object_scale\":      1.0,            # determine how much to penalize wrong prediction of confidence of non-object predictors\n        \"coord_scale\":          1.0,            # determine how much to penalize wrong position and size predictions (x, y, w, h)\n        \"class_scale\":          1.0,            # determine how much to penalize wrong class prediction\n\n        \"debug\":                true            # turn on/off the line that prints current confidence, position, size, class losses and recall\n    },\n\n    \"valid\": {\n        \"valid_image_folder\":   \"\",\n        \"valid_annot_folder\":   \"\",\n\n        \"valid_times\":          1\n    }\n}\n\n```\n\nThe model section defines the type of the model to construct as well as other parameters of the model such as the input image size and the list of anchors. The ```labels``` setting lists the labels to be trained on. Only images, which has labels being listed, are fed to the network. The rest images are simply ignored. By this way, a Dog Detector can easily be trained using VOC or COCO dataset by setting ```labels``` to ```['dog']```.\n\nDownload pretrained weights for backend (tiny yolo, full yolo, squeezenet, mobilenet, and inceptionV3) at:\n\nhttps://drive.google.com/drive/folders/10oym4eL2RxJa0gro26vzXK__TtYOP5Ng\n\n**These weights must be put in the root folder of the repository. They are the pretrained weights for the backend only and will be loaded during model creation. The code does not work without these weights.**\n\nThe link to the pretrained weights for the whole model (both frontend and backend) of the raccoon detector can be downloaded at:\n\nhttps://drive.google.com/drive/folders/10oym4eL2RxJa0gro26vzXK__TtYOP5Ng\n\nThese weights can be used as the pretrained weights for any one class object detectors.\n\n### 3. Generate anchors for your dataset (optional)\n\n`python gen_anchors.py -c config.json`\n\nCopy the generated anchors printed on the terminal to the ```anchors``` setting in ```config.json```.\n\n### 4. Start the training process\n\n`python train.py -c config.json`\n\nBy the end of this process, the code will write the weights of the best model to file best_weights.h5 (or whatever name specified in the setting \"saved_weights_name\" in the config.json file). The training process stops when the loss on the validation set is not improved in 3 consecutive epoches.\n\n### 5. Perform detection using trained weights on an image by running\n`python predict.py -c config.json -w /path/to/best_weights.h5 -i /path/to/image/or/video`\n\nIt carries out detection on the image and write the image with detected bounding boxes to the same folder.\n\n## Usage for jupyter notebook\n\nRefer to the notebook (https://github.com/experiencor/basic-yolo-keras/blob/master/Yolo%20Step-by-Step.ipynb) for a complete walk-through implementation of YOLOv2 from scratch (training, testing, and scoring).\n\n## Evaluation of the current implementation:\n\n| Train        | Test          | mAP (with this implementation) | mAP (on released weights) |\n| -------------|:--------------|:------------------------:|:-------------------------:|\n| COCO train   | COCO val      | 28.6 |    42.1 |\n\nThe code to evaluate detection results can be found at https://github.com/experiencor/basic-yolo-keras/issues/27.\n\n## Copyright\n\nSee [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexperiencor%2Fkeras-yolo2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexperiencor%2Fkeras-yolo2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexperiencor%2Fkeras-yolo2/lists"}