demo.py程式問題
2020/01/28 09:19 下午
電腦視覺深度學習討論版
馮品儒
觀看數:7
回答數:3
收藏數:0
cvdl-1-d29
1.demo.py 問題
請問我在執行Real Time的時候遇到了如下的問題:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
in
3 while True:
4 _, frame = video_capture.read()
----> 5 canvas = detect(frame, net, transform)
6 cv2.imshow('Video', canvas)
7 if cv2.waitKey(1) & 0xFF == ord('q'):
in detect(frame, net, transform)
8 x = torch.from_numpy(frame_t).permute(2, 0, 1)
9 x = Variable(x.unsqueeze(0))
---> 10 y = net(x)
11 detections = y.data
12 scale = torch.Tensor([width, height, width, height])
D:\program\anaconda\envs\tf_gpu_1.13\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
545 result = self._slow_forward(*input, **kwargs)
546 else:
--> 547 result = self.forward(*input, **kwargs)
548 for hook in self._forward_hooks.values():
549 hook_result = hook(self, input, result)
D:\program\anaconda\envs\tf_gpu_1.13\lib\site-packages\ssd.py in forward(self, x)
73 # apply vgg up to conv4_3 relu
74 for k in range(23):
---> 75 x = self.vgg[k](x)
76
77 s = self.L2Norm(x)
D:\program\anaconda\envs\tf_gpu_1.13\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
545 result = self._slow_forward(*input, **kwargs)
546 else:
--> 547 result = self.forward(*input, **kwargs)
548 for hook in self._forward_hooks.values():
549 hook_result = hook(self, input, result)
D:\program\anaconda\envs\tf_gpu_1.13\lib\site-packages\torch\nn\modules\conv.py in forward(self, input)
341
342 def forward(self, input):
--> 343 return self.conv2d_forward(input, self.weight)
344
345 class Conv3d(_ConvNd):
D:\program\anaconda\envs\tf_gpu_1.13\lib\site-packages\torch\nn\modules\conv.py in conv2d_forward(self, input, weight)
338 _pair(0), self.dilation, self.groups)
339 return F.conv2d(input, weight, self.bias, self.stride,
--> 340 self.padding, self.dilation, self.groups)
341
342 def forward(self, input):
RuntimeError: Expected object of backend CPU but got backend CUDA for argument #2 'weight'
2.輸入資料型態.ipynb 問題
我在loading 完圖片後執行images, targets = next(batch_iterator) 遇到問題如下:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in
----> 1 images, targets = next(batch_iterator)
D:\program\anaconda\envs\tf_gpu_1.13\lib\site-packages\torch\utils\data\dataloader.py in __next__(self)
344 def __next__(self):
345 index = self._next_index() # may raise StopIteration
--> 346 data = self.dataset_fetcher.fetch(index) # may raise StopIteration
347 if self.pin_memory:
348 data = _utils.pin_memory.pin_memory(data)
D:\program\anaconda\envs\tf_gpu_1.13\lib\site-packages\torch\utils\data\_utils\fetch.py in fetch(self, possibly_batched_index)
42 def fetch(self, possibly_batched_index):
43 if self.auto_collation:
---> 44 data = [self.dataset[idx] for idx in possibly_batched_index]
45 else:
46 data = self.dataset[possibly_batched_index]
D:\program\anaconda\envs\tf_gpu_1.13\lib\site-packages\torch\utils\data\_utils\fetch.py in (.0)
42 def fetch(self, possibly_batched_index):
43 if self.auto_collation:
---> 44 data = [self.dataset[idx] for idx in possibly_batched_index]
45 else:
46 data = self.dataset[possibly_batched_index]
d:\freshman\python\Object Detection 程式導讀\data\coco.py in __getitem__(self, index)
108 target is the object returned by ``coco.loadAnns``.
109 """
--> 110 im, gt, h, w = self.pull_item(index)
111 return im, gt
112
d:\freshman\python\Object Detection 程式導讀\data\coco.py in pull_item(self, index)
130 assert osp.exists(path), 'Image path does not exist: {}'.format(path)
131 img = cv2.imread(osp.join(self.root, path))
--> 132 height, width, _ = img.shape
133 if self.target_transform is not None:
134 target = self.target_transform(target, width, height)
AttributeError: 'NoneType' object has no attribute 'shape'
3.Build RetinaNet.ipynb、Build SSD_VGG.ipynb 問題
在執行 基本設定 時,遇到了:
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
in
4 '''tensor type會依照cpu或gpu有所不同'''
5 if torch.cuda.is_available():
----> 6 if args.cuda:
7 torch.set_default_tensor_type('torch.cuda.FloatTensor')
8 if not args.cuda:
NameError: name 'args' is not defined
請問該如何解決?
4.檔案中出現很多 _DS_Store 的檔案,請問那是甚麼檔案?