Tencent / FaceDetection-DSFD

腾讯优图高精度双分支人脸检测器
Other
2.91k stars 728 forks source link

model file is too large #6

Closed MichaelGou1105 closed 5 years ago

MichaelGou1105 commented 5 years ago

when i run python demo.py, the issue

CUDA out of memory,Tried to allocate 62.00 MiB (GPU 0; 22.38 GiB total capacity; 20.83 GiB already allocated; 20.06 MiB free; 276.64 MiB cached)
ChandanKumarAAI commented 5 years ago

Can you please specify your pytorch version?

DecentMakeover commented 5 years ago

Hi

Facing a similar issue, Not able to run the demo.py file.

DecentMakeover commented 5 years ago

@ChandanKumarAAI Were you able to get predictions using the demo.py file?

ChandanKumarAAI commented 5 years ago

My torch version is 0.4, and I was facing the same issue, so I updated the following code, and now it is working.

def infer(net , img , transform , thresh , cuda , shrink): if shrink != 1: img = cv2.resize(img, None, None, fx=shrink, fy=shrink, interpolation=cv2.INTER_LINEAR) x = torch.from_numpy(transform(img)[0]).permute(2, 0, 1) with torch.no_grad(): x = Variable(x.unsqueeze(0)) if cuda: x = x.cuda()

print (shrink , x.shape)

    y = net(x)      # forward pass
    detections = y.data
    # scale each detection back up to the image
    scale = torch.Tensor([ img.shape[1]/shrink, img.shape[0]/shrink,
                     img.shape[1]/shrink, img.shape[0]/shrink] )
    det = []
    for i in range(detections.size(1)):
        j = 0
        while detections[0, i, j, 0] >= thresh:
            score = detections[0, i, j, 0].cpu().numpy()
            #label_name = labelmap[i-1]
            pt = (detections[0, i, j, 1:]*scale).cpu().numpy()
            #print ("#"*20,type(pt), pt)
            coords = (pt[0], pt[1], pt[2], pt[3]) 
            det.append([pt[0], pt[1], pt[2], pt[3], score])
            j += 1
    if (len(det)) == 0:
        det = [ [0.1,0.1,0.2,0.2,0.01] ]
    det = np.array(det)

    keep_index = np.where(det[:, 4] >= 0)[0]
    det = det[keep_index, :]
    return det
ChandanKumarAAI commented 5 years ago

@DecentMakeover yes I was able to get prediction from demo.py.

ChandanKumarAAI commented 5 years ago

Screenshot from 2019-03-18 11-42-36

DecentMakeover commented 5 years ago

Okay let me try this.

ChaunceyWang commented 5 years ago

@AnberLu @ChandanKumarAAI @DecentMakeover It's mainly caused by torch version. Someone faces this similar problem. The torch version we used is 0.3.1.