Skip to content

About problems that arise when running the test.py script #123

@AntyRia

Description

@AntyRia

Thanks for your great contribution, I have encountered some problems while using your script:

I changed the entry part of test.py to fix the use of config and checkpoint

if name == 'main':
parser = argparse.ArgumentParser(description='Hyperparams')
parser.add_argument('--config', help='config file path', default='config/pan_pp/pan_pp_r18_ic15_736_det_only.py')
parser.add_argument('--checkpoint', nargs='?', type=str, default='checkpoints/pan_r18_ic15/panpp_r18_ic15_det.pth.tar')
parser.add_argument('--report_speed', action='store_true', default=True)
parser.add_argument('--vis', action='store_true')
parser.add_argument('--debug', action='store_true')
args = parser.parse_args()
main(args)

In addition, I have prepared the data set in a format, i got an error when i python test.py, the error message is as follows:

Traceback (most recent call last):
File "test.py", line 168, in
main(args)
File "test.py", line 156, in main
test(test_loader, model, cfg)
File "test.py", line 81, in test
for idx, data in enumerate(test_loader):
File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 530, in next
data = self._next_data()
File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1224, in _next_data
return self._process_data(data)
File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1250, in _process_data
data.reraise()
File "/opt/conda/lib/python3.8/site-packages/torch/_utils.py", line 457, in reraise
raise exception
TypeError: Caught TypeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop
data = fetcher.fetch(index)
File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/opt/conda/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/data/project/pan_pp/dataset/pan_pp/pan_pp_ic15.py", line 482, in getitem
return self.prepare_test_data(index)
File "/data/project/pan_pp/dataset/pan_pp/pan_pp_ic15.py", line 465, in prepare_test_data
img = transform_pic(img)
File "/opt/conda/lib/python3.8/site-packages/torchvision/transforms/transforms.py", line 95, in call
img = t(img)
File "/opt/conda/lib/python3.8/site-packages/torchvision/transforms/transforms.py", line 135, in call
return F.to_tensor(pic)
File "/opt/conda/lib/python3.8/site-packages/torchvision/transforms/functional.py", line 147, in to_tensor
img = torch.from_numpy(np.array(pic, mode_to_nptype.get(pic.mode, np.uint8), copy=True))
TypeError: array() takes 1 positional argument but 2 were given

I checked img = transforms.ToTensor()(img) in dataset/pan_pp/pan_pp_ic15.py and there was no error in its type. I wondered what to do in this case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions