shaoshengsong / MobileNetV3-SSD

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

one question #2

Open zhaojc001 opened 5 years ago

zhaojc001 commented 5 years ago

when i use voc0712 training,it appears the following error,please help me: CUDA_VISIBLE_DEVICES=4 python2 train_ssd.py --dataset_type voc --datasets /usr/local/zjc/ActionRecog/VOCdevkit --net mb3-ssd-lite --scheduler cosine --lr 0.01 --t_max 100 --validation_epochs 5 --num_epochs 100 --base_net_lr 0.001 --batch_size 5 File "train_ssd.py", line 223 raise ValueError(f"Dataset tpye {args.dataset_type} is not supported.") ^ SyntaxError: invalid syntax

shaoshengsong commented 5 years ago
I tested it on python3,You can use the following command line.

` python train_ssd.py --datasets /media/santiago/dataset/VOC/VOC2012/ --validation_dataset /media/santiago/dataset/VOC/VOC2007/ --net "mb3-ssd-lite" --batch_size 2 --num_epochs 150 --scheduler cosine --lr 0.0012 --t_max 150 --validation_epochs 5

2019-08-11 13:50:01,426 - root - INFO - Namespace(balance_data=False, base_net=None, base_net_lr=None, batch_size=2, checkpoint_folder='models/', dataset_type='voc', datasets=['/media/santiago/dataset/VOC/VOC2012/'], debug_steps=100, extra_layers_lr=None, freeze_base_net=False, freeze_net=False, gamma=0.1, lr=0.0012, mb2_width_mult=1.0, milestones='80,100', momentum=0.9, net='mb3-ssd-lite', num_epochs=150, num_workers=4, pretrained_ssd=None, resume=None, scheduler='cosine', t_max=150.0, use_cuda=True, validation_dataset='/media/santiago/dataset/VOC/VOC2007/', validation_epochs=5, weight_decay=0.0005) 2019-08-11 13:50:01,437 - root - INFO - Prepare training datasets. 2019-08-11 13:50:01,453 - root - INFO - No labels file, using default VOC classes. 2019-08-11 13:50:01,453 - root - INFO - Stored labels into file models/voc-model-labels.txt. 2019-08-11 13:50:01,454 - root - INFO - Train dataset size: 11540 2019-08-11 13:50:01,454 - root - INFO - Prepare Validation datasets. 2019-08-11 13:50:01,462 - root - INFO - No labels file, using default VOC classes. 2019-08-11 13:50:01,462 - root - INFO - validation dataset size: 4952 2019-08-11 13:50:01,462 - root - INFO - Build network. 2019-08-11 13:50:01,557 - root - INFO - Took 0.00 seconds to load the model. 2019-08-11 13:50:01,560 - root - INFO - Learning rate: 0.0012, Base net learning rate: 0.0012, Extra Layers learning rate: 0.0012. 2019-08-11 13:50:01,560 - root - INFO - Uses CosineAnnealingLR scheduler. 2019-08-11 13:50:01,560 - root - INFO - Start training from epoch 0. /home/santiago/env/pytorch/lib/python3.6/site-packages/torch/nn/_reduction.py:46: UserWarning: size_average and reduce args will be deprecated, please use reduction='sum' instead. warnings.warn(warning.format(ret)) 2019-08-11 13:50:28,595 - root - INFO - Epoch: 0, Step: 100, Average Loss: 14.9440, Average Regression Loss 3.2744, Average Classification Loss: 11.6695 `

zhaojc001 commented 5 years ago

when I train, the command of train is following,but it appears the following error,please help me once: python train_ssd.py --datasets E:/ActionRecog/data/VOCdevkit/VOC2012/ --validation_dataset E:/ActionRecog/data/VOCdevkit/VOC2007/ --net "mb3-ssd-lite" --batch_size 2 --num_epochs 150 --scheduler cosine --lr 0.0012 --t_max 150 --validation_epochs 5 2019-08-19 09:13:16,220 - root - INFO - Use Cuda. 2019-08-19 09:13:16,220 - root - INFO - Namespace(balance_data=False, base_net=None, base_net_lr=None, batch_size=2, checkpoint_folder='models/', dataset_type='voc', datasets=['E:/ActionRecog/data/VOCdevkit/VOC2012/'], debug_steps=100, extra_layers_lr=None, freeze_base_net=False, freeze_net=False, gamma=0.1, lr=0.0012, mb2_width_mult=1.0, milestones='80,100', momentum=0.9, net='mb3-ssd-lite', num_epochs=150, num_workers=4, pretrained_ssd=None, resume=None, scheduler='cosine', t_max=150.0, use_cuda=True, validation_dataset='E:/ActionRecog/data/VOCdevkit/VOC2007/', validation_epochs=5, weight_decay=0.0005) 2019-08-19 09:13:16,250 - root - INFO - Prepare training datasets. 2019-08-19 09:13:16,296 - root - INFO - No labels file, using default VOC classes. 2019-08-19 09:13:16,301 - root - INFO - Stored labels into file models/voc-model-labels.txt. 2019-08-19 09:13:16,302 - root - INFO - Train dataset size: 34010 2019-08-19 09:13:16,312 - root - INFO - Prepare Validation datasets. 2019-08-19 09:13:16,323 - root - INFO - No labels file, using default VOC classes. 2019-08-19 09:13:16,324 - root - INFO - validation dataset size: 3527 2019-08-19 09:13:16,328 - root - INFO - Build network. 2019-08-19 09:13:16,483 - root - INFO - Took 0.00 seconds to load the model. 2019-08-19 09:13:24,645 - root - INFO - Learning rate: 0.0012, Base net learning rate: 0.0012, Extra Layers learning rate: 0.0012. 2019-08-19 09:13:24,648 - root - INFO - Uses CosineAnnealingLR scheduler. 2019-08-19 09:13:24,654 - root - INFO - Start training from epoch 0. Traceback (most recent call last): File "train_ssd.py", line 335, in device=DEVICE, debug_steps=args.debug_steps, epoch=epoch) File "train_ssd.py", line 117, in train for i, data in enumerate(loader): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\torch\utils\data\dataloader.py", line 819, in iter return _DataLoaderIter(self) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\torch\utils\data\dataloader.py", line 560, in init w.start() File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\multiprocessing\process.py", line 105, in start self._popen = self._Popen(self) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\multiprocessing\context.py", line 223, in _Popen return _default_context.get_context().Process._Popen(process_obj) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\multiprocessing\context.py", line 322, in _Popen return Popen(process_obj) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\multiprocessing\popen_spawn_win32.py", line 65, in init reduction.dump(process_obj, to_child) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\multiprocessing\reduction.py", line 60, in dump ForkingPickler(file, protocol).dump(obj) AttributeError: Can't pickle local object 'TrainAugmentation.init..'

E:\object_detection\MobileNetV3-SSD-master\MobileNetV3-SSD-master>2019-08-19 09:13:28,581 - root - INFO - Use Cuda. Traceback (most recent call last): File "", line 1, in File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\multiprocessing\spawn.py", line 105, in spawn_main exitcode = _main(fd) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\multiprocessing\spawn.py", line 115, in _main self = reduction.pickle.load(from_parent) EOFError: Ran out of input

xuming0629 commented 5 years ago

@zhaojc001 @shaoshengsong Have you resolved it, I have the same problem. python3 train_ssd.py --datasets /home/VOC2007/ --validation_dataset /home/VOC2007/ --net "mb3-ssd-lite" --batch_size 2 --num_epochs 150 --scheduler cosine --lr 0.0012 --t_max 150 --validation_epochs 5

This is my output:

2019-11-04 11:17:41,868 - root - INFO - Prepare training datasets.
2019-11-04 11:17:41,869 - root - INFO - No labels file, using default VOC classes.
2019-11-04 11:17:41,869 - root - INFO - Stored labels into file models/voc-model-labels.txt.
2019-11-04 11:17:41,869 - root - INFO - Train dataset size: 160
2019-11-04 11:17:41,869 - root - INFO - Prepare Validation datasets.
2019-11-04 11:17:41,869 - root - INFO - No labels file, using default VOC classes.
2019-11-04 11:17:41,869 - root - INFO - validation dataset size: 40
2019-11-04 11:17:41,869 - root - INFO - Build network.
2019-11-04 11:17:41,947 - root - INFO - Took 0.00 seconds to load the model.
2019-11-04 11:17:45,129 - root - INFO - Learning rate: 0.0012, Base net learning rate: 0.0012, Extra Layers learning rate: 0.0012.
2019-11-04 11:17:45,129 - root - INFO - Uses CosineAnnealingLR scheduler.
2019-11-04 11:17:45,129 - root - INFO - Start training from epoch 0.
/home/tsd/.local/lib/python3.6/site-packages/torch/optim/lr_scheduler.py:82: UserWarning: Detected call of `lr_scheduler.step()` before `optimizer.step()`. In PyTorch 1.1.0 and later, you should call them in the opposite order: `optimizer.step()` before `lr_scheduler.step()`.  Failure to do this will result in PyTorch skipping the first value of the learning rate schedule.See more details at https://pytorch.org/docs/stable/optim.html#how-to-adjust-learning-rate
  "https://pytorch.org/docs/stable/optim.html#how-to-adjust-learning-rate", UserWarning)
********************
Traceback (most recent call last):
  File "train_ssd.py", line 337, in <module>
    train(train_loader, net, criterion, optimizer, device=DEVICE, debug_steps=args.debug_steps, epoch=epoch)
  File "train_ssd.py", line 119, in train
    for i, data in enumerate(loader):
  File "/home/tsd/.local/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 819, in __next__
    return self._process_data(data)
  File "/home/tsd/.local/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 846, in _process_data
    data.reraise()
  File "/home/tsd/.local/lib/python3.6/site-packages/torch/_utils.py", line 369, in reraise
    raise self.exc_type(msg)
IndexError: Caught IndexError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/home/tsd/.local/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop
    data = fetcher.fetch(index)
  File "/home/tsd/.local/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/tsd/.local/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/tsd/.local/lib/python3.6/site-packages/torch/utils/data/dataset.py", line 206, in __getitem__
    return self.datasets[dataset_idx][sample_idx]
  File "/home/1/MobileNetV3-SSD/vision/datasets/voc_dataset.py", line 65, in __getitem__
    image, boxes, labels = self.transform(image, boxes, labels)
  File "/home/1/MobileNetV3-SSD/vision/ssd/data_preprocessing.py", line 34, in __call__
    return self.augment(img, boxes, labels)
  File "/home/1/MobileNetV3-SSD/vision/transforms/transforms.py", line 55, in __call__
    img, boxes, labels = t(img, boxes, labels)
  File "/home/1/MobileNetV3-SSD/vision/transforms/transforms.py", line 275, in __call__
    overlap = jaccard_numpy(boxes, rect)
  File "/home/1/MobileNetV3-SSD/vision/transforms/transforms.py", line 30, in jaccard_numpy
    inter = intersect(box_a, box_b)
  File "/home/1/MobileNetV3-SSD/vision/transforms/transforms.py", line 13, in intersect
    max_xy = np.minimum(box_a[:, 2:], box_b[2:])
IndexError: too many indices for array
weidongmei123 commented 4 years ago

me too.crying!

tianyuluan commented 4 years ago

@zhaojc001 @shaoshengsong

Have you resolved it, I have the same problem.

python3 train_ssd.py --datasets /home/VOC2007/ --validation_dataset /home/VOC2007/ --net "mb3-ssd-lite" --batch_size 2 --num_epochs 150 --scheduler cosine --lr 0.0012 --t_max 150 --validation_epochs 5

This is my output:


2019-11-04 11:17:41,868 - root - INFO - Prepare training datasets.

2019-11-04 11:17:41,869 - root - INFO - No labels file, using default VOC classes.

2019-11-04 11:17:41,869 - root - INFO - Stored labels into file models/voc-model-labels.txt.

2019-11-04 11:17:41,869 - root - INFO - Train dataset size: 160

2019-11-04 11:17:41,869 - root - INFO - Prepare Validation datasets.

2019-11-04 11:17:41,869 - root - INFO - No labels file, using default VOC classes.

2019-11-04 11:17:41,869 - root - INFO - validation dataset size: 40

2019-11-04 11:17:41,869 - root - INFO - Build network.

2019-11-04 11:17:41,947 - root - INFO - Took 0.00 seconds to load the model.

2019-11-04 11:17:45,129 - root - INFO - Learning rate: 0.0012, Base net learning rate: 0.0012, Extra Layers learning rate: 0.0012.

2019-11-04 11:17:45,129 - root - INFO - Uses CosineAnnealingLR scheduler.

2019-11-04 11:17:45,129 - root - INFO - Start training from epoch 0.

/home/tsd/.local/lib/python3.6/site-packages/torch/optim/lr_scheduler.py:82: UserWarning: Detected call of `lr_scheduler.step()` before `optimizer.step()`. In PyTorch 1.1.0 and later, you should call them in the opposite order: `optimizer.step()` before `lr_scheduler.step()`.  Failure to do this will result in PyTorch skipping the first value of the learning rate schedule.See more details at https://pytorch.org/docs/stable/optim.html#how-to-adjust-learning-rate

  "https://pytorch.org/docs/stable/optim.html#how-to-adjust-learning-rate", UserWarning)

********************

Traceback (most recent call last):

  File "train_ssd.py", line 337, in <module>

    train(train_loader, net, criterion, optimizer, device=DEVICE, debug_steps=args.debug_steps, epoch=epoch)

  File "train_ssd.py", line 119, in train

    for i, data in enumerate(loader):

  File "/home/tsd/.local/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 819, in __next__

    return self._process_data(data)

  File "/home/tsd/.local/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 846, in _process_data

    data.reraise()

  File "/home/tsd/.local/lib/python3.6/site-packages/torch/_utils.py", line 369, in reraise

    raise self.exc_type(msg)

IndexError: Caught IndexError in DataLoader worker process 0.

Original Traceback (most recent call last):

  File "/home/tsd/.local/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop

    data = fetcher.fetch(index)

  File "/home/tsd/.local/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch

    data = [self.dataset[idx] for idx in possibly_batched_index]

  File "/home/tsd/.local/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>

    data = [self.dataset[idx] for idx in possibly_batched_index]

  File "/home/tsd/.local/lib/python3.6/site-packages/torch/utils/data/dataset.py", line 206, in __getitem__

    return self.datasets[dataset_idx][sample_idx]

  File "/home/1/MobileNetV3-SSD/vision/datasets/voc_dataset.py", line 65, in __getitem__

    image, boxes, labels = self.transform(image, boxes, labels)

  File "/home/1/MobileNetV3-SSD/vision/ssd/data_preprocessing.py", line 34, in __call__

    return self.augment(img, boxes, labels)

  File "/home/1/MobileNetV3-SSD/vision/transforms/transforms.py", line 55, in __call__

    img, boxes, labels = t(img, boxes, labels)

  File "/home/1/MobileNetV3-SSD/vision/transforms/transforms.py", line 275, in __call__

    overlap = jaccard_numpy(boxes, rect)

  File "/home/1/MobileNetV3-SSD/vision/transforms/transforms.py", line 30, in jaccard_numpy

    inter = intersect(box_a, box_b)

  File "/home/1/MobileNetV3-SSD/vision/transforms/transforms.py", line 13, in intersect

    max_xy = np.minimum(box_a[:, 2:], box_b[2:])

IndexError: too many indices for array

have you soved that?please tell me if you have,thanks!