shaoshengsong / MobileNetV3-SSD

MobileNetV3-SSD for object detection and implementation in PyTorch
269 stars 88 forks source link

RuntimeError: expected backend CPU and dtype Float but got backend CUDA and dtype Float #5

Open WestbrookZero opened 5 years ago

WestbrookZero commented 5 years ago

请问一下,执行run_ssd_example.py脚本报这个错该如何解决? Traceback (most recent call last): File "run_ssd_example.py", line 57, in boxes, labels, probs = predictor.predict(image, 10, 0.4) File "D:\Projects\DeepLearning\MobileNetV3-SSD-master\vision\ssd\predictor.py", line 37, in predict scores, boxes = self.net.forward(images) File "D:\Projects\DeepLearning\MobileNetV3-SSD-master\vision\ssd\ssd.py", line 100, in forward locations, self.priors, self.config.center_variance, self.config.size_variance File "D:\Projects\DeepLearning\MobileNetV3-SSD-master\vision\utils\box_utils.py", line 104, in convert_locations_to_boxes locations[..., :2] center_variance priors[..., 2:] + priors[..., :2], RuntimeError: expected backend CPU and dtype Float but got backend CUDA and dtype Float

lingyi-learning commented 5 years ago

Do you solve this problem?

xiezhiepng commented 5 years ago

我也是同样的问题?

duhaijun commented 5 years ago

请问一下,执行run_ssd_example.py脚本报这个错该如何解决? Traceback (most recent call last): File "run_ssd_example.py", line 57, in boxes, labels, probs = predictor.predict(image, 10, 0.4) File "D:\Projects\DeepLearning\MobileNetV3-SSD-master\vision\ssd\predictor.py", line 37, in predict scores, boxes = self.net.forward(images) File "D:\Projects\DeepLearning\MobileNetV3-SSD-master\vision\ssd\ssd.py", line 100, in forward locations, self.priors, self.config.center_variance, self.config.size_variance File "D:\Projects\DeepLearning\MobileNetV3-SSD-master\vision\utils\box_utils.py", line 104, in convert_locations_to_boxes locations[..., :2] center_variance priors[..., 2:] + priors[..., :2], RuntimeError: expected backend CPU and dtype Float but got backend CUDA and dtype Float

模型加载到cuda就行了

siemonchan commented 5 years ago

If you are trying to use GPU, change device in create_mobilenetv3_ssd_lite_predictor to torch.device('cuda:0'), it works for me.

azhuantou commented 4 years ago

@siemonchan thanks

YONGHUICAI commented 4 years ago

请问一下,执行run_ssd_example.py脚本报这个错该如何解决? Traceback (most recent call last): File "run_ssd_example.py", line 57, in boxes, labels, probs = predictor.predict(image, 10, 0.4) File "D:\Projects\DeepLearning\MobileNetV3-SSD-master\vision\ssd\predictor.py", line 37, in predict scores, boxes = self.net.forward(images) File "D:\Projects\DeepLearning\MobileNetV3-SSD-master\vision\ssd\ssd.py", line 100, in forward locations, self.priors, self.config.center_variance, self.config.size_variance File "D:\Projects\DeepLearning\MobileNetV3-SSD-master\vision\utils\box_utils.py", line 104, in convert_locations_to_boxes locations[..., :2] center_variance priors[..., 2:] + priors[..., :2], RuntimeError: expected backend CPU and dtype Float but got backend CUDA and dtype Float

模型加载到cuda就行了

修改vision/ssd/mobilenet_v3_ssd_lite.py文件第90行成def create_mobilenetv3_ssd_lite_predictor(net, candidate_size=200, nms_method=None, sigma=0.5, device=torch.device('cuda:0'))就可以了。

shaoshengsong commented 4 years ago

It is recommended that git clone this version https://github.com/shaoshengsong/MobileNetV3-SSD-Compact-Version