Traffic-Light-Detection-Using-YOLOv3
Traffic-Light-Detection-Using-YOLOv3 copied to clipboard
RuntimeError: a view of a leaf Variable that requires grad is being used in an in-place operation.
trafficstars
https://github.com/sovit-123/Traffic-Light-Detection-Using-YOLOv3/blob/master/models.py#L112-L116 There is an issue with this code which fails with torch=1.8.0
Code need to be updated as follows
bias_ = module_list[j][0].bias.data # shape(255,)
bias = bias_[:modules.no * modules.na].view(modules.na, -1) # shape(3,85)
#bias[:, 4] += -4.5 # obj
bias[:, 4] += math.log(8 / (640 / stride[yolo_index]) ** 2) # obj (8 objects per 640 image)
bias[:, 5:] += math.log(0.6 / (modules.nc - 0.99)) # cls (sigmoid(p) = 1/nc)
module_list[j][0].bias = torch.nn.Parameter(bias, requires_grad=bias_.requires_grad)