dbolya / yolact

A simple, fully convolutional model for real-time instance segmentation.
MIT License
5.03k stars 1.32k forks source link

Unable to Load Images to train model on Custom Datasets #558

Closed kevalrajpalknight closed 4 years ago

kevalrajpalknight commented 4 years ago

Hello, I have just stuck with Image Instance Segmentation for a while. I am trying to train the Yolact model for my custom data. Here is some brief information about what I have done so far

  1. I have annotated the image using labelme annotation tool
  2. I have converted annotation file for each (train & validation data) using labelme2coco -> train.json & test.json
  3. I made changes in the cofig.py file as needed and expected by yolact
  4. As I was following this repository I encountered an error Argument 'bb' has incorrect type to which I have solved with the approach stated in this closed issue

After completing the above task I am stuck here with below-stated issue.

`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.00s) creating index... index created! loading annotations into memory... Done (t=0.00s) creating index... index created! /usr/local/lib/python3.6/dist-packages/torch/jit/_recursive.py:165: UserWarning: 'lat_layers' was found in ScriptModule constants, but it is a non-constant submodule. Consider removing it. " but it is a non-constant {}. Consider removing it.".format(name, hint)) /usr/local/lib/python3.6/dist-packages/torch/jit/_recursive.py:165: UserWarning: 'pred_layers' was found in ScriptModule constants, but it is a non-constant submodule. Consider removing it. " but it is a non-constant {}. Consider removing it.".format(name, hint)) /usr/local/lib/python3.6/dist-packages/torch/jit/_recursive.py:165: UserWarning: 'downsample_layers' was found in ScriptModule constants, but it is a non-constant submodule. Consider removing it. " but it is a non-constant {}. Consider removing it.".format(name, hint)) Initializing weights... Begin training!

Traceback (most recent call last): File "train.py", line 504, in train() File "train.py", line 270, in train for datum in data_loader: File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 363, in next data = self._next_data() File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 989, in _next_data return self._process_data(data) File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py", line 1014, in _process_data data.reraise() File "/usr/local/lib/python3.6/dist-packages/torch/_utils.py", line 395, in reraise raise self.exc_type(msg) AssertionError: Caught AssertionError in DataLoader worker process 0. Original Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/worker.py", line 185, in _worker_loop data = fetcher.fetch(index) File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/content/yolact/data/coco.py", line 94, in getitem im, gt, masks, h, w, num_crowds = self.pull_item(index) File "/content/yolact/data/coco.py", line 141, in pull_item assert osp.exists(path), 'Image path does not exist: {}'.format(path) AssertionError: Image path does not exist: data/YolaDataset/train/6.JPG`

NOTE:I have moved my test & train data to yolact/data/YolactDataset ( also CWD is /yolact/ )

Here is the Log file Yolact Leather Defect Config.log

Here is the content of config.py

yolact_leather_defect_dataset = Config({
    'name': 'Yolact Leather Defect',

    # Training images and annotations
    'train_images': './data/YolaDataset/train/',
    'train_info':   './data/train.json',

    # Validation images and annotations.
    'valid_images': './data/YolaDataset/test/',
    'valid_info':   './data/test.json',

    # Whether or not to load GT. If this is False, eval.py quantitative evaluation won't work.
    'has_gt': True,

    # A list of names for each of you classes.
    'class_names': ("FC", "LF", "OC", "PM"),

    # COCO class ids aren't sequential, so this is a bandage fix. If your ids aren't sequential,
    # provide a map from category_id -> index in class_names + 1 (the +1 is there because it's 1-indexed).
    # If not specified, this just assumes category ids start at 1 and increase sequentially.
    'label_map': {
        1:1, 2:2, 3:3, 4:4,
    }
})
yolact_leather_defect_config = coco_base_config.copy({
    'name': 'Yolact Leather Defect Config',

    # Dataset stuff
    'dataset': yolact_leather_defect_dataset,
    'num_classes': len(yolact_leather_defect_dataset.class_names) + 1,

    # Image Size
    'max_size': 550,

    # Training params
    'lr_steps': (280000, 600000, 700000, 750000),
    'max_iter': 800000,

    # Backbone Settings
    'backbone': resnet101_backbone.copy({
        'selected_layers': list(range(1, 4)),
        'use_pixel_scales': True,
        'preapply_sqrt': False,
        'use_square_anchors': True, # This is for backward compatability with a bug

        'pred_aspect_ratios': [ [[1, 1/2, 2]] ]*5,
        'pred_scales': [[24], [48], [96], [192], [384]],
    }),

    # FPN Settings
    'fpn': fpn_base.copy({
        'use_conv_downsample': True,
        'num_downsample': 2,
    }),

    # Mask Settings
    'mask_type': mask_type.lincomb,
    'mask_alpha': 6.125,
    'mask_proto_src': 0,
    'mask_proto_net': [(256, 3, {'padding': 1})] * 3 + [(None, -2, {}), (256, 3, {'padding': 1})] + [(32, 1, {})],
    'mask_proto_normalize_emulate_roi_pooling': True,

    # Other stuff
    'share_prediction_module': True,
    'extra_head_net': [(256, 3, {'padding': 1})],

    'positive_iou_threshold': 0.5,
    'negative_iou_threshold': 0.4,

    'crowd_iou_threshold': 0.7,

    'use_semantic_segmentation_loss': True,
})

I have tried to resolve the issue to the best can help myself. Any help would be appreciated.

Thank You!

kevalrajpalknight commented 4 years ago

I have miss-spelled the YolactDataset to YolaDataset in the configuration file.

xqh-code commented 1 year ago

I also have this problem with you, my reason is that there is a problem with the path of the picture, you are checking it well