EfficientDet (Scalable and Efficient Object Detection) implementation in Keras and Tensorflow

Overview

EfficientDet

This is an implementation of EfficientDet for object detection on Keras and Tensorflow. The project is based on the official implementation google/automl, fizyr/keras-retinanet and the qubvel/efficientnet.

About pretrained weights

Thanks for their hard work. This project is released under the Apache License. Please take their licenses into consideration too when use this project.

Updates

  • [03/21/2020] Synchronize with the official implementation. google/automl
  • [03/05/2020] Anchor free version. The accuracy is a little lower, but it's faster and smaller.For details, please refer to xuannianz/SAPD
  • [02/20/2020] Support quadrangle detection. For details, please refer to README_quad

Train

build dataset

  1. Pascal VOC
    • Download VOC2007 and VOC2012, copy all image files from VOC2007 to VOC2012.
    • Append VOC2007 train.txt to VOC2012 trainval.txt.
    • Overwrite VOC2012 val.txt by VOC2007 val.txt.
  2. MSCOCO 2017
    • Download images and annotations of coco 2017
    • Copy all images into datasets/coco/images, all annotations into datasets/coco/annotations
  3. Other types please refer to fizyr/keras-retinanet)

train

  • STEP1: python3 train.py --snapshot imagenet --phi {0, 1, 2, 3, 4, 5, 6} --gpu 0 --random-transform --compute-val-loss --freeze-backbone --batch-size 32 --steps 1000 pascal|coco datasets/VOC2012|datasets/coco to start training. The init lr is 1e-3.
  • STEP2: python3 train.py --snapshot xxx.h5 --phi {0, 1, 2, 3, 4, 5, 6} --gpu 0 --random-transform --compute-val-loss --freeze-bn --batch-size 4 --steps 10000 pascal|coco datasets/VOC2012|datasets/coco to start training when val mAP can not increase during STEP1. The init lr is 1e-4 and decays to 1e-5 when val mAP keeps dropping down.

Evaluate

  1. PASCAL VOC

    • python3 eval/common.py to evaluate pascal model by specifying model path there.
    • The best evaluation results (score_threshold=0.01, mAP50) on VOC2007 test are:
    phi 0 1
    w/o weighted 0.8029
    w/ weighted 0.7892
  2. MSCOCO

    • python3 eval/coco.py to evaluate coco model by specifying model path there.
    phi mAP
    0 0.334 weights, results
    1 0.393 weights, results
    2 0.424 weights, results
    3 0.454 weights, results
    4 0.483 weights, results

Test

python3 inference.py to test your image by specifying image path and model path there.

image1

Comments
  • CSV dataset loading error

    CSV dataset loading error

    Thank you for your great work.

    I constructed my own dataset with csv file like under


    filename, xmin, ymin, xmax, ymax, class_name ...


    training looks like working well, but there are too many warning messages like under

    UserWarning: Image with id 745 (shape (896, 896, 3)) contains no valid boxes after transform image.shape

    b0 backbone is more often show the message, and b3 backbone has just few message Can I know what it means?

    wontfix 
    opened by kboseong 25
  • The difference of tensorflow.keras.model.Model() and keras.model.Model()

    The difference of tensorflow.keras.model.Model() and keras.model.Model()

    Thank you very much for your contribution and sharing. There is a question puzzled me. Why does tensorflow.keras.model.Model() work in model.py(build_regress_head() and build_class_head()), not keras.model.Model()? Is there any difference between them? Looking forward to your answer. Thank you very much.

    wontfix 
    opened by GithubAbner 20
  • No module named 'utils.compute_overlap'

    No module named 'utils.compute_overlap'

    Hello, firstly thank you for the great work.

    I am having trouble starting training. I get this error:

    -- No module named 'utils.compute_overlap' --

    I have the keras-retinanet running perfectly on my machine.

    What could be done?

    Regards!

    wontfix 
    opened by nicholasguimaraes 17
  • Output of scores variable using inference.py is -1 for the entire list of scores

    Output of scores variable using inference.py is -1 for the entire list of scores

    Hello @xuannianz , @km23630 , I am training the code for a task with two classes, but the code is unable to detect an image, it is giving -1 scores to all.

    I am using the following script for training the model.

    python train.py --snapshot imagenet --phi 1 --gpu 0 --random-transform --freeze-backbone --epochs 10 --batch-size 8 --steps 100 csv /work/traffic_dataset/train_labels_eff.csv /work/traffic_dataset/class_name_to_ID.csv

    I have made all necessary changes as RetinaNet as mentioned and RetinaNet works fine for me. Also, a normal coco models weights which were trained using EfficientDet also works, just that my own model.h5 file is not working

    opened by init-22 16
  •  No module named 'utils.compute_overlap'

    No module named 'utils.compute_overlap'

    Hi, When I try to run the train.py, I got error saying no module named 'utils.compute_overlap'. It's weird that there is a 'compute_overlap.pyx' file in 'utils' forlder. Should we just rename the suffix as 'py' and use this file?

    wontfix 
    opened by KaggleAlbertaAI 14
  • The loss is very low,but the mAP is 0 when training on my own datasets.

    The loss is very low,but the mAP is 0 when training on my own datasets.

    I am training on my own datasets using the code of April version,the loss is very low than previous version, but the mAP is always 0. Using the same config,Feb. code version has a high loss, but mAP is not zero. How can I solve the problem

    wontfix 
    opened by xinlnix 13
  • import error in windows: ModuleNotFoundError: No module named 'utils.compute_overlap'

    import error in windows: ModuleNotFoundError: No module named 'utils.compute_overlap'

    from utils.compute_overlap import compute_overlap When I run this import statement in windows, I get ModuleNotFoundError: No module named 'utils.compute_overlap'. How to fix this error?

    wontfix 
    opened by 2696120622 12
  • How to test

    How to test "custum csv model"?

    I understand that the "inference.py" file is a test file for PASCAL VOC data.

    How can I use inference.py for my csv data?

    Similarly, in /eval/commom.py it is difficult to evaluate csv data.

    Thanks.

    wontfix 
    opened by JooHyungSon 11
  • I face the same problem after using the latest code.

    I face the same problem after using the latest code.

    I face the same problem after using the latest code @ csv mode. The training process seems no problem. however there's no inference result. (no matter how I try ) could any one give some suggestion about the no inference at all phenomena?

    step1: python train.py --snapshot imagenet --phi 0 --gpu 0,1 --random-transform --freeze-backbone --compute-val-loss --batch-size 2 --steps 200 csv D:\wordG.csv D:\wordG.txt --val-annotations-path D:\wordG.csv

    step2:

    python train.py --snapshot checkpoints\2020-06-19\csv_50_0.0043_0.7948.h5 --phi 0 --gpu 0,1 --random-transform --freeze-bn --compute-val-loss --batch-size 2 --steps 200 csv D:\wordG.csv D:\wordG.txt --val-annotations-path D:\wordG.csv

    Epoch 00042: saving model to checkpoints/2020-06-19\csv_42_0.0081_0.2341.h5 200/200 [==============================] - 168s 840ms/step - loss: 0.0081 - classification_loss: 0.0021 - regression_loss: 0.0059 - val_loss: 0.2341 - val_classification_loss: 0.2016 - val_regression_loss: 0.0326 Epoch 43/50 199/200 [============================>.] - ETA: 0s - loss: 0.0065 - classification_loss: 0.0013 - regression_loss: 0.0052Epoch 1/50 245/200 [====================================] - 24s 99ms/step - loss: 0.2023 - classification_loss: 0.2089 - regression_loss: 0.0304 Running network: 100% (489 of 489) |##############################################################################################| Elapsed Time: 0:00:26 Time: 0:00:26 Parsing annotations: 100% (489 of 489) |##########################################################################################| Elapsed Time: 0:00:00 Time: 0:00:00 num_fp=34253.0, num_tp=2745.0 199 instances of class 0 with average precision: 0.8843 136 instances of class 1 with average precision: 0.8379 204 instances of class 2 with average precision: 0.9671 267 instances of class 3 with average precision: 0.9180 78 instances of class 4 with average precision: 0.7325 417 instances of class 5 with average precision: 0.9871 184 instances of class 6 with average precision: 1.0000 72 instances of class 7 with average precision: 1.0000 2 instances of class 8 with average precision: 1.0000 498 instances of class 9 with average precision: 0.9989 23 instances of class A with average precision: 0.0855 340 instances of class C with average precision: 0.9917 23 instances of class K with average precision: 1.0000 23 instances of class L with average precision: 1.0000 320 instances of class R with average precision: 0.9190 2 instances of class T with average precision: 1.0000 1 instances of class U with average precision: 1.0000 1 instances of class V with average precision: 1.0000 1 instances of class X with average precision: 0.0048 mAP: 0.8593

    Epoch 00043: saving model to checkpoints/2020-06-19\csv_43_0.0065_0.2393.h5 200/200 [==============================] - 168s 841ms/step - loss: 0.0065 - classification_loss: 0.0013 - regression_loss: 0.0052 - val_loss: 0.2393 - val_classification_loss: 0.2089 - val_regression_loss: 0.0304 Epoch 44/50 104/200 [==============>...............] - ETA: 56s - loss: 0.0054 - classification_loss: 7.3843e-04 - regression_loss: 0.0046Traceback (most recent call last):.

    Originally posted by @fiyerowei in https://github.com/xuannianz/EfficientDet/issues/117#issuecomment-646406922

    wontfix 
    opened by fiyerowei 10
  • how to design anchor ratios and scales?

    how to design anchor ratios and scales?

    wanna train on custom dataset, using default coco anchor settings, the big target can detect while small target always miss.

    Did I miss something in such situation?

    wontfix 
    opened by jinfagang 10
  • mscoco pretrained weights uncorrect!

    mscoco pretrained weights uncorrect!

    I downloaded the mscoco pretrained weights (d0, d1 and d2), and test with the script inference.py. The output scores are all very small, around 0.01. I found that the model can output different scores with the same input and model weights. I guess there is something wrong in the pretrained weights, and the script inference.py can not load all model weights correctly. Can you check this please?

    wontfix 
    opened by luckycallor 10
  • Some advice about license compliance

    Some advice about license compliance

    Hello, such a nice repository benefits me a lot and so kind of you to make it open source!

    Question There’s some possible legal issues on the license of your repository when you combine numerous third-party packages. For instance, random, argparse and datetime you imported are licensed with Python Software Foundation License, Python Software Foundation License and Zope Public License (ZPL 2.1), respectively. However, the Apache License of your repository are less strict than above package licenses on some terms, which has violated the whole license compatibility in your repository and may bring legal and financial risks.

    Advice You can select another proper license for your repository, or write a custom license with license exception if some license terms couldn’t be summed up consistently.

    Best wishes!

    opened by Ashley123456789 0
  • Bump pillow from 6.2.0 to 9.3.0

    Bump pillow from 6.2.0 to 9.3.0

    Bumps pillow from 6.2.0 to 9.3.0.

    Release notes

    Sourced from pillow's releases.

    9.3.0

    https://pillow.readthedocs.io/en/stable/releasenotes/9.3.0.html

    Changes

    ... (truncated)

    Changelog

    Sourced from pillow's changelog.

    9.3.0 (2022-10-29)

    • Limit SAMPLESPERPIXEL to avoid runtime DOS #6700 [wiredfool]

    • Initialize libtiff buffer when saving #6699 [radarhere]

    • Inline fname2char to fix memory leak #6329 [nulano]

    • Fix memory leaks related to text features #6330 [nulano]

    • Use double quotes for version check on old CPython on Windows #6695 [hugovk]

    • Remove backup implementation of Round for Windows platforms #6693 [cgohlke]

    • Fixed set_variation_by_name offset #6445 [radarhere]

    • Fix malloc in _imagingft.c:font_setvaraxes #6690 [cgohlke]

    • Release Python GIL when converting images using matrix operations #6418 [hmaarrfk]

    • Added ExifTags enums #6630 [radarhere]

    • Do not modify previous frame when calculating delta in PNG #6683 [radarhere]

    • Added support for reading BMP images with RLE4 compression #6674 [npjg, radarhere]

    • Decode JPEG compressed BLP1 data in original mode #6678 [radarhere]

    • Added GPS TIFF tag info #6661 [radarhere]

    • Added conversion between RGB/RGBA/RGBX and LAB #6647 [radarhere]

    • Do not attempt normalization if mode is already normal #6644 [radarhere]

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    wontfix dependencies 
    opened by dependabot[bot] 1
  • Bump tensorflow-gpu from 1.15.0 to 2.9.3

    Bump tensorflow-gpu from 1.15.0 to 2.9.3

    Bumps tensorflow-gpu from 1.15.0 to 2.9.3.

    Release notes

    Sourced from tensorflow-gpu's releases.

    TensorFlow 2.9.3

    Release 2.9.3

    This release introduces several vulnerability fixes:

    TensorFlow 2.9.2

    Release 2.9.2

    This releases introduces several vulnerability fixes:

    ... (truncated)

    Changelog

    Sourced from tensorflow-gpu's changelog.

    Release 2.9.3

    This release introduces several vulnerability fixes:

    Release 2.8.4

    This release introduces several vulnerability fixes:

    ... (truncated)

    Commits
    • a5ed5f3 Merge pull request #58584 from tensorflow/vinila21-patch-2
    • 258f9a1 Update py_func.cc
    • cd27cfb Merge pull request #58580 from tensorflow-jenkins/version-numbers-2.9.3-24474
    • 3e75385 Update version numbers to 2.9.3
    • bc72c39 Merge pull request #58482 from tensorflow-jenkins/relnotes-2.9.3-25695
    • 3506c90 Update RELEASE.md
    • 8dcb48e Update RELEASE.md
    • 4f34ec8 Merge pull request #58576 from pak-laura/c2.99f03a9d3bafe902c1e6beb105b2f2417...
    • 6fc67e4 Replace CHECK with returning an InternalError on failing to create python tuple
    • 5dbe90a Merge pull request #58570 from tensorflow/r2.9-7b174a0f2e4
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    wontfix dependencies 
    opened by dependabot[bot] 1
Owner
null
Mask R-CNN for object detection and instance segmentation on Keras and TensorFlow

Mask R-CNN for Object Detection and Segmentation This is an implementation of Mask R-CNN on Python 3, Keras, and TensorFlow. The model generates bound

Matterport, Inc 22.5k Jan 4, 2023
This is an implementation of Googles Yogi-Optimizer in Keras (tf.keras)

Yogi-Optimizer_Keras This is an implementation of Googles Yogi-Optimizer in Keras (tf.keras) The NeurIPS-Paper can be found here: http://papers.nips.c

null 14 Sep 13, 2022
Keras udrl - Keras implementation of Upside Down Reinforcement Learning

keras_udrl Keras implementation of Upside Down Reinforcement Learning This is me

Eder Santana 7 Jan 24, 2022
Face Mask Detection on Image and Video using tensorflow and keras

Face-Mask-Detection Face Mask Detection on Image and Video using tensorflow and keras Train Neural Network on face-mask dataset using tensorflow and k

Nahid Ebrahimian 12 Nov 11, 2022
Hybrid CenterNet - Hybrid-supervised object detection / Weakly semi-supervised object detection

Hybrid-Supervised Object Detection System Object detection system trained by hybrid-supervision/weakly semi-supervision (HSOD/WSSOD): This project is

null 5 Dec 10, 2022
Yolo object detection - Yolo object detection with python

How to run download required files make build_image make download Docker versio

null 3 Jan 26, 2022
(JMLR'19) A Python Toolbox for Scalable Outlier Detection (Anomaly Detection)

Python Outlier Detection (PyOD) Deployment & Documentation & Stats Build Status & Coverage & Maintainability & License PyOD is a comprehensive and sca

Yue Zhao 6.6k Jan 3, 2023
Si Adek Keras is software VR dangerous object detection.

Si Adek Python Keras Sistem Informasi Deteksi Benda Berbahaya Keras Python. Version 1.0 Developed by Ananda Rauf Maududi. Developed date: 24 November

Ananda Rauf 1 Dec 21, 2021
Classification models 1D Zoo - Keras and TF.Keras

Classification models 1D Zoo - Keras and TF.Keras This repository contains 1D variants of popular CNN models for classification like ResNets, DenseNet

Roman Solovyev 12 Jan 6, 2023
Example-custom-ml-block-keras - Custom Keras ML block example for Edge Impulse

Custom Keras ML block example for Edge Impulse This repository is an example on

Edge Impulse 8 Nov 2, 2022
Segcache: a memory-efficient and scalable in-memory key-value cache for small objects

Segcache: a memory-efficient and scalable in-memory key-value cache for small objects This repo contains the code of Segcache described in the followi

TheSys Group @ CMU CS 78 Jan 7, 2023
Tensorflow 2.x implementation of Panoramic BlitzNet for object detection and semantic segmentation on indoor panoramic images.

Deep neural network for object detection and semantic segmentation on indoor panoramic images. The implementation is based on the papers:

Alejandro de Nova Guerrero 9 Nov 24, 2022
Implementation of ConvMixer in TensorFlow and Keras

ConvMixer ConvMixer, an extremely simple model that is similar in spirit to the ViT and the even-more-basic MLP-Mixer in that it operates directly on

Sayan Nath 8 Oct 3, 2022
Implementation of ConvMixer-Patches Are All You Need? in TensorFlow and Keras

Patches Are All You Need? - ConvMixer ConvMixer, an extremely simple model that is similar in spirit to the ViT and the even-more-basic MLP-Mixer in t

Sayan Nath 8 Oct 3, 2022
Unofficial Tensorflow-Keras implementation of Fastformer based on paper [Fastformer: Additive Attention Can Be All You Need](https://arxiv.org/abs/2108.09084).

Fastformer-Keras Unofficial Tensorflow-Keras implementation of Fastformer based on paper Fastformer: Additive Attention Can Be All You Need. Tensorflo

Yam Peleg 10 Jan 30, 2022
A Keras implementation of YOLOv4 (Tensorflow backend)

keras-yolo4 请使用更完善的版本: https://github.com/miemie2013/Keras-YOLOv4 Please visit here for more complete model: https://github.com/miemie2013/Keras-YOLOv

null 384 Nov 29, 2022
A tensorflow/keras implementation of StyleGAN to generate images of new Pokemon.

PokeGAN A tensorflow/keras implementation of StyleGAN to generate images of new Pokemon. Dataset The model has been trained on dataset that includes 8

null 19 Jul 26, 2022