MrDemeanor / MaskRCNNJupyterSuite

Suite of jupyter notebooks designed to accelerate productivity when creating, running, and evaluating MaskRCNN models
5 stars 5 forks source link

TypeError: argument must be sequence #1

Open backgomc opened 5 years ago

backgomc commented 5 years ago

I'm trying to run this lines. but there is error code. please help me how can i run it.

start_train = time.time()
model.train(dataset_train, dataset_val, learning_rate = TrainConfig().LEARNING_RATE, epochs = NUM_EPOCHS, layers = 'all', augmentation=None, custom_callbacks=None, no_augmentation_sources=None)
end_train = time.time()
minutes = round((end_train - start_train) / 60, 2)
print(f'Training took {minutes} minutes')

E0903 04:51:14.370807 140589790996224 model.py:1810] Error processing image {'id': 3, 'source': 'coco_like', 'path': '/home/MaskRCNNTutorial/MaskRCNNJupyterSuite/datasets/Downtown_Sliced/train/images/24.jpg', 'width': 353, 'height': 353, 'annotations': [{'id': 4, 'image_id': 3, 'category_id': 1, 'segmentation': [196, 87, 181, 95, 171, 91, 180, 80, 192, 83], 'area': 375, 'bbox': [171, 80, 25, 15], 'iscrowd': 0}]}
Traceback (most recent call last):
  File "/home/venv/src/mask-rcnn/mrcnn/model.py", line 1709, in data_generator
    use_mini_mask=config.USE_MINI_MASK)
  File "/home/venv/src/mask-rcnn/mrcnn/model.py", line 1212, in load_image_gt
    mask, class_ids = dataset.load_mask(image_id)
  File "<ipython-input-41-562fec61f152>", line 85, in load_mask
    mask_draw.polygon(segmentation, fill=1)
  File "/home/venv/lib/python3.6/site-packages/PIL/ImageDraw.py", line 240, in polygon
    self.draw.draw_polygon(xy, fill, 1)
TypeError: argument must be sequence
Epoch 1/80
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-49-f616f0b4b179> in <module>
      1 start_train = time.time()
----> 2 model.train(dataset_train, dataset_val, learning_rate = TrainConfig().LEARNING_RATE, epochs = NUM_EPOCHS, layers = 'all', augmentation=None, custom_callbacks=None, no_augmentation_sources=None)
      3 end_train = time.time()
      4 minutes = round((end_train - start_train) / 60, 2)
      5 print(f'Training took {minutes} minutes')

/home/venv/src/mask-rcnn/mrcnn/model.py in train(self, train_dataset, val_dataset, learning_rate, epochs, layers, augmentation, custom_callbacks, no_augmentation_sources)
   2372             max_queue_size=100,
   2373             workers=workers,
-> 2374             use_multiprocessing=True,
   2375         )
   2376         self.epoch = max(self.epoch, epochs)

/home/venv/lib/python3.6/site-packages/keras/legacy/interfaces.py in wrapper(*args, **kwargs)
     89                 warnings.warn('Update your `' + object_name +
     90                               '` call to the Keras 2 API: ' + signature, stacklevel=2)
---> 91             return func(*args, **kwargs)
     92         wrapper._original_function = func
     93         return wrapper

/home/venv/lib/python3.6/site-packages/keras/engine/training.py in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch)
   2192                 batch_index = 0
   2193                 while steps_done < steps_per_epoch:
-> 2194                     generator_output = next(output_generator)
   2195 
   2196                     if not hasattr(generator_output, '__len__'):

/home/venv/lib/python3.6/site-packages/keras/utils/data_utils.py in get(self)
    791             success, value = self.queue.get()
    792             if not success:
--> 793                 six.reraise(value.__class__, value, value.__traceback__)

/home/venv/lib/python3.6/site-packages/six.py in reraise(tp, value, tb)
    691             if value.__traceback__ is not tb:
    692                 raise value.with_traceback(tb)
--> 693             raise value
    694         finally:
    695             value = None

/home/venv/lib/python3.6/site-packages/keras/utils/data_utils.py in _data_generator_task(self)
    656                             # => Serialize calls to
    657                             # infinite iterator/generator's next() function
--> 658                             generator_output = next(self._generator)
    659                             self.queue.put((True, generator_output))
    660                         else:

/home/venv/src/mask-rcnn/mrcnn/model.py in data_generator(dataset, config, shuffle, augment, augmentation, random_rois, batch_size, detection_targets, no_augmentation_sources)
   1707                     load_image_gt(dataset, config, image_id, augment=augment,
   1708                                 augmentation=augmentation,
-> 1709                                 use_mini_mask=config.USE_MINI_MASK)
   1710 
   1711             # Skip images that have no instances. This can happen in cases

/home/venv/src/mask-rcnn/mrcnn/model.py in load_image_gt(dataset, config, image_id, augment, augmentation, use_mini_mask)
   1210     # Load image and mask
   1211     image = dataset.load_image(image_id)
-> 1212     mask, class_ids = dataset.load_mask(image_id)
   1213     original_shape = image.shape
   1214     image, window, scale, padding, crop = utils.resize_image(

<ipython-input-41-562fec61f152> in load_mask(self, image_id)
     83             mask_draw = ImageDraw.ImageDraw(mask, '1')
     84             for segmentation in annotation['segmentation']:
---> 85                 mask_draw.polygon(segmentation, fill=1)
     86                 bool_array = np.array(mask) > 0
     87                 instance_masks.append(bool_array)

/home/venv/lib/python3.6/site-packages/PIL/ImageDraw.py in polygon(self, xy, fill, outline)
    238         ink, fill = self._getink(outline, fill)
    239         if fill is not None:
--> 240             self.draw.draw_polygon(xy, fill, 1)
    241         if ink is not None and ink != fill:
    242             self.draw.draw_polygon(xy, ink, 0)

TypeError: argument must be sequence
carlos-justo commented 4 years ago

same error, did you solve it?