代码书写位置
pytorch从零开始YOLOV4的neck部分代码写在yolo4.py里
整体代码
整体代码如下:
import torch.nn as nn
import torch.nn.functional as F
import torch
import numpy as np
def yolo_decode(output, num_classes, anchors, num_anchors, scale_x_y):
device = None
cuda_check = output.is_cuda
if cuda_check:
device = output.get_device()
n_ch = 4+1+num_classes
A = num_anchors
B = output.size(0)
H = output.size(2)
W = output.size(3)
output = output.view(B, A, n_ch, H, W).permute(0,1,3,4,2).contiguous()
bx, by = output[..., 0], output[..., 1]
bw, bh = output[..., 2], output[...,