zhaozhengChen / LPCAM

The official code of CVPR 2023 paper (Extracting Class Activation Maps from Non-Discriminative Features as well).
30 stars 4 forks source link

Could you provide the setting of training Deeplab on MSCOCO dataset? #3

Closed Italy2006 closed 1 year ago

zhaozhengChen commented 1 year ago

Thanks for your interest in our work. This is the config file for training Deeplab on the MSCOCO dataset. Compared to the config on VOC dataset, there are only a few modifications: change the BATCH_SIZE to 10, ITER_MAX to 100000, and LR to 2e-4.

EXP:
    ID: coco
    OUTPUT_DIR: data_coco

DATASET:
    NAME: coco
    ROOT: ./data/datasets/coco_2014
    LABELS: ./data/datasets/coco_2014/mask
    N_CLASSES: 81
    IGNORE_LABEL: 255
    SCALES: [0.5, 0.75, 1.0, 1.25, 1.5]
    SPLIT:
        TRAIN: train2014
        VAL: val2014
        TEST: no

DATALOADER:
    NUM_WORKERS: 8

IMAGE:
    MEAN:
        R: 122.675
        G: 116.669
        B: 104.008
    SIZE:
        BASE: # None
        TRAIN: 321
        TEST: 513

MODEL:
    NAME: DeepLabV2_ResNet101_MSC
    N_BLOCKS: [3, 4, 23, 3]
    ATROUS_RATES: [6, 12, 18, 24]
    INIT_MODEL: data/models/imagenet/deeplabv1_resnet101-imagenet.pth

SOLVER:
    BATCH_SIZE:
        TRAIN: 10
        TEST: 1
    ITER_MAX: 100000
    ITER_SIZE: 2
    ITER_SAVE: 5000
    ITER_TB: 20
    LR_DECAY: 10
    LR: 2e-4
    MOMENTUM: 0.9
    OPTIMIZER: sgd
    POLY_POWER: 0.9
    WEIGHT_DECAY: 5.0e-4
    AVERAGE_LOSS: 20

CRF:
    ITER_MAX: 10
    POS_W: 3
    POS_XY_STD: 1
    BI_W: 4
    BI_XY_STD: 67
    BI_RGB_STD: 3
Italy2006 commented 1 year ago

Thanks for your interest in our work. This is the config file for training Deeplab on the MSCOCO dataset. Compared to the config on VOC dataset, there are only a few modifications: change the BATCH_SIZE to 10, ITER_MAX to 100000, and LR to 2e-4.

EXP:
    ID: coco
    OUTPUT_DIR: data_coco

DATASET:
    NAME: coco
    ROOT: ./data/datasets/coco_2014
    LABELS: ./data/datasets/coco_2014/mask
    N_CLASSES: 81
    IGNORE_LABEL: 255
    SCALES: [0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0]
    SPLIT:
        TRAIN: train2014
        VAL: val2014
        TEST: no

DATALOADER:
    NUM_WORKERS: 8

IMAGE:
    MEAN:
        R: 122.675
        G: 116.669
        B: 104.008
    SIZE:
        BASE: # None
        TRAIN: 481
        TEST: 513

MODEL:
    NAME: DeepLabV2_ResNet101_MSC
    N_BLOCKS: [3, 4, 23, 3]
    ATROUS_RATES: [6, 12, 18, 24]
    INIT_MODEL: data/models/imagenet/deeplabv1_resnet101-imagenet.pth

SOLVER:
    BATCH_SIZE:
        TRAIN: 10
        TEST: 1
    ITER_MAX: 100000
    ITER_SIZE: 1
    ITER_SAVE: 2500
    ITER_TB: 20
    LR_DECAY: 10
    LR: 2.5e-4
    MOMENTUM: 0.9
    OPTIMIZER: sgd
    POLY_POWER: 0.9
    WEIGHT_DECAY: 5.0e-4
    AVERAGE_LOSS: 20

CRF:
    ITER_MAX: 10
    POS_W: 3
    POS_XY_STD: 1
    BI_W: 4
    BI_XY_STD: 67
    BI_RGB_STD: 3

Thanks a lot, and i want to know whether you use the balance loss?

zhaozhengChen commented 1 year ago

No, we use the classical Cross Entropy loss (torch.nn.CrossEntropyLoss).

Italy2006 commented 1 year ago

No, we use the classical Cross Entropy loss (torch.nn.CrossEntropyLoss).

Thanks, and how many GPU you used for training? 2? I use one and it shows out of memoory

zhaozhengChen commented 1 year ago

I used two RTX 3090 (24GB) GPUs for training, but it is OK for a single GPU as well.

Italy2006 commented 1 year ago

I used two RTX 3090 (24GB) GPUs for training, but it is OK for a single GPU as well.

I have tried two 3090 (24GB) but it still shows out of memory...

zhaozhengChen commented 1 year ago

It shouldn't be out of memory if you set the BATCH_SIZE to 10. What IMAGE SIZE do you use?

Italy2006 commented 1 year ago

It shouldn't be out of memory if you set the BATCH_SIZE to 10. What IMAGE SIZE do you use?

I copy your config so the size is 481x481. I try it on a single a100 gpu and it costs 58g

zhaozhengChen commented 1 year ago

Sorry, I give you the wrong config. I have updated it. I use the image size 321x321 (same as VOC).

Italy2006 commented 1 year ago

Sorry, I give you the wrong config. I have updated it. I use the image size 321x321 (same as VOC).

Thanks! But i want to know wherther you have tried the size of 481x481? It seems that other works use this size.

zhaozhengChen commented 1 year ago

Yes, I have tried it and got a similar result.

Italy2006 commented 1 year ago

Yes, I have tried it and got a similar result.

Well, thank you! To be honest i follow you from this link https://github.com/jbeomlee93/RIB/issues/2#issue-1040396333, and he provide the size of 481x481 so i am a little curious hhh

zhaozhengChen commented 1 year ago

I cannot remember who provide the size 321x321 to me hhh. Most of the project doesn't provide the details of training DeepLab on the MS COCO dataset.

Italy2006 commented 1 year ago

I cannot remember who provide the size 321x321 to me hhh. Most of the project doesn't provide the details of training DeepLab on the MS COCO dataset.

Yes,it costs met two days to find the details of the corresponding settings. Thank you very much!

lucasdavid commented 1 year ago

Hello. Thank you for the amazing work here. Could you please share your libs/datasets/coco.py and data/datasets/coco lists? deeplab-pytorch and AdvCAM do not expecify which ones they are using.

henry227 commented 1 year ago

image Hi,i want to ask , is the mask stored as a pseudo label or a category list in the path setting of the labels in the coco configuration file ? Have you changed it?

zhaozhengChen commented 1 year ago

image Hi,i want to ask , is the mask stored as a pseudo label or a category list in the path setting of the labels in the coco configuration file ? Have you changed it?

Yes, pseudo label.

zhaozhengChen commented 1 year ago

image Hi,i want to ask , is the mask stored as a pseudo label or a category list in the path setting of the labels in the coco configuration file ? Have you changed it?

Sorry for the late reply. This is the dataset file for COCO2014.

#!/usr/bin/env python
# coding: utf-8
#
# Author:   Zhaozheng
# Created:  2021-10

from __future__ import absolute_import, print_function

import os.path as osp
from glob import glob

import cv2
import numpy as np
import scipy.io as sio
import torch
from PIL import Image
from torch.utils import data

from .base import _BaseDataset

class coco2014(_BaseDataset):
    def __init__(self, **kwargs):
        super(coco2014, self).__init__(**kwargs)

    def _set_files(self):
        # Create data list via {train, test, all}.txt
        if self.split in ["train14", "val14"]:
            file_list = osp.join(self.root, self.split + ".txt")
            file_list = open(file_list, "r")
            file_list = [id_.rstrip() for id_ in file_list]
            self.files = file_list
        else:
            raise ValueError("Invalid split name: {}".format(self.split))

    def _load_data(self, index):
        # Set paths
        image_id = self.files[index]
        image_path = osp.join(self.root, "JPEGImages", image_id + ".jpg")
        if 'MSCOCO2' in self.label_dir:
            label_path = osp.join(self.label_dir, image_id + ".png")
        else:
            label_path = osp.join(self.label_dir, 'COCO_train2014_'+image_id + ".png")

        image = cv2.imread(image_path, cv2.IMREAD_COLOR).astype(np.float32)
        label = np.asarray(Image.open(label_path), dtype=np.int32)

        return image_id, image, label