Tianxiaomo / pytorch-YOLOv4

PyTorch ,ONNX and TensorRT implementation of YOLOv4
Apache License 2.0
4.47k stars 1.49k forks source link

For 320*608 input size, Yolo_loss may have a bug? #358

Open 184338740 opened 3 years ago

184338740 commented 3 years ago

Train file train.py:

class Yolo_loss(nn.Module):
    def __init__(self, n_classes=80, n_anchors=3, device=None, batch=2):
        ...
        self.strides = [8, 16, 32]
        image_size = 608
        fsize = image_size // self.strides[i]
        ...
    def forward(self, xin, labels=None):
        ...
        fsize = output.shape[2]
        output = output.view(batchsize, self.n_anchors, n_ch, fsize, fsize)  # height_output = width_output
        ...

The output view to (fsize, fsize), such as (13,13) resolution. Yolo_loss function may just run for square input?

184338740 commented 3 years ago

What`s more Config file, cfg.py:

Cfg.width = 608 # width  = 320 + 96 * m, m in {0, 1, 2, 3, ...}  
Cfg.height = 608 # height = 320 + 96 * n, n in {0, 1, 2, 3, ...}
Cfg.w = Cfg.width
Cfg.h = Cfg.height

Image read file, dataset.py:

class Yolo_dataset(Dataset):
    self.cfg = cfg
    ai = image_data_augmentation(img, self.cfg.w, self.cfg.h, pleft, ptop, swidth, sheight, flip,  dhue, dsat, dexp, gaussian_noise, blur, truth)

Image Augmentation file where resize, dataset.py:

def image_data_augmentation(mat, w, h, pleft, ptop, swidth, sheight, flip, dhue, dsat, dexp, gaussian_noise, blur,truth):
    img = mat
    sized = cv2.resize(img, (w, h), cv2.INTER_LINEAR)