Anchor regression: predicted relative coordinates, not direct pixels
The Anchor detector often encodes the object box as a relative reference box with a change in the centre of the logarithm scale.
Learning objectives and first steps2 objectives 2 first fixes
Try to do it after reading
- Encoding and Decoding Box Centre and Scale Offset
- Check coordinates and standardized parameters
Suggested first
- Thrust and Matrix Operations
- Basic neural network
Let's give the reference box and then predict how to adjust
The Anchor detector often encodes the object box as a relative reference box with a change in the centre of the logarithm scale. The reference boxes of different sizes use relative quantities rather than directly reverting to absolute pixels. Codes and decouplings must be aligned and not just four output names must be remembered.
Establishment of anchor centre [10,20], width 4 8; target centre [12,16], width 8 4 In the light of the basic agreement, dx =(12−10)/4=0.5, dy =(16−20)/8=−0.5, dw = log(8/4) = log2 , dh = log(4/8) =− log2 。 Decoding involves relative relocation of the centre, wide-band multiplier, and restoration of the original target.
If dx is incorrectly added directly to the pixel centre, move 0.5 instead of 2; The output scale is also wrong if dw is shown as a linear width difference. The value shape is still four, but geometrically different. There may also be additional weight coefficients in the process of realization, which must be reversed together.
Training matches are different from return targets
It is decided which anchor matches which true box, and then calculates the return target for the positive sample. Negative background anchor usually does not have the same target box back to monitor. Matching thresholds, positive-negative sampling and neglect have an impact on training distribution and should not return all anchor to the nearest frame without indicating the rules.
Greatness must be positive, otherwise logarithms cannot be defined. It is predicted that the dw oversized index may spill and that stabilization measures, such as cropping, may actually be used. The clippings limit the decoding range and should look at specific codes and not treat the theoretical index formula as a secure service without boundaries.
Coordinate formatting and image scaling should also be consistent. If anchor is at the coordinates of the scale and the target is at the coordinates of the original map, the deviation is abnormally large. The decoding result can be returned to the same coordinate system before the IoU is verified for decoding and rerouting.
References to this section Faster R-CNN and Torchvision The current box code is implemented. The values are synthetic box hand-counted and the detection model has not been trained. It explains a common parameterization that does not represent the same agreement for all non-anchor or other detectors.
Value recovery
import mathax,ay,aw,ah=10,20,4,8x,y,w,h=12,16,8,4dx,dy,dw,dh=(x-ax)/aw,(y-ay)/ah,math.log(w/aw),math.log(h/ah)restored=(ax+dx*aw,ay+dy*ah,aw*math.exp(dw),ah*math.exp(dh))assert all(math.isclose(a,b) for a,b in zip(restored,(x,y,w,h)))dx = 0.5, anchor wide 4 and how many pixels are actually moved by the centre?
Moves 2 because the relative shift is by the width of anchor.
Double width. What are the objectives of the logarithm width?
log2 about 0.693147, decoding indexes multiplied by the original width.
If the frame encoder uses four separate zoom weights, the training target is first multiplied by these weights and the decoding must be preceded by the application of the centre and index formula. Standard mean values and margins should likewise be saved. An effective self-measure is the random selection of the positive-wide composite frame, which is decoded immediately, checking for consistency within the reasonable floating-point tolerance limit, by item, at the centre, width and final angle.
Sources and reconciliations
Definitions, methods and interfaces are available.
Figures and calculations are reorganized according to this chapter. Mathematical measurements, framework operations and real business effects are described separately in the body of the text.