windygoo / PromptNucSeg

[ECCV 2024] Code for "Unleashing the Power of Prompt-driven Nucleus Instance Segmentation"
46 stars 6 forks source link

图片大小的问题 #2

Closed wzr0108 closed 9 months ago

wzr0108 commented 10 months ago

作者您好,我在训练prompter的时候遇到这个问题

    return torch.stack(images), torch.stack(masks), points, labels
RuntimeError: stack expects each tensor to be equal size, but got [3, 512, 512] at entry 0 and [3, 608, 608] at entry 1

是两张图片的大小不一样导致的 我使用的是cpm17数据集,配置文件是prompter/config/cpm17.py。 cpm17的图片大小不一致,数据增强部分有pad,但是并没有pad到同一大小

train=dict(
        transform=[
            dict(type="RandomGridShuffle", grid=(4, 4), p=0.5),
            dict(
                type="ColorJitter",
                brightness=0.25,
                contrast=0.25,
                saturation=0.1,
                hue=0.05,
                p=0.2,
            ),
            dict(type="RandomRotate90", p=0.5),
            dict(type="Downscale", scale_max=0.5, scale_min=0.5, p=0.15),
            dict(type="Blur", blur_limit=10, p=0.2),
            dict(type="GaussNoise", var_limit=50, p=0.25),
            dict(type="ZoomBlur", p=0.1, max_factor=1.05),
            dict(type="HorizontalFlip", p=0.5),
            dict(type="VerticalFlip", p=0.5),
            dict(
                type="ShiftScaleRotate",
                shift_limit=0.3,
                scale_limit=0.1,
                rotate_limit=0,
                border_mode=0,
                value=0,
                p=0.5,
            ),
            dict(
                type="PadIfNeeded",
                min_height=None,
                min_width=None,
                pad_height_divisor=prompter["space"],
                pad_width_divisor=prompter["space"],
                position="top_left",
                p=1,
            ),
            dict(type="Normalize"),
        ]
    ),
windygoo commented 10 months ago

作者您好,我在训练prompter的时候遇到这个问题

    return torch.stack(images), torch.stack(masks), points, labels
RuntimeError: stack expects each tensor to be equal size, but got [3, 512, 512] at entry 0 and [3, 608, 608] at entry 1

是两张图片的大小不一样导致的 我使用的是cpm17数据集,配置文件是prompter/config/cpm17.py。 cpm17的图片大小不一致,数据增强部分有pad,但是并没有pad到同一大小

train=dict(
        transform=[
            dict(type="RandomGridShuffle", grid=(4, 4), p=0.5),
            dict(
                type="ColorJitter",
                brightness=0.25,
                contrast=0.25,
                saturation=0.1,
                hue=0.05,
                p=0.2,
            ),
            dict(type="RandomRotate90", p=0.5),
            dict(type="Downscale", scale_max=0.5, scale_min=0.5, p=0.15),
            dict(type="Blur", blur_limit=10, p=0.2),
            dict(type="GaussNoise", var_limit=50, p=0.25),
            dict(type="ZoomBlur", p=0.1, max_factor=1.05),
            dict(type="HorizontalFlip", p=0.5),
            dict(type="VerticalFlip", p=0.5),
            dict(
                type="ShiftScaleRotate",
                shift_limit=0.3,
                scale_limit=0.1,
                rotate_limit=0,
                border_mode=0,
                value=0,
                p=0.5,
            ),
            dict(
                type="PadIfNeeded",
                min_height=None,
                min_width=None,
                pad_height_divisor=prompter["space"],
                pad_width_divisor=prompter["space"],
                position="top_left",
                p=1,
            ),
            dict(type="Normalize"),
        ]
    ),

我更新了下config文件,应该可以了。

wzr0108 commented 10 months ago

屏幕截图 2024-01-30 163053 这个loss是正常的吗

windygoo commented 10 months ago

屏幕截图 2024-01-30 163053 这个loss是正常的吗

不正常,重新拉一下prompter/dataset.py

windygoo commented 10 months ago

你加我qq吧, 1373697070

wzr0108 commented 10 months ago

这个qq号搜不到啊

wzr0108 commented 10 months ago

image

windygoo commented 10 months ago

这个qq号搜不到啊

你再试试?