PyTorch_YOLOv4 icon indicating copy to clipboard operation
PyTorch_YOLOv4 copied to clipboard

Use Transfer Learning YoloV4 and yolov4 tiny

Open anantgupta129 opened this issue 4 years ago • 2 comments

How can I use pre trained weights on COCO dataset and finetune them on my dataset for yolov4 and yolov4 tiny? While loading the model only Pytorch weights are used.

Can i add this in https://github.com/WongKinYiu/PyTorch_YOLOv4/blob/master/train.py#L86

    pretrained = weights.endswith('.pt')
    if pretrained:
        with torch_distributed_zero_first(rank):
            attempt_download(weights)  # download if not found locally
        ckpt = torch.load(weights, map_location=device)  # load checkpoint
        model = Darknet(opt.cfg).to(device)  # create
        state_dict = {k: v for k, v in ckpt['model'].items() if model.state_dict()[k].numel() == v.numel()}
        model.load_state_dict(state_dict, strict=False)
        print('Transferred %g/%g items from %s' % (len(state_dict), len(model.state_dict()), weights))  # report
    else:
        model = Darknet(opt.cfg).to(device) # create
         load_darknet_weights(model, 'yolov4-tiny.weights')

@WongKinYiu @glenn-jocher

anantgupta129 avatar Dec 23 '21 03:12 anantgupta129

Is it work?

ingbeeedd avatar Mar 10 '22 11:03 ingbeeedd

Is it working?

parthkvv avatar Sep 30 '22 15:09 parthkvv