Open qsc232344 opened 4 years ago
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
This problem may occured due to line146 in util.py(https://github.com/ayooshkathuria/pytorch-yolo-v3/blob/fbb4ef98d5a598f4c8eded6d618a599b7d289e2f/util.py#L146), 'imgpred.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 imagepred.size(0): output = 0 continue and insert a part of code before line215 in detect.py(https://github.com/ayooshkathuria/pytorch-yolo-v3/blob/fbb4ef98d5a598f4c8eded6d618a599b7d289e2f/detect.py#L215): 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!
great!it fix the problem!
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
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