One ,yolov1 bounding box
bounding box How did it happen ? Produced by regression , regression ? oh dear , Oh, my God , I have forgotten what it is to return , ok , Let me give you an example of linear regression in junior high school
There are two sets of data A and B
A = [1,2,3,4,5]
B = [2,4,6,8,10]
Using the thought of regression to predict when A by 6 When B What is the corresponding value
Obviously, the regression parameter is 2, The regression process is y = 2x, therefore A by 6 When B The corresponding value should be 12, This is the simplest way to go back .
then yolo1 It is mentioned that the whole image is directly used to generate the network structure 7*7 Of grid cell, each grid
cell forecast x,y,w,h,confidence And so on , among confidence namely IOU It's worth it . The key is this bounding
box How did it come about , To me this kind of small white is still entangled for several days, calculate to understand to lose , So make a quick note , Welcome everyone to correct （ Excuse me for thinking too much , At my level blog And the big guy [ Laugh and cry ]）
good , Let's have a look Annotation Inside XML file , Take a look at it
You can see the Bounding box Is the format of , All by [xmin,xmax,ymin,ymax] form , What about the central coordinates ?
review yolov1 The paper also said that the coordinates and the length and width should be normalized , You don't get your central coordinates back ? At the end of the day scipts eureka vol_label.py The file knows that the center coordinates are based on the label xmin,xmax,ymin,ymax Calculated , Ha ha ha , See the code note below .
def convert(size, box): dw = 1./size # In normalization, the width is divided by the whole image_size Width of dh =
1./size # Normalization is done by dividing the height by the whole image_size The height of x = (box + box)/2.0 #
use (xmin+xmax)/2 obtain x The center point of y = (box + box)/2.0 # use (ymin+ymax)/2 obtain y The center point of w =
box - box # Then the width is used xmax-xmin Calculated h = box - box #
Then the height is used ymax-ymin Calculated x = x*dw # Normalized central coordinates x w = w*dw # normalization bbox width y = y*dh #
Normalized central coordinates y h = h*dh # normalization bbox height return (x,y,w,h) def convert_annotation(year,
image_id): in_file = open('VOCdevkit/VOC%s/Annotations/%s.xml'%(year,
image_id)) out_file = open('VOCdevkit/VOC%s/labels/%s.txt'%(year, image_id),
'w') tree=ET.parse(in_file) root = tree.getroot() size = root.find('size') w =
int(size.find('width').text) h = int(size.find('height').text) for obj in
root.iter('object'): difficult = obj.find('difficult').text cls =
obj.find('name').text if cls not in classes or int(difficult) == 1: continue
cls_id = classes.index(cls) xmlbox = obj.find('bndbox') # Getting annotation bbox And returned in tuples
b = (float(xmlbox.find('xmin').text), float(xmlbox.find('xmax').text),
float(xmlbox.find('ymin').text), float(xmlbox.find('ymax').text)) #
towards convert afferent size = (w,h), and b, They are (xmin,xmax,ymin,ymax) bb = convert((w,h), b)
out_file.write(str(cls_id) + " " + " ".join([str(a) for a in bb]) + '\n')
We have the central coordinates x,y and bbox Of w,h In this way, regression parameters can be trained happily
Waiting for the shift .. ..