Answers.Body: <p>Object detection models behave the same during both, training and test phase, i.e. they just return thousands and thousands of bounding boxes as predictions, <strong>plus a confidence score for each box</strong> (important). What change between training and test is what we make out of these bounding boxes.</p>
  <p><strong>Trainining</strong>:<br />
  During training we want to assess how good each bounding box is with respect to our ground truth annotations, so what happen is usually a brutal comparison between each predicted bounding box with each true annotation box. Of course we need to quantify the quality of each predicted box vs true annotation, we can do that using <a href="https://en.wikipedia.org/wiki/Jaccard_index" rel="nofollow noreferrer">Intersection Over the Union</a>(IOU), i.e. percentage of shared pixels between the total area of the two boxes combined. We don't care during training about the amount of predictions the model return, we just want the model to learn to predict good boxes on overall.</p>
  <p><strong>Test:</strong><br />
  During test instead we want indeed to have a single box per object, but the model is still returning thousands of them, so we need to find a way to select one ourselves, and this is why the predicted confidence scores are important, otherwise we would have no idea about what boxes are better than others. The most common algorithm used to choose winning boxes depending on their confidence scores is called <a href="https://towardsdatascience.com/non-maximum-suppression-nms-93ce178e177c" rel="nofollow noreferrer">Non Maximum Suppression</a>.</p>
  <p>The picture below shows the algorithm (taken from the linked blog post).</p>
  <img src="https://i.sstatic.net/c10Ce.png" width="300" />
  <p>You can see that Non-Max Suppression work iteratively, starting from the box with highest confidence score, and checking the IOU between it and the remaining boxes. In order to work, an initial threshold parameter needs to be set, this threshold is used to determine if one of the remaining boxes should be kept and tested in the next iteration or not. Basically we want to discard boxes that overlap too much. Conceptually, if I have a box with high confidence score in a location, and another box overlapping a lot with it but with a lower confidence score, I want to keep only the first one and discard the second. If instead two boxes are not overlapping, then they might be detecting different objects, and I want to keep both. Notice that in a soft version of Non-Max Suppression the IOU score is used to update the confidence scores of each box as well. After converging, Non-Max Suppression will return the set of best non overlapping boxes.</p>
  <p><a href="https://i.sstatic.net/2XzAY.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/2XzAY.png" alt="enter image description here" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-03T11:29:58.127Z
Answers.Text: maybe I missed the point. I understand what you say sir, but it seems to me not exactly an answer to what I have asked. My question is about the ancor boxes. A am sure they are used to train a model on a dataset as they are being apposed to the ground truth boxes (backpropagation process adjustes them untill they fit to the location and size of ground truth boxes). 
  But I doubt that they are used in a common daily use of already trained yolo model. Am i right?
Answers.UserDisplayName: Igor
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-01T10:58:20.920Z
Answers.LastActivityDate: 2022-02-01T10:58:20.920Z
Answers.UserDisplayName: Edoardo Guerriero
Body: <p>another question in YOLO.
  I've red about how YOLO adjusts anchor boxes by offsets to create the final bounding boxes.
  What I do not understand, is when YOLO does it.
  Is it being done only during the training process, or also during the common use of already trained model?</p>
  
Tags: <convolutional-neural-networks><yolo><bounding-box>
Title: YOLO - are the anchor boxes used only in training?
UserDisplayName: Igor
ThreadText: # YOLO - are the anchor boxes used only in training?
  
  (Asked by: username_0 on 2022-01-31)
  
  another question in YOLO.
  I've red about how YOLO adjusts anchor boxes by offsets to create the final bounding boxes.
  What I do not understand, is when YOLO does it.
  Is it being done only during the training process, or also during the common use of already trained model?
  
  **Tags:** convolutional-neural-networks, yolo, bounding-box
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-02-01. Score: 2
  
  Object detection models behave the same during both, training and test phase, i.e. they just return thousands and thousands of bounding boxes as predictions, **plus a confidence score for each box** (important). What change between training and test is what we make out of these bounding boxes.
  
  **Trainining**:  
  During training we want to assess how good each bounding box is with respect to our ground truth annotations, so what happen is usually a brutal comparison between each predicted bounding box with each true annotation box. Of course we need to quantify the quality of each predicted box vs true annotation, we can do that using [Intersection Over the Union](https://en.wikipedia.org/wiki/Jaccard_index)(IOU), i.e. percentage of shared pixels between the total area of the two boxes combined. We don't care during training about the amount of predictions the model return, we just want the model to learn to predict good boxes on overall.
  
  **Test:**  
  During test instead we want indeed to have a single box per object, but the model is still returning thousands of them, so we need to find a way to select one ourselves, and this is why the predicted confidence scores are important, otherwise we would have no idea about what boxes are better than others. The most common algorithm used to choose winning boxes depending on their confidence scores is called [Non Maximum Suppression](https://towardsdatascience.com/non-maximum-suppression-nms-93ce178e177c).
  
  The picture below shows the algorithm (taken from the linked blog post).
  
  ![](https://i.sstatic.net/c10Ce.png)
  
  You can see that Non-Max Suppression work iteratively, starting from the box with highest confidence score, and checking the IOU between it and the remaining boxes. In order to work, an initial threshold parameter needs to be set, this threshold is used to determine if one of the remaining boxes should be kept and tested in the next iteration or not. Basically we want to discard boxes that overlap too much. Conceptually, if I have a box with high confidence score in a location, and another box overlapping a lot with it but with a lower confidence score, I want to keep only the first one and discard the second. If instead two boxes are not overlapping, then they might be detecting different objects, and I want to keep both. Notice that in a soft version of Non-Max Suppression the IOU score is used to update the confidence scores of each box as well. After converging, Non-Max Suppression will return the set of best non overlapping boxes.
  
  [![enter image description here](https://i.sstatic.net/2XzAY.png)](https://i.sstatic.net/2XzAY.png)
  
  > **Comments:**
  > **username_0**: maybe I missed the point. I understand what you say sir, but it seems to me not exactly an answer to what I have asked. My question is about the ancor boxes. A am sure they are used to train a model on a dataset as they are being apposed to the ground truth boxes (backpropagation process adjustes them untill they fit to the location and size of ground truth boxes).  But I doubt that they are used in a common daily use of already trained yolo model. Am i right?  
  
  ---
  
  