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

请问:测试的时候出现这种错误怎么办,还有所得到的result的构成是怎样的? #25

Open
searchstorm opened this issue Mar 10, 2021 · 0 comments

Comments

@searchstorm
Copy link

错误:show_result(img, result, model.CLASSES)
File "yolodet-pytorch/yolodet/apis/inference.py", line 168, in show_result
label = rslt['label']
IndexError: too many indices for tensor of dimension 3

代码:
from yolodet.apis.inference import inference_detector,init_detector,show_result
import os

config_file ='cfg/yolov4_gpu.py'
checkpoint_file ='work_dirs/yolov4/latest.pth'

build the model from a config file and a checkpoint file

model = init_detector(config_file, checkpoint_file, device='cuda:0')

test a single image and show the results

img ='test.jpg' # or img = mmcv.imread(img), which will only load it once
result,t = inference_detector(model, img)
print('%s Done , object num : %s .time:(%.3fs)' % (img,len(result), t))

visualize the results in a new window

show_result(img, result, model.CLASSES)

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

1 participant