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

Runtimeerror #132

Open
qsc232344 opened this issue Dec 5, 2019 · 4 comments
Open

Runtimeerror #132

qsc232344 opened this issue Dec 5, 2019 · 4 comments

Comments

@qsc232344
Copy link

File "detect.py", line 234, in
output = torch.cat((output,prediction))
RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 8 and 86 in dimension 1 at C:\w\1\s\windows\pytorch\aten\src\TH/generic/THTensor.cpp:689
How can I debug that? Thx

@barresoft
Copy link

barresoft commented Jan 9, 2020

The scripts continues if i modifly the line 230 of detect.py to :

        if not write:
            output = prediction
            write = 1
        else:
            output = prediction
            output = torch.cat((output,prediction))

but only the last detected image is boxed, i think that if the images are individually "detected", then all will have boxes

@chrisway613
Copy link

This problem may occured due to line146 in util.py(

image_pred_ = image_pred[non_zero_ind.squeeze(),:].view(-1,7)
), 'img_pred_.size(0)' may become 0 when filtered by 'non_zero_ind'.
Therefore, I solve this problem by add the code behind line146 as below:
if not image_pred_.size(0):
output = 0
continue
and insert a part of code before line215 in detect.py(
i += 1
):
for im_num, image in enumerate(imlist[i * batch_size: min((i + 1) * batch_size, len(imlist))]):
end = time.time()
im_id = i * batch_size + im_num
print("{0:20s} predicted in {1:6.3f} seconds".format(image.split("/")[-1], (end - start) / batch_size))
print("{0:20s} {1:s}".format("Object Detected:", 'None'))
print("----------------------------------------------------------")
this is for the compatible print out.
Hope this can help u, best wishes!

@pppaulpeter
Copy link

great!it fix the problem!

@siyuhe0120
Copy link

The scripts continues if i modifly the line 230 of detect.py to :

        if not write:
            output = prediction
            write = 1
        else:
            output = prediction
            output = torch.cat((output,prediction))

but only the last detected image is boxed, i think that if the images are individually "detected", then all will have boxes

if output.size()[1] == prediction.size()[1]:
output = torch.cat((output,prediction))
The remaining codes are consistent

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

5 participants