aim-uofa / AdelaiDet

AdelaiDet is an open source toolbox for multiple instance-level detection and recognition tasks.
https://git.io/AdelaiDet
Other
3.34k stars 644 forks source link

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 1 year ago

Pathomphop commented 1 year ago

/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 commented 1 year ago

I got the same problem. Do you have solutions?

Pathomphop commented 1 year ago

if you run in colab chnage the version of condacolab