As Gent and Saif have said, the YOLO algorithm learns that through training based on labelled data that includes the bounding boxes. If you want to dig deeper into how the algorithm works, there are a number of detailed threads about YOLO on the forums, e.g. this one would be a good place to start and it links to some others.
1 Like