Bug in pytorch with yolact

Hello !

I have this bug :

runfile('C:/Users/Sylvain ARD/Dropbox/Documents Sylvain/travail avec Boubacar/yolact/yolact-master/yolact-master/train.py', wdir='C:/Users/Sylvain ARD/Dropbox/Documents Sylvain/travail avec Boubacar/yolact/yolact-master/yolact-master')
loading annotations into memory...
Done (t=0.05s)
creating index...
index created!
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
Initializing weights...
Begin training!

epoch :  0
Traceback (most recent call last):

  File "C:\Users\Sylvain ARD\Dropbox\Documents Sylvain\travail avec Boubacar\yolact\yolact-master\yolact-master\train.py", line 505, in <module>
    train()

  File "C:\Users\Sylvain ARD\Dropbox\Documents Sylvain\travail avec Boubacar\yolact\yolact-master\yolact-master\train.py", line 271, in train
    for datum in data_loader:

  File "C:\Users\Sylvain ARD\.conda\envs\yolact\lib\site-packages\torch\utils\data\dataloader.py", line 819, in __next__
    return self._process_data(data)

  File "C:\Users\Sylvain ARD\.conda\envs\yolact\lib\site-packages\torch\utils\data\dataloader.py", line 846, in _process_data
    data.reraise()

  File "C:\Users\Sylvain ARD\.conda\envs\yolact\lib\site-packages\torch\_utils.py", line 369, in reraise
    raise self.exc_type(msg)

TypeError: __init__() missing 4 required positional arguments: 'casting', 'from_', 'to', and 'i'

please help me !
Best regards

Hi,

It would be very helpful if you shared some information about what you’re doing when this happened?
When debugging issues happening in the dataloading, I would recommend setting the number of workers to 0 as well to get more helpful stack traces.

It happened when I run train.py
what do you call workers ?

I don’t think we have any file called train.py in pytorch?

what do you call workers ?

The error comes from the dataloader workers.

Hi !
I use the yolact code :

how to use 0 workers please ?
Thank you

when I do 0 worker I get :

runfile('C:/Users/Sylvain ARD/Dropbox/Documents Sylvain/travail avec Boubacar/yolact/yolact-master/yolact-master/train.py', wdir='C:/Users/Sylvain ARD/Dropbox/Documents Sylvain/travail avec Boubacar/yolact/yolact-master/yolact-master')
Reloaded modules: data, data.config, backbone, data.coco, utils, utils.augmentations, utils.functions, layers, layers.functions, layers.functions.detection, layers.box_utils, utils.timer, layers.modules, layers.modules.multibox_loss, layers.interpolate, utils.logger, utils.nvinfo, yolact, eval, layers.output_utils
Scaling parameters by 0.12 to account for a batch size of 1.
Per-GPU batch size is less than the recommended limit for batch norm. Disabling batch norm.
loading annotations into memory...
Done (t=0.03s)
creating index...
index created!
loading annotations into memory...
Done (t=0.00s)
creating index...
index created!
Initializing weights...
Begin training!

epoch :  0
C:\Users\Sylvain ARD\Dropbox\Documents Sylvain\travail avec Boubacar\yolact\yolact-master\yolact-master\utils\augmentations.py:309: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
  mode = random.choice(self.sample_options)
Traceback (most recent call last):

  File "C:\Users\Sylvain ARD\Dropbox\Documents Sylvain\travail avec Boubacar\yolact\yolact-master\yolact-master\train.py", line 505, in <module>
    train()

  File "C:\Users\Sylvain ARD\Dropbox\Documents Sylvain\travail avec Boubacar\yolact\yolact-master\yolact-master\train.py", line 271, in train
    for datum in data_loader:

  File "C:\Users\Sylvain ARD\.conda\envs\yolact\lib\site-packages\torch\utils\data\dataloader.py", line 346, in __next__
    data = self.dataset_fetcher.fetch(index)  # may raise StopIteration

  File "C:\Users\Sylvain ARD\.conda\envs\yolact\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\Sylvain ARD\.conda\envs\yolact\lib\site-packages\torch\utils\data\_utils\fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]

  File "C:\Users\Sylvain ARD\Dropbox\Documents Sylvain\travail avec Boubacar\yolact\yolact-master\yolact-master\data\coco.py", line 94, in __getitem__
    im, gt, masks, h, w, num_crowds = self.pull_item(index)

  File "C:\Users\Sylvain ARD\Dropbox\Documents Sylvain\travail avec Boubacar\yolact\yolact-master\yolact-master\data\coco.py", line 168, in pull_item
    {'num_crowds': 0, 'labels': np.array([0])})

  File "C:\Users\Sylvain ARD\Dropbox\Documents Sylvain\travail avec Boubacar\yolact\yolact-master\yolact-master\utils\augmentations.py", line 688, in __call__
    return self.augment(img, masks, boxes, labels)

  File "C:\Users\Sylvain ARD\Dropbox\Documents Sylvain\travail avec Boubacar\yolact\yolact-master\yolact-master\utils\augmentations.py", line 55, in __call__
    img, masks, boxes, labels = t(img, masks, boxes, labels)

  File "C:\Users\Sylvain ARD\Dropbox\Documents Sylvain\travail avec Boubacar\yolact\yolact-master\yolact-master\utils\augmentations.py", line 167, in __call__
    boxes[:, [0, 2]] *= (width  / img_w)

UFuncTypeError: Cannot cast ufunc 'multiply' output from dtype('float64') to dtype('int32') with casting rule 'same_kind'


C:\Users\Sylvain ARD\Dropbox\Documents Sylvain\travail avec Boubacar\yolact\yolact-master\yolact-master\utils\augmentations.py:309: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
  mode = random.choice(self.sample_options)
C:\Users\Sylvain ARD\Dropbox\Documents Sylvain\travail avec Boubacar\yolact\yolact-master\yolact-master\utils\augmentations.py:309: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
  mode = random.choice(self.sample_options)
C:\Users\Sylvain ARD\Dropbox\Documents Sylvain\travail avec Boubacar\yolact\yolact-master\yolact-master\utils\augmentations.py:309: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
  mode = random.choice(self.sample_options)
C:\Users\Sylvain ARD\Dropbox\Documents Sylvain\travail avec Boubacar\yolact\yolact-master\yolact-master\utils\augmentations.py:309: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
  mode = random.choice(self.sample_options)

I corrected the bug it was a bug in my annotation json

Congrats on finding it!

I have a similar issue. Can you tell me what the bug was in your json annotation?

here are my annotations files :

so you can compare with yours

I remember only two errors : the polygons must be an array of polygons and not a simple polygon and there was instances IDs duplicated

is that has helped you ?

in addition I added :

boxes=boxes.astype("float64")####Ajouté par Sylvain Ard

at line 168 of augmentations.py