SwinTransformer / Swin-Transformer-Object-Detection

This is an official implementation for "Swin Transformer: Hierarchical Vision Transformer using Shifted Windows" on Object Detection and Instance Segmentation.
https://arxiv.org/abs/2103.14030
Apache License 2.0
1.79k stars 378 forks source link

Can't see train loss when train on custom dataset. #125

Closed LZYmixiu closed 2 years ago

LZYmixiu commented 2 years ago

I have trained on custom dataset which included 45 pics in training set. I can't see train loss when train on this dataset, only the metric result showed in terminal. Here is my config file:

_base_ = './cascade_mask_rcnn_swin_tiny_patch4_window7_mstrain_480-800_giou_4conv1f_adamw_3x_coco.py

dataset_type = 'CocoDataset'
classes = ('counter_weight',)
data_root = './MTDATA'
data = dict(
    samples_per_gpu=2,
    workers_per_gpu=2,
    train=dict(
        type=dataset_type,
        # explicitly add your class names to the field `classes`
        classes=classes,
        ann_file=data_root + 'annotations/gray_train.json',
        img_prefix=data_root + 'train'),
    val=dict(
        type=dataset_type,
        # explicitly add your class names to the field `classes`
        classes=classes,
        ann_file=data_root + 'annotations/gray_val.json',
        img_prefix=data_root + 'val'),
    test=dict(
        type=dataset_type,
        # explicitly add your class names to the field `classes`
        classes=classes,
        ann_file=data_root + 'annotations/gray_val.json',
        img_prefix=data_root + 'val'))

model = dict(
    roi_head=dict(
        bbox_head=[
            dict(
                type='Shared2FCBBoxHead',
                # explicitly over-write all the `num_classes` field.
                num_classes=1),
            dict(
                type='Shared2FCBBoxHead',
                # explicitly over-write all the `num_classes` field.
                num_classes=1),
            dict(
                type='Shared2FCBBoxHead',
                # explicitly over-write all the `num_classes` field.
                num_classes=1)],
    # explicitly over-write all the `num_classes` field.
    mask_head=dict(num_classes=1)))

And I run this config file using: CUDA_VISIBLE_DEVICES=2 python ./tools/train.py configs/swin/counter_weight_config.py --work-dir ./weights/counterweight_20211207/

impiga commented 2 years ago

Hi, the default logging interval is 50 iterations (see this line). This means that it will print training information at 50,100,150.. iterations of each epoch. However, there are only 45 images in the custom training set and batch size is 2, so that there will be only 22 or 23 iterations per epoch.

You may add this line in your config:

log_config = dict(interval=1)
LZYmixiu commented 2 years ago

Hi, the default logging interval is 50 iterations (see this line). This means that it will print training information at 50,100,150.. iterations of each epoch. However, there are only 45 images in the custom training set and batch size is 2, so that there will be only 22 or 23 iterations per epoch.

You may add this line in your config:

log_config = dict(interval=1)

THX A LOT!

er778899789 commented 2 years ago

@LZYmixiu Sorry to bother you. I want to I want to training my custom dataset with Swin transfomer, I want to ask your dataset is label by which label tool ? ex. labelme ? If the tool is using labelme, after finishing the label, it need to transfer labelme json to coco json format right? Please share the training experience with me !!

LZYmixiu commented 2 years ago

Yes, my labeling tool is labelme and you should transfer the json files to coco format first.

---Original--- From: @.> Date: Thu, Feb 24, 2022 08:53 AM To: @.>; Cc: @.**@.>; Subject: Re: [SwinTransformer/Swin-Transformer-Object-Detection] Can't see train loss when train on custom dataset. (Issue #125)

@LZYmixiu Sorry to bother you. I want to I want to training my custom dataset with Swin transfomer, I want to ask your dataset is label by which label tool ? ex. labelme ? If the tool is using labelme, after finishing the label, it need to transfer labelme json to coco json format right? Please share the training experience with me !!

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.Message ID: @.***>

er778899789 commented 2 years ago

@LZYmixiu Sorry, I get a error in training. Like the following image. I training my custom dataset with Swin-Transformer-Object-Detection's code. image

I search this error, the solution is training with mmdetection not Swin-Transformer-Object-Detection. I want to ask, Do you training custom dataset use this Swin-Transformer-Object-Detection repositories code ? Or you download the mmdetection's code and copy the swin model python code and config file from Swin-Transformer-Object-Detection repositories to mmdetection to training ?

LZYmixiu commented 2 years ago

counter_weight_config.py is my custom config.Not the official code.

---Original--- From: @.> Date: Thu, Feb 24, 2022 14:27 PM To: @.>; Cc: @.**@.>; Subject: Re: [SwinTransformer/Swin-Transformer-Object-Detection] Can't seetrain loss when train on custom dataset. (Issue #125)

@LZYmixiu Sorry, I can't find config file like yours. (counter_weight_config.py) I only find cascade_mask_rcnn_swin_tiny_patch4_window7_mstrain_480-800_giou_4conv1f_adamw_3x_coco.py in swin folder. Where can I find this file (counter_weight_config.py) in Swin-Transformer-Object-Detection ?

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.Message ID: @.***>

LZYmixiu commented 2 years ago

This is the error created by mmdet version. You have problem with steps of mmdet installation which is wrong in official README.

---Original--- From: @.> Date: Fri, Feb 25, 2022 08:37 AM To: @.>; Cc: @.**@.>; Subject: Re: [SwinTransformer/Swin-Transformer-Object-Detection] Can't seetrain loss when train on custom dataset. (Issue #125)

@LZYmixiu Sorry, I get a error in training. Like the following image. I training my custom dataset with Swin-Transformer-Object-Detection's code.

I search this error, the solution is training with mmdetection not Swin-Transformer-Object-Detection. I want to ask, Do you training custom dataset use this Swin-Transformer-Object-Detection repositories code ? Or you download the mmdetection's code and copy the swin model python code and config file from Swin-Transformer-Object-Detection repositories to mmdetection to training ?

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.Message ID: @.***>

er778899789 commented 2 years ago

@LZYmixiu I already solve my problem by myself. Thanks a lot!!