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: indices should be either on cpu or on the same device as the indexed tensor (cpu) when run demo.py in colab #613

Open
Pathomphop opened this issue May 17, 2023 · 2 comments

Comments

@Pathomphop
Copy link

/usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py:125: UserWarning: Decorating classes is deprecated and will be disabled in future versions. You should only decorate functions or methods. To preserve the current behavior of class decoration, you can directly decorate the __init__ method and nothing else.
warnings.warn("Decorating classes is deprecated and will be disabled in "
[05/17 07:22:07 detectron2]: Arguments: Namespace(config_file='configs/BAText/ICDAR2015/v1_attn_R_50.yaml', webcam=False, video_input=None, input=['/content/images/'], output='output', confidence_threshold=0.3, opts=['MODEL.WEIGHTS', 'v1_ic15_finetuned.pth'])
WARNING [05/17 07:22:07 d2.config.compat]: Config 'configs/BAText/ICDAR2015/v1_attn_R_50.yaml' has no VERSION. Assuming it to be compatible with latest v2.
[05/17 07:22:08 d2.checkpoint.detection_checkpoint]: [DetectionCheckpointer] Loading from v1_ic15_finetuned.pth ...
The checkpoint state_dict contains keys that are not used by the model:
pixel_mean
pixel_std
0% 0/10 [00:00<?, ?it/s]/usr/local/lib/python3.10/dist-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3483.)
return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]
0% 0/10 [00:01<?, ?it/s]
Traceback (most recent call last):
File "/content/AdelaiDet/demo/demo.py", line 87, in
predictions, visualized_output = demo.run_on_image(img)
File "/content/AdelaiDet/demo/predictor.py", line 54, in run_on_image
predictions = self.predictor(image)
File "/content/detectron2/detectron2/engine/defaults.py", line 317, in call
predictions = self.model([inputs])[0]
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/content/AdelaiDet/adet/modeling/one_stage_detector.py", line 99, in forward
return self.inference(batched_inputs)
File "/content/AdelaiDet/adet/modeling/one_stage_detector.py", line 169, in inference
return OneStageRCNN._postprocess(results, batched_inputs, images.image_sizes)
File "/content/AdelaiDet/adet/modeling/one_stage_detector.py", line 185, in _postprocess
r = detector_postprocess(results_per_image, height, width)
File "/content/AdelaiDet/adet/modeling/one_stage_detector.py", line 16, in detector_postprocess
results = d2_postprocesss(results, output_height, output_width, mask_threshold)
File "/content/detectron2/detectron2/modeling/postprocessing.py", line 58, in detector_postprocess
results = results[output_boxes.nonempty()]
File "/content/detectron2/detectron2/structures/instances.py", line 142, in getitem
ret.set(k, v[item])
RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)

@Gorgerbin
Copy link

I got the same problem. Do you have solutions?

@Pathomphop
Copy link
Author

if you run in colab chnage the version of condacolab

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

2 participants