Я тренируюсь на пользовательских объектах для обнаружения объектов с использованием yolo-v3 и PyTorch. маркировка и все остальные задачи выполнены. при запуске команды train я получаю следующую ошибку
(base) C:\Users\murali\Desktop\yolov3>python train.py --data coco.data --cfg cfg/yolov3.cfg
Namespace(accumulate=2, adam=False, arc='defaultpw', batch_size=32, bucket='', cache_images=False, cfg='cfg/yolov3.cfg', data='coco.data', device='', epochs=273, evolve=False, img_size=416, img_weights=False, multi_scale=False, name='', nosave=False, notest=False, prebias=False, rect=False, resume=False, transfer=False, var=None, weights='')
Using CPU
WARNING:root:This caffe2 python run does not have GPU support. Will run in CPU only mode.
Reading labels (357 found, 0 missing, 4 empty for 361 images): 100%|███████████████| 361/361 [00:00<00:00, 6489.34it/s]
Model Summary: 222 layers, 6.19491e+07 parameters, 6.19491e+07 gradients
Starting training for 273 epochs...
Epoch gpu_mem GIoU obj cls total targets img_size
Corrupt JPEG data: 2 extraneous bytes before marker 0xd9
0%| | 0/12 [00:00<?, ?it/s]Corrupt JPEG data: 2 extraneous bytes before marker 0xd9
Corrupt JPEG data: 1 extraneous bytes before marker 0xd9
Corrupt JPEG data: 1 extraneous bytes before marker 0xd9
Corrupt JPEG data: 2 extraneous bytes before marker 0xd9
Corrupt JPEG data: 1 extraneous bytes before marker 0xd9
Corrupt JPEG data: 2 extraneous bytes before marker 0xd9
Corrupt JPEG data: 1 extraneous bytes before marker 0xd9
Corrupt JPEG data: 1 extraneous bytes before marker 0xd9
Corrupt JPEG data: 1 extraneous bytes before marker 0xd9
Corrupt JPEG data: 2 extraneous bytes before marker 0xd9
Corrupt JPEG data: 2 extraneous bytes before marker 0xd9
Corrupt JPEG data: 1 extraneous bytes before marker 0xd9
Corrupt JPEG data: 1 extraneous bytes before marker 0xd9
Corrupt JPEG data: 2 extraneous bytes before marker 0xd9
Traceback (most recent call last):
File "train.py", line 426, in
train() # train normally
File "train.py", line 235, in train
for i, (imgs, targets, paths, _) in pbar: # batch -------------------------------------------------------------
File "C:\Users\murali\AppData\Local\Continuum\anaconda3\lib\site-packages\tqdm_tqdm.py", line 1005, in iter
for obj in iterable:
File "C:\Users\murali\AppData\Local\Continuum\anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 819, in next
return self._process_data(data)
File "C:\Users\murali\AppData\Local\Continuum\anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 846, in _process_data
data.reraise()
File "C:\Users\murali\AppData\Local\Continuum\anaconda3\lib\site-packages\torch_utils.py", line 369, in reraise
raise self.exc_type(msg)
UnboundLocalError: Caught UnboundLocalError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "C:\Users\murali\AppData\Local\Continuum\anaconda3\lib\site-packages\torch\utils\data_utils\worker.py", line 178, in _worker_loop
data = fetcher.fetch(index)
File "C:\Users\murali\AppData\Local\Continuum\anaconda3\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "C:\Users\murali\AppData\Local\Continuum\anaconda3\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "C:\Users\murali\Desktop\yolov3\utils\datasets.py", line 416, in getitem
img, labels = load_mosaic(self, index)
File "C:\Users\murali\Desktop\yolov3\utils\datasets.py", line 590, in load_mosaic
labels4.append(labels)
UnboundLocalError: local variable 'labels' referenced before assignment
В упомянутых строках указана ошибка, следующая за двумя частями кода в строке dataset.py
416находится в следующем коде
if mosaic:
# Load mosaic
img, labels = load_mosaic(self, index)
h, w, _ = img.shape
590 в следующем коде (label4.append (этикетки))
# Load labels
label_path = self.label_files[index]
if os.path.isfile(label_path):
x = self.labels[index]
if x is None: # labels not preloaded
with open(label_path, 'r') as f:
x = np.array([x.split() for x in f.read().splitlines()], dtype=np.float32)
if x.size > 0:
# Normalized xywh to pixel xyxy format
labels = x.copy()
labels[:, 1] = w * (x[:, 1] - x[:, 3] / 2) + padw
labels[:, 2] = h * (x[:, 2] - x[:, 4] / 2) + padh
labels[:, 3] = w * (x[:, 1] + x[:, 3] / 2) + padw
labels[:, 4] = h * (x[:, 2] + x[:, 4] / 2) + padh
labels4.append(labels)
labels4 = np.concatenate(labels4, 0)
Какрешить это?
Полный код здесь
`