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 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[0] # In normalization, the width is divided by the whole image_size Width of dh =
1./size[1] # Normalization is done by dividing the height by the whole image_size The height of x = (box[0] + box[1])/2.0 #
use (xmin+xmax)/2 obtain x The center point of y = (box[2] + box[3])/2.0 # use (ymin+ymax)/2 obtain y The center point of w =
box[1] - box[0] # Then the width is used xmax-xmin Calculated h = box[3] - box[2] #
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 .. ..

©2019-2020 Toolsou All rights reserved,
【 Explain in detail 】 Interview must ask :SpringBoot Automatic configuration principle 【 Hyper detail 】Java Realization of student information management system 2020 The 11th National Blue Bridge Cup Python group JavaScript note ( five )---- Branch statement MYSQL database SQL Sentence practice experiment EXERCISES. 1 SIMPLE COMMANDSMySQL Basics Commonly used sentence ( Add / delete / modify query )C++ of string of compare usage vue limit input Only positive numbers can be entered C Language of a Gobang game implementation Programmer refused due to low salary offer,HR become shame , Netizens instantly blew up ..