Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

model file is too large #6

Closed
MichaelGou1105 opened this issue Mar 18, 2019 · 8 comments
Closed

model file is too large #6

MichaelGou1105 opened this issue Mar 18, 2019 · 8 comments

Comments

@MichaelGou1105
Copy link

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
Copy link

Can you please specify your pytorch version?

@DecentMakeover
Copy link

Hi

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

@DecentMakeover
Copy link

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

@ChandanKumarAAI
Copy link

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
Copy link

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

@ChandanKumarAAI
Copy link

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

@DecentMakeover
Copy link

Okay let me try this.

@ChaunceyWang
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants