MiniBullLab / easy_ai

3 stars 1 forks source link

one class运行报错 #136

Closed foww-0001 closed 3 years ago

foww-0001 commented 3 years ago

运行命令:

python3 easyai/tools/feature_save/one_class_feature_save.py -t one_class -i /home/wfw/data/VOCdevkit/MVTec/bottle/ImageSets/train.txt -m PadimNet -w /home/wfw/workspace/HASCO/all_wights/wide_resnet50_2_patchcore.pt -c example/padim_config.json

报错如下:

Traceback (most recent call last):
  File "easyai/tools/feature_save/one_class_feature_save.py", line 62, in <module>
    main()
  File "easyai/tools/feature_save/one_class_feature_save.py", line 57, in main
    task.process_test(options.valPath)
  File "easyai/tools/feature_save/one_class_feature_save.py", line 28, in process_test
    self.test(epoch)
  File "easyai/tools/feature_save/one_class_feature_save.py", line 33, in test
    prediction, _ = self.inference.infer(batch_data)
  File "/home/wfw/workspace/Test/easy_ai/easyai/tasks/one_class/one_class.py", line 53, in infer
    model_output = self.model(image_data)
  File "/home/wfw/workspace/Test/TestENV/lib/python3.6/site-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/wfw/workspace/Test/easy_ai/easyai/model/cls/padim_net.py", line 67, in forward
    x = block(layer_outputs, base_outputs)
  File "/home/wfw/workspace/Test/TestENV/lib/python3.6/site-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/wfw/workspace/Test/easy_ai/easyai/model_block/head/cls/patch_head.py", line 42, in forward
    x = self.embedding_concat(x, feature)  # n, c, h, w
  File "/home/wfw/workspace/Test/easy_ai/easyai/model_block/head/cls/patch_head.py", line 27, in embedding_concat
    z[:, :, i, :, :] = torch.cat((x[:, :, i, :, :], y), 1)
RuntimeError: All input tensors must be on the same device. Received cpu and cuda:0
foww-0001 commented 3 years ago

one_class_save运行成功。