Giter Site home page Giter Site logo

ssisyphustao / object-detection-knowledge-distillation Goto Github PK

View Code? Open in Web Editor NEW
213.0 6.0 51.0 643 KB

An Object Detection Knowledge Distillation framework powered by pytorch, now having SSD and yolov5.

License: GNU General Public License v3.0

Python 100.00%
pytorch knowledge-distillation ssd object-detection deep-learning yolov5

object-detection-knowledge-distillation's Introduction

Object Detection Knowledge Distillation(ODKD)

version coverage

The function of this branch is not complete. For ssd and yolov5 distillation, checking other branches.

Release edition is coming Soon...

Update

  1. The first edition is the refactor of branch mbv2-lite, which is an implementation of Chen, G. et al. (2017) ‘Learning efficient object detection models with knowledge distillation’ with SSD-lite structure.

  2. Replace part of code with pytorch api which has same functionality.

  3. Very friendly beginner guidance.

  4. System Architecture

odkd

Useage

$ python setup.py install --user

$ odkd-train ./training_config.yml -t

$ odkd-train training_config.yml
or
$ python -m torch.distributed.launch --nproc_per_node=2 `which odkd-train` training_config.yml

$ odkd-eval ${CHECKPOINTS_PATH}/${RUN_INDEX}/config.yml

TODO

  • Evaluation Module

  • LOG Module

  • Coco dataset support

  • Yolov5 distillation

object-detection-knowledge-distillation's People

Contributors

ssisyphustao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

object-detection-knowledge-distillation's Issues

SSD mbv2

Is there any reason why the mbv2 model take so much time to evaluate compared to the vgg model??

No module named 'dcn_op_v2'

Dear @SsisyphusTao , thanks for starting this distillation approach with yolo v5.

I'm trying to run this on my computer, but I'm got this error: ModuleNotFoundError: No module named 'dcn_op_v2'.

I search on your others repositories, and I found the "Plugins for Pytorch & TensorRT". I've tried to install that, but I got another error: RuntimeError: Error compiling objects for extension.

Do you know how can I fix that?

Best regards,

how the dataset mean is computed?

Hello,
Can you please explain how these values were computed?

MEANS = (127, 127, 127)

I tried to compute them by myself on the VOC2007+2012 dataset, and I obtained these values:
(115.78, 110.57, 102.41)

thank you

Yolov5 : teacher bounded regression loss, Lb

Thanks for the awesome implementation.
I had a look at the losses and for the yolov5 implementation:

  1. this implementation does not have the teacher bounded regression loss.
  2. Also, the classification loss term does not include the term for soft targets. As mentioned in the paper, "It is known that
    a deep teacher can better fit to the training data and perform better in test scenarios. The soft labels
    contain information about the relationship between different classes as discovered by teacher. By
    learning from soft labels, the student network inherits such hidden information."

I wanted to ask if I am correct in pointing these out and if yes did you deliberately skipped these things?

Thanks

Bounded regression loss

https://github.com/SsisyphusTao/SSD-Knowledge-Distillation/blob/0597fbee635afcf0b8710ba3a9e40ab9f010aea5/nets/multibox_loss.py#L17-L23
F.mse_loss has reduction='mean' by default, but we should use reduction='sum' as for loss_l
https://github.com/SsisyphusTao/SSD-Knowledge-Distillation/blob/0597fbee635afcf0b8710ba3a9e40ab9f010aea5/nets/multibox_loss.py#L120
I think the next code corresponds to the formula from the article.

def bounded_regression_loss(Rs, Rt, gt, m, v=0.5):
    loss = torch.sum(F.mse_loss(Rs, gt, reduction='none'), 1)
    return torch.sum(loss * (loss + m > torch.sum(F.mse_loss(Rt, gt, reduction='none'), 1))) * v

RuntimeError: CUDA error: out of memory

Hi,

I always got the run time error after I ran python eval.py mbv2 --trained_model=checkpoints/student_mbv2_500_3934.pth. Does anyone know how to solve this error? Thanks.

hint loss is not work

the hint loss is too small to work and this loss is close to zero after few epochs quickly

The given teacher checkpoint (vgg) doesn't fit with the current version of VGG in the repo.

size mismatch for loc.0.weight: copying a param with shape torch.Size([16, 512, 3, 3]) from checkpoint, the shape in current model is torch.Size([16, 1024, 3, 3]).
        size mismatch for loc.1.weight: copying a param with shape torch.Size([24, 1024, 3, 3]) from checkpoint, the shape in current model is torch.Size([24, 512, 3, 3]).
        size mismatch for loc.2.weight: copying a param with shape torch.Size([24, 512, 3, 3]) from checkpoint, the shape in current model is torch.Size([24, 256, 3, 3]).
        size mismatch for loc.4.weight: copying a param with shape torch.Size([16, 256, 3, 3]) from checkpoint, the shape in current model is torch.Size([24, 256, 3, 3]).
        size mismatch for loc.4.bias: copying a param with shape torch.Size([16]) from checkpoint, the shape in current model is torch.Size([24]).
        size mismatch for loc.5.weight: copying a param with shape torch.Size([16, 256, 3, 3]) from checkpoint, the shape in current model is torch.Size([24, 256, 3, 3]).
        size mismatch for loc.5.bias: copying a param with shape torch.Size([16]) from checkpoint, the shape in current model is torch.Size([24]).
        size mismatch for conf.0.weight: copying a param with shape torch.Size([84, 512, 3, 3]) from checkpoint, the shape in current model is torch.Size([84, 1024, 3, 3]).
        size mismatch for conf.1.weight: copying a param with shape torch.Size([126, 1024, 3, 3]) from checkpoint, the shape in current model is torch.Size([126, 512, 3, 3]).
        size mismatch for conf.2.weight: copying a param with shape torch.Size([126, 512, 3, 3]) from checkpoint, the shape in current model is torch.Size([126, 256, 3, 3]).
        size mismatch for conf.4.weight: copying a param with shape torch.Size([84, 256, 3, 3]) from checkpoint, the shape in current model is torch.Size([126, 256, 3, 3]).
        size mismatch for conf.4.bias: copying a param with shape torch.Size([84]) from checkpoint, the shape in current model is torch.Size([126]).
        size mismatch for conf.5.weight: copying a param with shape torch.Size([84, 256, 3, 3]) from checkpoint, the shape in current model is torch.Size([126, 256, 3, 3]).
        size mismatch for conf.5.bias: copying a param with shape torch.Size([84]) from checkpoint, the shape in current model is torch.Size([126]).

How to run with no ground-truth data

Hello,
Firstly, thank you very much for this great repository.
I am really interested to run your code on a video, where the teacher transfers his knowledge to the student. However, since I am running on a video, there are no ground truth data available like in VOC/COCO datasets. What would change in the loss if I only use information from the outputs of the student and the teacher? and how do you think this would affect the training?

Thank you very much for your help

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.