Answers.Body: <p>The classification head works as follows.</p>
  <p>After the stack of <code>BiFPN</code> we have a feature map of size <code>B x C x H x W</code>.</p>
  <p>For EfficientDet <code>H</code> and <code>W</code> are <code>1/8</code> of the input image size.</p>
  <p>Then for each pixel in this feature map one applies one convolution to get the bounding boxes. The model predicts <code>n_anchors</code> - rescaled and shifted versions of reference boxes. The number of output convolution channels is <code>n_anchors x 4</code>. 4 channels are for the location and scale of each box.</p>
  <p>Another convolution predicts the probabilities of a class for each particular location on the grid. The number of output convolution channels is the number of pixels and the outputs are just the logits as for the classification problem.</p>
  <p>You have not mentioned the code you're looking at. But I recommend to have a look at <a href="https://github.com/rwightman/efficientdet-pytorch/blob/master/effdet/efficientdet.py" rel="nofollow noreferrer">rwightman's implementation</a> (if you are familiar with PyTorch).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-26T19:23:29.800Z
Answers.LastActivityDate: 2021-12-26T19:23:29.800Z
Answers.UserDisplayName: spiridon_the_sun_rotator
Body: <p>EfficientDet outputs classes and bounding boxes. My question is about both but specifically I am interested in the class prediction net part. In the paper's diagram it shows 2 conv layers. I don't understand the code and how it works. And what's the difference between the 2 conv layers of classification and box prediction?</p>
  <p><a href="https://i.sstatic.net/CDBJu.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/CDBJu.jpg" alt="enter image description here" /></a></p>
  
Tags: <deep-learning><computer-vision><object-detection><object-recognition><semantic-segmentation>
Title: How does the classification head of EfficientDet work?
UserDisplayName: ML Dev
ThreadText: # How does the classification head of EfficientDet work?
  
  (Asked by: username_0 on 2021-12-25)
  
  EfficientDet outputs classes and bounding boxes. My question is about both but specifically I am interested in the class prediction net part. In the paper's diagram it shows 2 conv layers. I don't understand the code and how it works. And what's the difference between the 2 conv layers of classification and box prediction?
  
  [![enter image description here](https://i.sstatic.net/CDBJu.jpg)](https://i.sstatic.net/CDBJu.jpg)
  
  **Tags:** deep-learning, computer-vision, object-detection, object-recognition, semantic-segmentation
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-12-26. Score: 1
  
  The classification head works as follows.
  
  After the stack of `BiFPN` we have a feature map of size `B x C x H x W`.
  
  For EfficientDet `H` and `W` are `1/8` of the input image size.
  
  Then for each pixel in this feature map one applies one convolution to get the bounding boxes. The model predicts `n_anchors` - rescaled and shifted versions of reference boxes. The number of output convolution channels is `n_anchors x 4`. 4 channels are for the location and scale of each box.
  
  Another convolution predicts the probabilities of a class for each particular location on the grid. The number of output convolution channels is the number of pixels and the outputs are just the logits as for the classification problem.
  
  You have not mentioned the code you're looking at. But I recommend to have a look at [rwightman's implementation](https://github.com/rwightman/efficientdet-pytorch/blob/master/effdet/efficientdet.py) (if you are familiar with PyTorch).
  
  
  ---
  
  