Answers.Body: <p>In effect, the midpoint is contained in cell <span class="math-container">$2$</span>. Cells <span class="math-container">$1,3,4$</span> will be shown at <span class="math-container">$P_c=0$</span> according to the YOLO algorithm, which only takes in count the cell that contains the midpoint and calculates the bounding box, as you mentioned, with <span class="math-container">$b_y b_x, b_y, b_h, b_w$</span>. With the proposition of <span class="math-container">$Y = [1, 0.9, 0.1, 2, 2]$</span>, I would think that if you take the point <span class="math-container">$(0,0)$</span> as the left-upper corner, <span class="math-container">$Y$</span> would be more likely to be <span class="math-container">$Y = [1,0.2,0.57,0.21,0.15]$</span>, being calculated with a grid of <span class="math-container">$19 \times 19$</span>.</p>
  <p><a href="https://i.sstatic.net/NzU0a.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/NzU0a.png" alt="Representation of the bx and by values" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-13T04:38:35.957Z
Answers.Text: Thank you for answering my question. Still I have queries. But What  bx, by, bh, bw values should I give for cell 1,3,4 as we are giving Pc as 0? Are you sure that we have to take only the cell contains mid points? Also can you explain the calculations being done for Y = [1,0.2,0.57,0.21,0.15]? Thank you for the help.
Answers.UserDisplayName: Gokulakannan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-13T05:09:14.717Z
Answers.Text: In fact,  Y.O.L.O. algorithm doesn't compute any calculations in cells with Pc=0, then the values over these cells (1,3,4) are irrelevant for the algorithm, that's why the representation is [0, ?, ?, ?, ?] . Calculations over  bx, by, bh, and bw are computed with a simple rule of three. I attached an image in the answer to represent it.
Answers.UserDisplayName: Bitzel
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-12T21:46:23.837Z
Answers.LastActivityDate: 2021-01-28T23:27:48.850Z
Answers.LastEditDate: 2021-01-28T23:27:48.850Z
Answers.UserDisplayName: Bitzel
Body: <p>I am having a question on how to label training data for YOLO algorithm.</p>
  <p>Let's say that each label Y, we need to specify <span class="math-container">$[P_c, b_x, b_y, b_h, b_w]$</span>, where <span class="math-container">$P_c$</span> is the indicator for presence (1=present, 0=not present), <span class="math-container">$(b_x, b_y)$</span> is the relative position of the center of the object-of-interest, and <span class="math-container">$(b_h, b_w)$</span> is the relative dimension of the bounding box containing the object.</p>
  <p>Using picture below as an example, the cell (1,2), which contains a black car, should have a label <span class="math-container">$Y = [1, 0.4, 0.3, 0.9, 0.5]$</span>. And for any cells without cars, they should have a label <span class="math-container">$[0, ?, ?, ?, ?]$</span> [Coursera Deep Learning Specialization Materials]</p>
  <p><a href="https://i.sstatic.net/MehFy.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/MehFy.jpg" alt="enter image description here" /></a></p>
  <p>But if we have a finer grid like this, where the dimension of each cells is smaller than the ground truth bounding box.</p>
  <p><a href="https://i.sstatic.net/kw1Hg.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/kw1Hg.jpg" alt="enter image description here" /></a></p>
  <p>Let's say that the ground truth bounding box for the car is the red box, and the ground truth center point is the red dot, which is in cell 2.</p>
  <p>For cell 2 it will have label <span class="math-container">$Y = [1, 0.9, 0.1, 2, 2]$</span>, is this correct? And for cell <span class="math-container">$1, 3, 4$</span> what kind of label will they have? Do they have <span class="math-container">$P_c=1$</span> or <span class="math-container">$P_c = 0$</span>? And if <span class="math-container">$P_c=1$</span>, how will the <span class="math-container">$b_x$</span> and <span class="math-container">$b_y$</span> be? (As I remember that <span class="math-container">$b_x, b_y$</span> should have value between <span class="math-container">$0$</span> and <span class="math-container">$1$</span>. But in cell <span class="math-container">$1,3,4$</span> there is no center point of the object-of-interest)</p>
  
Tags: <convolutional-neural-networks><computer-vision><object-recognition><yolo>
Title: How to label training data for YOLO
UserDisplayName: Gokulakannan
ThreadText: # How to label training data for YOLO
  
  (Asked by: username_0 on 2018-07-11)
  
  I am having a question on how to label training data for YOLO algorithm.
  
  Let's say that each label Y, we need to specify $[P\_c, b\_x, b\_y, b\_h, b\_w]$, where $P\_c$ is the indicator for presence (1=present, 0=not present), $(b\_x, b\_y)$ is the relative position of the center of the object-of-interest, and $(b\_h, b\_w)$ is the relative dimension of the bounding box containing the object.
  
  Using picture below as an example, the cell (1,2), which contains a black car, should have a label $Y = [1, 0.4, 0.3, 0.9, 0.5]$. And for any cells without cars, they should have a label $[0, ?, ?, ?, ?]$ [Coursera Deep Learning Specialization Materials]
  
  [![enter image description here](https://i.sstatic.net/MehFy.jpg)](https://i.sstatic.net/MehFy.jpg)
  
  But if we have a finer grid like this, where the dimension of each cells is smaller than the ground truth bounding box.
  
  [![enter image description here](https://i.sstatic.net/kw1Hg.jpg)](https://i.sstatic.net/kw1Hg.jpg)
  
  Let's say that the ground truth bounding box for the car is the red box, and the ground truth center point is the red dot, which is in cell 2.
  
  For cell 2 it will have label $Y = [1, 0.9, 0.1, 2, 2]$, is this correct? And for cell $1, 3, 4$ what kind of label will they have? Do they have $P\_c=1$ or $P\_c = 0$? And if $P\_c=1$, how will the $b\_x$ and $b\_y$ be? (As I remember that $b\_x, b\_y$ should have value between $0$ and $1$. But in cell $1,3,4$ there is no center point of the object-of-interest)
  
  **Tags:** convolutional-neural-networks, computer-vision, object-recognition, yolo
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-07-12. Score: 2 | Accepted answer
  
  In effect, the midpoint is contained in cell $2$. Cells $1,3,4$ will be shown at $P\_c=0$ according to the YOLO algorithm, which only takes in count the cell that contains the midpoint and calculates the bounding box, as you mentioned, with $b\_y b\_x, b\_y, b\_h, b\_w$. With the proposition of $Y = [1, 0.9, 0.1, 2, 2]$, I would think that if you take the point $(0,0)$ as the left-upper corner, $Y$ would be more likely to be $Y = [1,0.2,0.57,0.21,0.15]$, being calculated with a grid of $19 \times 19$.
  
  [![Representation of the bx and by values](https://i.sstatic.net/NzU0a.png)](https://i.sstatic.net/NzU0a.png)
  
  > **Comments:**
  > **username_0**: Thank you for answering my question. Still I have queries. But What  bx, by, bh, bw values should I give for cell 1,3,4 as we are giving Pc as 0? Are you sure that we have to take only the cell contains mid points? Also can you explain the calculations being done for Y = [1,0.2,0.57,0.21,0.15]? Thank you for the help.  
  > **username_1**: In fact,  Y.O.L.O. algorithm doesn't compute any calculations in cells with Pc=0, then the values over these cells (1,3,4) are irrelevant for the algorithm, that's why the representation is [0, ?, ?, ?, ?] . Calculations over  bx, by, bh, and bw are computed with a simple rule of three. I attached an image in the answer to represent it.  
  
  ---
  
  