質問編集履歴

1

エラー文の修正

2022/09/07 04:43

投稿

Tyutohannpa_
Tyutohannpa_

スコア24

test CHANGED
File without changes
test CHANGED
@@ -9,20 +9,60 @@
9
9
 
10
10
  ```
11
11
  エラーメッセージ
12
+ ---------------------------------------------------------------------------
12
13
  AttributeError Traceback (most recent call last)
13
14
  <timed exec> in <module>
14
15
 
15
- <ipython-input-33-dd6592475800> in train(net, dataloaders_dict, criterion, optimizer, num_epochs)
16
+ <ipython-input-11-f5fd48daba1c> in train(net, dataloaders_dict, criterion, optimizer, num_epochs)
17
+ 62
16
- 53 # 1ステップにおけるミニバッチを使用した学習または検証
18
+ 63
17
- 54 # データローダーをイテレートしてミニバッチを抽出
18
- ---> 55 for images, targets in dataloaders_dict[phase]:
19
+ ---> 64 for images, targets in dataloaders_dict[phase]:
19
- 56 # 画像データにデバイスを割り当てる
20
+ 65 # 画像データにデバイスを割り当てる
20
- 57 images = images.to(device)
21
+ 66 images = images.to(device)
22
+
21
-
23
+ /usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py in __next__(self)
24
+ 679 # TODO(https://github.com/pytorch/pytorch/issues/76750)
25
+ 680 self._reset() # type: ignore[call-arg]
26
+ --> 681 data = self._next_data()
27
+ 682 self._num_yielded += 1
28
+ 683 if self._dataset_kind == _DatasetKind.Iterable and \
29
+
30
+ /usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py in _next_data(self)
31
+ 719 def _next_data(self):
32
+ 720 index = self._next_index() # may raise StopIteration
33
+ --> 721 data = self._dataset_fetcher.fetch(index) # may raise StopIteration
34
+ 722 if self._pin_memory:
35
+ 723 data = _utils.pin_memory.pin_memory(data, self._pin_memory_device)
36
+
37
+ /usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py in fetch(self, possibly_batched_index)
38
+ 47 def fetch(self, possibly_batched_index):
39
+ 48 if self.auto_collation:
40
+ ---> 49 data = [self.dataset[idx] for idx in possibly_batched_index]
41
+ 50 else:
42
+ 51 data = self.dataset[possibly_batched_index]
43
+
44
+ /usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py in <listcomp>(.0)
45
+ 47 def fetch(self, possibly_batched_index):
46
+ 48 if self.auto_collation:
47
+ ---> 49 data = [self.dataset[idx] for idx in possibly_batched_index]
48
+ 50 else:
49
+ 51 data = self.dataset[possibly_batched_index]
50
+
51
+ /content/drive/My Drive/Colab Notebooks/ObjectDetection/voc.py in __getitem__(self, index)
52
+ 256 # pull_item()にイメージのインデックスを渡して前処理
53
+ 257 # 処理後のイメージデータとBBoxとラベルの2次元配列を返す
54
+ --> 258 im, bl, _, _ = self.pull_item(index)
55
+ 259 return im, bl
56
+ 260
57
+
22
- /content/drive/My Drive/ObjectDetection/voc.py in pull_item(self, index)
58
+ /content/drive/My Drive/Colab Notebooks/ObjectDetection/voc.py in pull_item(self, index)
59
+ 275 img_path = self.img_list[index] # インデックスを指定してイメージのパスを取得
60
+ 276 img = cv2.imread(img_path) # OpenCV2でイメージの[高さ,幅,[B,G,R]]を取得
61
+ --> 277 height, width, _ = img.shape # 配列要素数を数えて高さ,幅のみを取得
62
+ 278
63
+ 279 # アノテーションデータのリストを取得
23
64
 
24
65
  AttributeError: 'NoneType' object has no attribute 'shape'
25
-
26
66
  ```
27
67
 
28
68
  ### 該当のソースコード