Giter Site home page Giter Site logo

likyoo / siam-nestedunet Goto Github PK

View Code? Open in Web Editor NEW
247.0 6.0 59.0 2.35 MB

The pytorch implementation for "SNUNet-CD: A Densely Connected Siamese Network for Change Detection of VHR Images"

License: MIT License

Python 100.00%
pytorch change-detection

siam-nestedunet's Introduction

SNUNet-CD

authorlast commitissuesstarsforkslicense

PWC

SNUNet

News: 🎁🎁🎁 SNUNet-CD is supported in OpenCD and gets better results !!! You can find something here. Enjoy it ~ 😋😋😋

The pytorch implementation for "SNUNet-CD: A Densely Connected Siamese Network for Change Detection of VHR Images ". The paper is published on IEEE Geoscience and Remote Sensing Letters.

Our conference version "Siamese NestedUNet Networks for Change Detection of High Resolution Satellite Image" is published on CCRIS 2020: 2020 International Conference on Control, Robotics and Intelligent System. Its implementation (Siam-NestedUNet) is archived in Tag v1.1 .

Requirements

  • Python 3.6

  • Pytorch 1.4

  • torchvision 0.5.0

# other packages needed
pip install opencv-python tqdm tensorboardX sklearn

Dataset

Train from scratch

python train.py

Evaluate model performance

python eval.py

Visualization

python visualization.py

Pre-trained models

The pre-trained models in CDD dataset are available.

google drive | baidu disk (w90j)

Citation

If you find this work valuable or use our code in your own research, please consider citing us with the following bibtex:

@inproceedings{10.1145/3437802.3437810,
author = {Li, Kaiyu and Li, Zhe and Fang, Sheng},
title = {Siamese NestedUNet Networks for Change Detection of High Resolution Satellite Image},
year = {2020},
isbn = {9781450388054},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/3437802.3437810},
doi = {10.1145/3437802.3437810},
abstract = {Change detection is an important task in remote sensing (RS) image analysis. With the development of deep learning and the increase of RS data, there are more and more change detection methods based on supervised learning. In this paper, we improve the semantic segmentation network UNet++ and propose a fully convolutional siamese network (Siam-NestedUNet) for change detection. We combine three types of siamese structures with UNet++ respectively to explore the impact of siamese structures on the change detection task under the condition of a backbone network with strong feature extraction capabilities. In addition, for the characteristics of multiple outputs in Siam-NestedUNet, we design a set of experiments to explore the importance level of the output at different semantic levels. According to the experimental results, our method improves greatly on a number of indicators, including precision, recall, F1-Score and overall accuracy, and has better performance than other SOTA change detection methods. Our implementation will be released at https://github.com/likyoo/Siam-NestedUNet.},
booktitle = {2020 International Conference on Control, Robotics and Intelligent System},
pages = {42–48},
numpages = {7},
keywords = {Change Detection, Remote Sensing Image Processing, Fully Convolutional Siamese Network, Deep Learning},
location = {Xiamen, China},
series = {CCRIS 2020}
}
@ARTICLE{9355573,
  author={S. {Fang} and K. {Li} and J. {Shao} and Z. {Li}},
  journal={IEEE Geoscience and Remote Sensing Letters}, 
  title={SNUNet-CD: A Densely Connected Siamese Network for Change Detection of VHR Images}, 
  year={2021},
  volume={},
  number={},
  pages={1-5},
  doi={10.1109/LGRS.2021.3056416}}

Contact Information

Kaiyu Li: [email protected]

References

Appreciate the work from the following repositories:

siam-nestedunet's People

Contributors

efii avatar likyoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

siam-nestedunet's Issues

UserWarning: Implicit dimension choice for log_softmax has been deprecated in CPU mode

Hello @likyoo ,
I've runned train.py in Linux in CPU mode and get user userWarning

epoch 0 info 832 - 848: 42%|████████████████████████▏ | 52/125 [26:33<37:16, 30.64s/it]^C
Traceback (most recent call last):
ion choice for log_softmax has been deprecated. Change the call to include dim=X as an argument.
logpt = F.log_softmax(input)

To fix this issue edited code in model.py file to
logpt = F.log_softmax(input, dim=1)

超参数

你好 超参数中“EF”默认是FALSE 它代表的是什么呀 我复现网络出来精度怎么差了几个点

freeze_support()报错

你好,请问代码在运行过程中会出现这个报错是啥回事呢
INFO:root:GPU AVAILABLE? True
INFO:root:STARTING Dataset Creation
INFO:root:STARTING Dataloading
INFO:root:LOADING Model
INFO:root:STARTING training
INFO:root:SET model mode to train!
0%| | 0/500 [00:00<?, ?it/s]
代码跑到这个地方就报错了!!!

freeze_support() on Windows Python 3.8

Hello,
I have checked this project on Windows 10 with Python 3.8, and get an error.

PS S:\gis\siameseDetect\Siam-NestedUNet> python train.py
  File "train.py", line 68
    for epoch in range(opt.epochs):
    ^
IndentationError: expected an indented block
PS S:\gis\siameseDetect\Siam-NestedUNet> python train.py
INFO:root:GPU AVAILABLE? False
INFO:root:STARTING Dataset Creation
INFO:root:STARTING Dataloading
INFO:root:LOADING Model
INFO:root:STARTING training
INFO:root:SET model mode to train!
  0%|                                                                        | 0/188 [00:00<?, ?it/s]INFO:root:GPU AVAILABLE? False
INFO:root:STARTING Dataset Creation
INFO:root:STARTING Dataloading
INFO:root:LOADING Model
INFO:root:STARTING training
INFO:root:SET model mode to train!
  0%|                                                                        | 0/188 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Python38\lib\multiprocessing\spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "C:\Python38\lib\multiprocessing\spawn.py", line 125, in _main
    prepare(preparation_data)
  File "C:\Python38\lib\multiprocessing\spawn.py", line 236, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Python38\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
  File "C:\Python38\lib\runpy.py", line 265, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "C:\Python38\lib\runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "C:\Python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "S:\gis\siameseDetect\Siam-NestedUNet\train.py", line 80, in <module>
    for batch_img1, batch_img2, labels in tbar:
  File "C:\Python38\lib\site-packages\tqdm\std.py", line 1166, in __iter__
    for obj in iterable:
  File "C:\Python38\lib\site-packages\torch\utils\data\dataloader.py", line 279, in __iter__
    return _MultiProcessingDataLoaderIter(self)
  File "C:\Python38\lib\site-packages\torch\utils\data\dataloader.py", line 719, in __init__
    w.start()
  File "C:\Python38\lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)
  File "C:\Python38\lib\multiprocessing\context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:\Python38\lib\multiprocessing\context.py", line 327, in _Popen
    return Popen(process_obj)
  File "C:\Python38\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "C:\Python38\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
    _check_not_importing_main()
  File "C:\Python38\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main
    raise RuntimeError('''
RuntimeError:
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

number of gpus setted to 0 on metadata.json file, because I've not CUDA
torch and torchvision installed like this.
pip install torch==1.4.0+cpu torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

If this code runned and tested in non-Windows environment, please share tested operating system info, if it's possible.

Calculate FLOPs and Params

You recommend using thop (https://github.com/Lyken17/pytorch-OpCounter) to calculate FLOPs, but the official example of pytorch-OpCounter calculates MACs, does MACs(G)=FLOPs?In addition, why is the Params I calculated slightly different from yours? FC-EF: Params(M)-1.1, MACs=2.02; FC-Siam-conc: Params(M)-1.55, MACs=5.33; FC-Siam-diff: Params(M)-1.35, MACs=4.73;
SNUNet(32):Params(M)-12.03, MACs=54.83.
Hope to get your answer, thank you!

freeze_support()

Thank you! That has worked.

However I am getting another error now. Can't understand what this means...

(siamese_nested_unet) PS G:\NeuroPixel\segmentation\unet_plus_plus\siamese_nested_unet\Siam-NestedUNet-master> python train.py INFO:root:GPU AVAILABLE? True INFO:root:STARTING Dataset Creation INFO:root:STARTING Dataloading INFO:root:LOADING Model INFO:root:STARTING training INFO:root:SET model mode to train! 0%| | 0/625 [00:00<?, ?it/s]INFO:root:GPU AVAILABLE? True INFO:root:STARTING Dataset Creation INFO:root:STARTING Dataloading INFO:root:LOADING Model INFO:root:STARTING training INFO:root:SET model mode to train! 0%| | 0/625 [00:00<?, ?it/s] Traceback (most recent call last): File "", line 1, in File "F:\Anaconda\envs\siamese_nested_unet\lib\multiprocessing\spawn.py", line 105, in spawn_main exitcode = _main(fd) 0%| | 0/625 [00:03<?, ?it/s] File "F:\Anaconda\envs\siamese_nested_unet\lib\multiprocessing\spawn.py", line 114, in _main

Traceback (most recent call last):

prepare(preparation_data) File "train.py", line 79, in

  File "F:\Anaconda\envs\siamese_nested_unet\lib\multiprocessing\spawn.py", line 225, in prepare

for batch_img1, batch_img2, labels in tbar: _fixup_main_from_path(data['init_main_from_path']) File "F:\Anaconda\envs\siamese_nested_unet\lib\site-packages\tqdm\std.py", line 1185, in iter

File "F:\Anaconda\envs\siamese_nested_unet\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path for obj in iterable:run_name="mp_main")

File "F:\Anaconda\envs\siamese_nested_unet\lib\site-packages\torch\utils\data\dataloader.py", line 359, in iter File "F:\Anaconda\envs\siamese_nested_unet\lib\runpy.py", line 263, in run_path pkg_name=pkg_name, script_name=fname) File "F:\Anaconda\envs\siamese_nested_unet\lib\runpy.py", line 96, in _run_module_code mod_name, mod_spec, pkg_name, script_name) File "F:\Anaconda\envs\siamese_nested_unet\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "G:\NeuroPixel\segmentation\unet_plus_plus\siamese_nested_unet\Siam-NestedUNet-master\train.py", line 79, in for batch_img1, batch_img2, labels in tbar: File "F:\Anaconda\envs\siamese_nested_unet\lib\site-packages\tqdm\std.py", line 1185, in iter for obj in iterable: File "F:\Anaconda\envs\siamese_nested_unet\lib\site-packages\torch\utils\data\dataloader.py", line 359, in iter return self._get_iterator() File "F:\Anaconda\envs\siamese_nested_unet\lib\site-packages\torch\utils\data\dataloader.py", line 305, in _get_iterator return self._get_iterator() return _MultiProcessingDataLoaderIter(self) File "F:\Anaconda\envs\siamese_nested_unet\lib\site-packages\torch\utils\data\dataloader.py", line 305, in _get_iterator

  File "F:\Anaconda\envs\siamese_nested_unet\lib\site-packages\torch\utils\data\dataloader.py", line 918, in __init__

return _MultiProcessingDataLoaderIter(self) File "F:\Anaconda\envs\siamese_nested_unet\lib\site-packages\torch\utils\data\dataloader.py", line 918, in init w.start() File "F:\Anaconda\envs\siamese_nested_unet\lib\multiprocessing\process.py", line 105, in start w.start() File "F:\Anaconda\envs\siamese_nested_unet\lib\multiprocessing\process.py", line 105, in start self._popen = self._Popen(self)self._popen = self._Popen(self)

File "F:\Anaconda\envs\siamese_nested_unet\lib\multiprocessing\context.py", line 223, in _Popen File "F:\Anaconda\envs\siamese_nested_unet\lib\multiprocessing\context.py", line 223, in _Popen return _default_context.get_context().Process._Popen(process_obj) File "F:\Anaconda\envs\siamese_nested_unet\lib\multiprocessing\context.py", line 322, in _Popen return _default_context.get_context().Process._Popen(process_obj)return Popen(process_obj)

File "F:\Anaconda\envs\siamese_nested_unet\lib\multiprocessing\context.py", line 322, in _Popen File "F:\Anaconda\envs\siamese_nested_unet\lib\multiprocessing\popen_spawn_win32.py", line 33, in init return Popen(process_obj) File "F:\Anaconda\envs\siamese_nested_unet\lib\multiprocessing\popen_spawn_win32.py", line 65, in init reduction.dump(process_obj, to_child) File "F:\Anaconda\envs\siamese_nested_unet\lib\multiprocessing\reduction.py", line 60, in dump prep_data = spawn.get_preparation_data(process_obj._name) File "F:\Anaconda\envs\siamese_nested_unet\lib\multiprocessing\spawn.py", line 143, in get_preparation_data _check_not_importing_main() File "F:\Anaconda\envs\siamese_nested_unet\lib\multiprocessing\spawn.py", line 136, in _check_not_importing_main is not going to be frozen to produce an executable.''') RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.
ForkingPickler(file, protocol).dump(obj)

BrokenPipeError: [Errno 32] Broken pipe

Reduce the num of workers when you load the dataset.

Originally posted by @Youskrpig in #11 (comment)

About the method

Is your proposed method based on a classification method or a Metric-based method? looking forward to your reply, and it is very important to me. Thank you.

关于代码和paper

我有点迷啊,我是从nestedunet这篇论文上的链接找过来的,但是我看代码又好像是snunet这篇论文的,nestedunet的代码上传了一部分。这两篇论文应该都是你们一个实验室出的,snunet论文的代码为什么不另外放在一个仓库中呢

Dataset

@likyoo , Thanks for your work.
The CD dataset is contains by two parts, Model and Real. Can you tell me what is the origin of data set Real. And I want to know what standard it uses to mark the change area.

Can this model be used as an encoder?

Hello, I was working on a project where I'm required to encode two images for finding multiclass semantic difference between them.
Can you please tell which one should I use(with Channel attention or without)? and what changes should i consider?

fine-tuning model

I wanna to fit the model on my dataset.
Is there any way to fine-tuning the model?

ValueError: not enough values to unpack (expected 4, got 1)

INFO:root:STARTING Dataset Creation
INFO:root:STARTING Dataloading
/home/anaconda3/envs/p36/lib/python3.6/site-packages/torch/serialization.py:453: SourceChangeWarning: source code of class 'models.Models.SNUNet_ECAM' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
2%|▏ | 64/3000 [00:37<28:54, 1.69it/s]Traceback (most recent call last):
File "/home/pythonProject/Siam-NestedUNet-master/eval.py", line 37, in
cd_preds.data.cpu().numpy().flatten()).ravel()
ValueError: not enough values to unpack (expected 4, got 1)

the issue of dataset

作者您好,我想问下关于数据集的问题,我的数据集只是把变化的建筑物给标记出来,并统一用白色表示变化的建筑物,黑色表示背景,并没有区分增加或者减少(您的预测结果好像用不同颜色区分增加或者减少了),这样会对用自己的数据训练带来影响吗?期待您的解惑!

how to train 512x512 images?

I found the only parameters related to training image size is in the file metadata.json as "patch_size": 256. If I need to train on 512x512 images, should I change the parameter to "patch_size": 512 ? is this enough?

After I did this, the training results show that the cd_precisions : 1.0, cd_recalls: 0.0, f1_scores: 0.1, what is the problem?

thanks in advance

about attention

likyoo您好, 我在n = 8的情况下对比了有ECAM和没有ECAM的情况, 发现没有ECAM的运行反而比有ECAM的指标高一点的
有ECAM的
image


没有ECAM的
image

请问您有遇到这种情况吗, 谢谢

libcaffe2_nvrtc.so file linking issue in Linux

Hello Author,

I am trying to use this network as an API in my current project and try to create an executable, however I face an issue as below:

Error in dlopen or dlsym: libcaffe2_nvrtc.so: cannot open shared object file: No such file or directory

May I know which part of the code uses this libraries to run, as this issue is quite random. When these so files are in the same directory as the executable it is working fine else it doesn't !

Any ideas on this one will be appreciated! Thank you!

indices should be either on cpu or on the same device as the indexed tensor (cpu)

INFO:root:GPU AVAILABLE? True
INFO:root:STARTING Dataset Creation
INFO:root:STARTING Dataloading
INFO:root:LOADING Model
INFO:root:STARTING training
INFO:root:SET model mode to train!
epoch 0 info 0 - 16: 0%| | 0/625 [00:00<?, ?it/s]C:\Dacon\Siam-NestedUNet-master\utils\metrics.py:33: UserWarning: Implicit dimension choice for log_softmax has been deprecated. Change the call to include dim=X as an argument.
logpt = F.log_softmax(input)
epoch 0 info 0 - 16: 0%| | 0/625 [00:02<?, ?it/s]
Traceback (most recent call last):
File "train.py", line 94, in
cd_loss = criterion(cd_preds, labels)
File "C:\Dacon\Siam-NestedUNet-master\utils\losses.py", line 17, in hybrid_loss
dice = dice_loss(prediction, target)
File "C:\Dacon\Siam-NestedUNet-master\utils\metrics.py", line 75, in dice_loss
true_1_hot = torch.eye(num_classes)[true.squeeze(1)]
RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)

i dont know what to do
plz help me

Questions about Accuracy Assessment

I am very interested in your paper. But when it comes to accuracy assessment, I have some problems. You used "prfs(labels.data.cpu().numpy().flatten(), cd_preds.data.cpu().numpy().flatten(), average='binary', pos_label=1 in train )" for accuracy evaluation, and use "tn, fp, fn, tp =
confusion_matrix(labels.data.cpu().numpy().flatten(),cd_preds.data.cpu().numpy().flatten()).ravel()" in eval. During the calculation, I found that the accuracy of the two methods differed by up to 10%. May I ask why the accuracy of the two methods is so different. Which method is more reliable for accuracy assessment?
Looking forward to your answer, thank you!

Visualize and save result pictures

Hello, author!
Thank you for the code, I would like to ask if you have written a visualization module and a saving result image module in the code.

_, cd_preds1 = torch.max(cd_preds, 1)

您好,我对您的论文非常感兴趣。由于我刚入门,在理解计算预测图时遇到了一些问题,如标题,cd_preds是模型处理得到的结果,cd_preds的维度是[1(B), 2(C), 256(H), 256(W)],torch.max(cd_preds, 1)是取cd_preds在维度【2(C)】上的最大值,得到了维度为[1,256,256]最大值_和索引号(非0即1)cd_preds1,并将cd_preds1作为最终的预测结果。请问上述我的解析正确吗?cd_preds1作为最终的预测结果的依据是什么?非常希望得到您的回答,谢谢!

upload the paper to arxiv

Hi, thanks for the nice code first! And I was wondering if you could upload the paper to the web like arxiv, since it will help to understand the code a lot!

about loss

在文章中,我看到使用的loss是wce loss + dice loss,代码中看见用的是focal loss + dice loss。想问下是否是一致的?还想确定一下是否是SNUNet(GRSL)官方代码?谢谢!

F1 score

Hi likyoo,

Thank you for your great work.

I am wondering how you calculate F1 score.

I saw someone calculate f1 for unchanged class, and f1 for changed class. Then average these two f1 score.(they call it macro F1).

dataloading issue

error1

Hi! Thanks for uploading the code. I am facing the above error when running : "python train.py"
Looks like there is something wrong with the folder structure maintained by me or may be I need to provide the folder structure path as input somewhere. Can you kindly shed light on how to resolve this issue?

关于参数cd_corrects

非常感谢您能分享此代码,冒昧的问一下,方便告知一下cd_corrects的含义吗?如想计算Acc = (tp + tn)/(tp + tn + fp + fn),cd_corrects=Accuracy吗?谢谢

some issues

Thank you very much for your excellent work. The FLOPs I calculated are inconsistent with the results in this letter. I want to know how you calculate FLOPs? If it is convenient, can you share the code for calculating FLOPs? And I noticed that the accuracy of the public model is higher than that in this letter. Is this the best model you trained?Or is it different test results caused by different hardware? I'm looking forward to your reply.

attentional heatmap

How to visualize the attentional heatmap, could you provide some reference code.

tensorboard

in train.py line 168: for k, v in mean_train_metrics.items():
Maybe change "mean_train_metrics" to "mean_val_metrics"

About Dice Loss

The function of dice loss in the code:

def dice_loss(logits, true, eps=1e-7):
    """Computes the Sørensen–Dice loss.
    Note that PyTorch optimizers minimize a loss. In this
    case, we would like to maximize the dice loss so we
    return the negated dice loss.
    Args:
        true: a tensor of shape [B, 1, H, W].
        logits: a tensor of shape [B, C, H, W]. Corresponds to
            the raw output or logits of the model.
        eps: added to the denominator for numerical stability.
    Returns:
        dice_loss: the Sørensen–Dice loss.
    """
    num_classes = logits.shape[1]
    if num_classes == 1:
        true_1_hot = torch.eye(num_classes + 1)[true.squeeze(1)]
        true_1_hot = true_1_hot.permute(0, 3, 1, 2).float()
        true_1_hot_f = true_1_hot[:, 0:1, :, :]
        true_1_hot_s = true_1_hot[:, 1:2, :, :]
        true_1_hot = torch.cat([true_1_hot_s, true_1_hot_f], dim=1)
        pos_prob = torch.sigmoid(logits)
        neg_prob = 1 - pos_prob
        probas = torch.cat([pos_prob, neg_prob], dim=1)
    else:
        true_1_hot = torch.eye(num_classes)[true.squeeze(1)]
        true_1_hot = true_1_hot.permute(0, 3, 1, 2).float()
        probas = F.softmax(logits, dim=1)
    true_1_hot = true_1_hot.type(logits.type())
    dims = (0,) + tuple(range(2, true.ndimension()))
    intersection = torch.sum(probas * true_1_hot, dims)
    cardinality = torch.sum(probas + true_1_hot, dims)
    dice_loss = (2.0 * intersection / (cardinality + eps)).mean()
    return 1 - dice_loss

intersection and cardinality are calculated by

dims = (0,) + tuple(range(2, true.ndimension()))
intersection = torch.sum(probas * true_1_hot, dims)
cardinality = torch.sum(probas + true_1_hot, dims)

when the shape of input true is (B, H, W), dims is (0, 2). However, according to the definition of dice loss $1-\frac{2*I}{U}$, dims should be (2, 3), so I think the code here may be:

dims = tuple(range(2, logits.ndimension()))

Would you please double check or see if I misunderstood?

eval.py accessing sunet-32.pt instead of snunet-32.pt

The weights-20220718T230451Z-001.zip file has a bunch of snunet-*.pt files, but eval.py attempts to load weights/sunet-32.pt.

My patch:

index bd6bbaa..a215ba4 100644
--- a/eval.py
+++ b/eval.py
@@ -15,7 +15,7 @@ dev = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')

test_loader = get_test_loaders(opt)

-path = 'weights/sunet-32.pt' # the path of the model
+path = 'weights/snunet-32.pt' # the path of the model
model = torch.load(path)

About WHU dataset

您好,请问一下我用这个代码跑WHU数据集,为什么会出现这样的结果,跑LEVIR就没有问题,希望有时间您能回复一下,非常感谢。
INFO:root:EPOCH 1 TRAIN METRICS{'cd_losses': 0.5, 'cd_corrects': 100.0, 'cd_precisions': 0.0, 'cd_recalls': 0.0, 'cd_f1scores': 0.0, 'learning_rate': 0.0010000000000000002}
INFO:root:EPOCH 1 VALIDATION METRICS{'cd_losses': 0.5, 'cd_corrects': 100.00000016232754, 'cd_precisions': 0.0, 'cd_recalls': 0.0, 'cd_f1scores': 0.0, 'learning_rate': 0.00100000000000
00002}

About data loading

When I debug the data loading code, I find that there is no code of B. is there an error here?

Does the same high performance for false color image change detection?

Thank you very much for your work, I am doing a change detection task on false color images, referring to your framework, which is currently performing average on my dataset, and I hope you can guide me in which direction I should improve.
Also, for large size tif images, can you provide a source code that can be used to reduce the crop prediction edge effect? I have used my previous semantic segmentation method in your framework with mediocre results, so I would appreciate it if you could provide it!😂😂

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.