Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello, I use gid data and use the FCEFModule model to train, but the following error is reported. Is it because of a version problem? thanks #40

Closed
xjellyx opened this issue Mar 14, 2022 · 2 comments

Comments

@xjellyx
Copy link

xjellyx commented Mar 14, 2022

there is my code

import torch
import torch.nn as nn
import pytorch_lightning as pl
from torchrs.datasets import GID15
from torchrs.train.modules import FCEFModule
from torchrs.train.datamodules import GID15DataModule
from torchrs.transforms import Compose, ToTensor


def collate_fn(batch):
    x = torch.stack([x["x"] for x in batch])
    y = torch.cat([x["mask"] for x in batch])
    x = x.to(torch.float32)
    y = y.to(torch.long)
    return x, y

transform = Compose([ToTensor()])

dm = GID15DataModule(
    root="./datasets/gid-15",
    transform=transform,
    batch_size=128,
    num_workers=1,
    prefetch_factor=1,
    collate_fn=collate_fn,
    test_collate_fn=collate_fn,
)


model = FCEFModule(channels=3, t=2, num_classes=15, lr=1E-3)


callbacks = [
    pl.callbacks.ModelCheckpoint(monitor="val_loss", mode="min", verbose=True, save_top_k=1),
    pl.callbacks.EarlyStopping(monitor="val_loss", mode="min", patience=10)
]

trainer = pl.Trainer(
    gpus=1,
    precision=16,
    accumulate_grad_batches=1,
    max_epochs=25,
    callbacks=callbacks,
    weights_summary="top"
)
#
trainer.fit(model, datamodule=dm)
trainer.test(datamodule=dm)

Error

image

@isaaccorley
Copy link
Owner

FCEF is a model for change detection. The GID-15 dataset is just a semantic segmentation dataset. I would recommend using the segmentation_models_pytorch U-Net model instead (smp.Unet).

@xjellyx
Copy link
Author

xjellyx commented Mar 14, 2022

thanks

@xjellyx xjellyx closed this as completed Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants