GithubHelp home page GithubHelp logo

tramac / awesome-semantic-segmentation-pytorch Goto Github PK

View Code? Open in Web Editor NEW
2.8K 2.8K 580.0 1.75 MB

Semantic Segmentation on PyTorch (include FCN, PSPNet, Deeplabv3, Deeplabv3+, DANet, DenseASPP, BiSeNet, EncNet, DUNet, ICNet, ENet, OCNet, CCNet, PSANet, CGNet, ESPNet, LEDNet, DFANet)

License: Apache License 2.0

Python 99.91% Shell 0.09%
pytorch semantic-segmentation

awesome-semantic-segmentation-pytorch's Introduction

Hi, I'm Tramac 👋

A programmer from China, currently working on CV research at Baidu.

github follow Email HF 知乎

Tramac's github stats

awesome-semantic-segmentation-pytorch's People

Contributors

jeralyn123 avatar liminn avatar makanu avatar tramac avatar trellixvulnteam 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  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

awesome-semantic-segmentation-pytorch's Issues

error by python setup.py build develop

the error message as below

/home/allen/miniconda3/envs/pytorch/lib/python3.6/site-packages/torch/include/ATen/core/TensorMethods.h:1181:57: required from here
/usr/include/c++/6/tuple:483:67: error: mismatched argument pack lengths while expanding ‘std::is_constructible<_Elements, _UElements&&>’
return _and<is_constructible<_Elements, _UElements&&>...>::value;
^~~~~
/usr/include/c++/6/tuple:484:1: error: body of constexpr function ‘static constexpr bool std::_TC<, _Elements>::_MoveConstructibleTuple() [with _UElements = {std::tuple<at::Tensor, at::Tensor, at::Tensor>}; bool = true; _Elements = {at::Tensor, at::Tensor, at::Tensor}]’ not a return-statement
}
^
/usr/include/c++/6/tuple: In instantiation of ‘static constexpr bool std::_TC<, _Elements>::_ImplicitlyMoveConvertibleTuple() [with _UElements = {std::tuple<at::Tensor, at::Tensor, at::Tensor>}; bool = true; _Elements = {at::Tensor, at::Tensor, at::Tensor}]’:
/usr/include/c++/6/tuple:626:362: required by substitution of ‘template<class ... _UElements, typename std::enable_if<(((std::_TC<(sizeof... (_UElements) == 1), at::Tensor, at::Tensor, at::Tensor>::_NotSameTuple<_UElements ...>() && std::_TC<(1ul == sizeof... (_UElements)), at::Tensor, at::Tensor, at::Tensor>::_MoveConstructibleTuple<_UElements ...>()) && std::_TC<(1ul == sizeof... (_UElements)), at::Tensor, at::Tensor, at::Tensor>::_ImplicitlyMoveConvertibleTuple<_UElements ...>()) && (3ul >= 1)), bool>::type > constexpr std::tuple< >::tuple(_UElements&& ...) [with _UElements = {std::tuple<at::Tensor, at::Tensor, at::Tensor>}; typename std::enable_if<(((std::_TC<(sizeof... (_UElements) == 1), at::Tensor, at::Tensor, at::Tensor>::_NotSameTuple<_UElements ...>() && std::_TC<(1ul == sizeof... (_UElements)), at::Tensor, at::Tensor, at::Tensor>::_MoveConstructibleTuple<_UElements ...>()) && std::_TC<(1ul == sizeof... (_UElements)), at::Tensor, at::Tensor, at::Tensor>::_ImplicitlyMoveConvertibleTuple<_UElements ...>()) && (3ul >= 1)), bool>::type = ]’
/home/allen/miniconda3/envs/pytorch/lib/python3.6/site-packages/torch/include/ATen/core/TensorMethods.h:1181:57: required from here
/usr/include/c++/6/tuple:489:65: error: mismatched argument pack lengths while expanding ‘std::is_convertible<_UElements&&, _Elements>’
return _and<is_convertible<_UElements&&, _Elements>...>::value;
^~~~~
/usr/include/c++/6/tuple:490:1: error: body of constexpr function ‘static constexpr bool std::_TC<, _Elements>::_ImplicitlyMoveConvertibleTuple() [with _UElements = {std::tuple<at::Tensor, at::Tensor, at::Tensor>}; bool = true; _Elements = {at::Tensor, at::Tensor, at::Tensor}]’ not a return-statement
}
^

Environment,
Cuda: 9.0
Cudnn: 7.0.5

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

thank you for your code. could you tell me what the mean of this code:
cd awesome-semantic-segmentation-pytorch/core/nn
python setup.py build develop.
and the error is occur when i run it, could you help me how to solve it?

~/awesome-semantic-segmentation-pytorch/core/nn$ python setup.py build develop
1111 /home/wx/awesome-semantic-segmentation-pytorch/core/nn
running build
running build_ext
building '._C' extension
creating build/temp.linux-x86_64-3.5/home/wx/awesome-semantic-segmentation-pytorch
creating build/temp.linux-x86_64-3.5/home/wx/awesome-semantic-segmentation-pytorch/core
creating build/temp.linux-x86_64-3.5/home/wx/awesome-semantic-segmentation-pytorch/core/nn
creating build/temp.linux-x86_64-3.5/home/wx/awesome-semantic-segmentation-pytorch/core/nn/csrc
creating build/temp.linux-x86_64-3.5/home/wx/awesome-semantic-segmentation-pytorch/core/nn/csrc/cpu
creating build/temp.linux-x86_64-3.5/home/wx/awesome-semantic-segmentation-pytorch/core/nn/csrc/cuda
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DWITH_CUDA -I/home/wx/awesome-semantic-segmentation-pytorch/core/nn/csrc -I/usr/local/lib/python3.5/dist-packages/torch/lib/include -I/usr/local/lib/python3.5/dist-packages/torch/lib/include/TH -I/usr/local/lib/python3.5/dist-packages/torch/lib/include/THC -I/usr/local/cuda-9.0/include -I/usr/include/python3.5m -c /home/wx/awesome-semantic-segmentation-pytorch/core/nn/csrc/vision.cpp -o build/temp.linux-x86_64-3.5/home/wx/awesome-semantic-segmentation-pytorch/core/nn/csrc/vision.o -DTORCH_EXTENSION_NAME=._C -std=c++11
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from /home/wx/awesome-semantic-segmentation-pytorch/core/nn/csrc/ca.h:3:0,
from /home/wx/awesome-semantic-segmentation-pytorch/core/nn/csrc/vision.cpp:1:
/home/wx/awesome-semantic-segmentation-pytorch/core/nn/csrc/cpu/vision.h:2:29: fatal error: torch/extension.h: 没有那个文件或目录
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

question about enet

thanks for the great work!
here I have some question about the enet. I noticed in your code, in the bottleneck block, you didn't use zero paddings to align the main branch to residual branch, instead of using a conv to scratch to the main branch to the same size with the residual branch. It seems a different implementation idea compare to the original paper. May I ask if this modification is intended or?

Question

Thanks for your nice work. I can not figure out 'MixSoftmaxCrossEntropyLoss' in your code, which is the default loss function. Could you explain it for me?

checkpoint models

Hi! During training I find the sizes of the checkpoint models saved in different epochs are the same. Why is that? Does it mean the parameters in the models do not change or do not properly saved?

tests/test_model.py

there is a import error:
from core.nn.loss import MixSoftmaxCrossEntropyLoss, EncNetLoss, ICNetLoss
should be:
from core.utils.loss import MixSoftmaxCrossEntropyLoss, EncNetLoss, ICNetLoss

No module named 'core'

Thx for your work!but I have a problem that when I run demo.py, it retrun that "from core.utils.visualize import get_color_pallete
ModuleNotFoundError: No module named 'core'"
I have no idea about this. Could u fix it?
and when I run train.py, it's OK.

mIou

What is the best performing mIou for these models? I only got 76.7%...

Missing key problem

Hi,thanks for your code. But there are some missing key errors when I try to train danet . I really don't know how to solve it.
47411597-9058-499C-9524-6686DB698D25

error during training

Hi, I follow installation steps to try to run this project.
There are some warnings during the setup phase, but no errors are reported.

But the following errors occur during the training phase:

(awesomeseg) root@ubuntu:/home/ql/pycharm/awesome-semantic-segmentation-pytorch/scripts# python train.py --model fcn32s --backbone vgg16 --dataset pascal_voc --lr 0.0001 --epochs 50
Traceback (most recent call last):
  File "train.py", line 18, in <module>
    from core.data.dataloader import get_segmentation_dataset
  File "/home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/__init__.py", line 1, in <module>
    from . import nn, models, utils, data
  File "/home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn/__init__.py", line 2, in <module>
    from .sync_bn.syncbn import *
  File "/home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn/sync_bn/syncbn.py", line 17, in <module>
    from .functions import *
  File "/home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn/sync_bn/functions.py", line 15, in <module>
    from core.nn.sync_bn import lib
  File "/home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn/sync_bn/lib/__init__.py", line 12, in <module>
    ], build_directory=cpu_path, verbose=False)
  File "/usr/local/anaconda3/envs/awesomeseg/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 645, in load
    is_python_module)
  File "/usr/local/anaconda3/envs/awesomeseg/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 825, in _jit_compile
    return _import_module_from_library(name, build_directory, is_python_module)
  File "/usr/local/anaconda3/envs/awesomeseg/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 968, in _import_module_from_library
    return imp.load_module(module_name, file, path, description)
  File "/usr/local/anaconda3/envs/awesomeseg/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/usr/local/anaconda3/envs/awesomeseg/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: /home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn/sync_bn/lib/cpu/sync_cpu.so: undefined symbol: _ZN3c105ErrorC1ENS_14SourceLocationERKSs
(awesomeseg) root@ubuntu:/home/ql/pycharm/awesome-semantic-segmentation-pytorch/scripts#

The warning for the setup phase is like this:

(awesomeseg) root@ubuntu:/home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn# python setup.py build develop
running build
running build_ext
building '._C' extension
creating build
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/home
creating build/temp.linux-x86_64-3.6/home/ql
creating build/temp.linux-x86_64-3.6/home/ql/pycharm
creating build/temp.linux-x86_64-3.6/home/ql/pycharm/awesome-semantic-segmentation-pytorch
creating build/temp.linux-x86_64-3.6/home/ql/pycharm/awesome-semantic-segmentation-pytorch/core
creating build/temp.linux-x86_64-3.6/home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn
creating build/temp.linux-x86_64-3.6/home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn/csrc
creating build/temp.linux-x86_64-3.6/home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn/csrc/cpu
gcc -pthread -B /usr/local/anaconda3/envs/awesomeseg/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn/csrc -I/usr/local/anaconda3/envs/awesomeseg/lib/python3.6/site-packages/torch/lib/include -I/usr/local/anaconda3/envs/awesomeseg/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include -I/usr/local/anaconda3/envs/awesomeseg/lib/python3.6/site-packages/torch/lib/include/TH -I/usr/local/anaconda3/envs/awesomeseg/lib/python3.6/site-packages/torch/lib/include/THC -I/usr/local/anaconda3/envs/awesomeseg/include/python3.6m -c /home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn/csrc/vision.cpp -o build/temp.linux-x86_64-3.6/home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn/csrc/vision.o -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
gcc -pthread -B /usr/local/anaconda3/envs/awesomeseg/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn/csrc -I/usr/local/anaconda3/envs/awesomeseg/lib/python3.6/site-packages/torch/lib/include -I/usr/local/anaconda3/envs/awesomeseg/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include -I/usr/local/anaconda3/envs/awesomeseg/lib/python3.6/site-packages/torch/lib/include/TH -I/usr/local/anaconda3/envs/awesomeseg/lib/python3.6/site-packages/torch/lib/include/THC -I/usr/local/anaconda3/envs/awesomeseg/include/python3.6m -c /home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn/csrc/cpu/ca_cpu.cpp -o build/temp.linux-x86_64-3.6/home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn/csrc/cpu/ca_cpu.o -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
gcc -pthread -B /usr/local/anaconda3/envs/awesomeseg/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn/csrc -I/usr/local/anaconda3/envs/awesomeseg/lib/python3.6/site-packages/torch/lib/include -I/usr/local/anaconda3/envs/awesomeseg/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include -I/usr/local/anaconda3/envs/awesomeseg/lib/python3.6/site-packages/torch/lib/include/TH -I/usr/local/anaconda3/envs/awesomeseg/lib/python3.6/site-packages/torch/lib/include/THC -I/usr/local/anaconda3/envs/awesomeseg/include/python3.6m -c /home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn/csrc/cpu/psa_cpu.cpp -o build/temp.linux-x86_64-3.6/home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn/csrc/cpu/psa_cpu.o -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
gcc -pthread -B /usr/local/anaconda3/envs/awesomeseg/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn/csrc -I/usr/local/anaconda3/envs/awesomeseg/lib/python3.6/site-packages/torch/lib/include -I/usr/local/anaconda3/envs/awesomeseg/lib/python3.6/site-packages/torch/lib/include/torch/csrc/api/include -I/usr/local/anaconda3/envs/awesomeseg/lib/python3.6/site-packages/torch/lib/include/TH -I/usr/local/anaconda3/envs/awesomeseg/lib/python3.6/site-packages/torch/lib/include/THC -I/usr/local/anaconda3/envs/awesomeseg/include/python3.6m -c /home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn/csrc/cpu/syncbn_cpu.cpp -o build/temp.linux-x86_64-3.6/home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn/csrc/cpu/syncbn_cpu.o -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
creating build/lib.linux-x86_64-3.6
g++ -pthread -shared -B /usr/local/anaconda3/envs/awesomeseg/compiler_compat -L/usr/local/anaconda3/envs/awesomeseg/lib -Wl,-rpath=/usr/local/anaconda3/envs/awesomeseg/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-3.6/home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn/csrc/vision.o build/temp.linux-x86_64-3.6/home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn/csrc/cpu/ca_cpu.o build/temp.linux-x86_64-3.6/home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn/csrc/cpu/psa_cpu.o build/temp.linux-x86_64-3.6/home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn/csrc/cpu/syncbn_cpu.o -o build/lib.linux-x86_64-3.6/_C.cpython-36m-x86_64-linux-gnu.so
running develop
running egg_info
creating semantic_segmentation.egg-info
writing semantic_segmentation.egg-info/PKG-INFO
writing dependency_links to semantic_segmentation.egg-info/dependency_links.txt
writing top-level names to semantic_segmentation.egg-info/top_level.txt
writing manifest file 'semantic_segmentation.egg-info/SOURCES.txt'
reading manifest file 'semantic_segmentation.egg-info/SOURCES.txt'
writing manifest file 'semantic_segmentation.egg-info/SOURCES.txt'
running build_ext
copying build/lib.linux-x86_64-3.6/_C.cpython-36m-x86_64-linux-gnu.so ->
Creating /usr/local/anaconda3/envs/awesomeseg/lib/python3.6/site-packages/semantic-segmentation.egg-link (link to .)
Adding semantic-segmentation 0.1 to easy-install.pth file

Installed /home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn
Processing dependencies for semantic-segmentation==0.1
Finished processing dependencies for semantic-segmentation==0.1
(awesomeseg) root@ubuntu:/home/ql/pycharm/awesome-semantic-segmentation-pytorch/core/nn# 


I don't know if setup's warning problem caused the error in the training phase.
How should I solve the mistakes in the training phase?
Thank you

About results

Please tell us the hyperparameters of the result.
It is the number of epoch.

TypeError

@Tramac
Thank you for your help!

I try to train pspnet with auxiliary loss as in the paper, the args are as follows:

Namespace(aux=True, aux_weight=0.4, backbone='resnet50', base_size=520, batch_size=2, crop_size=480, dataset='pascal_voc', device=device(type='cuda', index=0), epochs=10, eval=False, lr=0.01, model='psp', momentum=0.9, no_val=True, resume=None, save_folder='./ckptmodels', start_epoch=0, train_split='train', weight_decay=0.0001)

And I get this error:

Traceback (most recent call last):
File "train.py", line 210, in
trainer = Trainer(args)
File "train.py", line 118, in init
aux=args.aux, crop_size=args.crop_size)
File "D:\PyTorch\Awesome-semantic-segmentation-pytorch-master\models\model_zoo.py", line 63, in get_segmentation_model
return modelsmodel
File "D:\PyTorch\Awesome-semantic-segmentation-pytorch-master\models\pspnet.py", line 138, in get_psp
model = PSPNet(datasets[dataset].NUM_CLASS, backbone=backbone, pretrained_base=pretrained_base, **kwargs)
File "D:\PyTorch\Awesome-semantic-segmentation-pytorch-master\models\pspnet.py", line 41, in init
self.auxlayer = _FCNHead(1024, nclass, **kwargs)
TypeError: init() missing 1 required positional argument: 'norm_layer'

Could you please help me? Thank you very much!

multi-GPU Questions

Hi, I want try a big batch_size so I need to multi-gpu, and I use the code about multi-gpu in train.py
, But I found a problem in paraller.py

core/utils/parallel.py", line 136, in _worker
output = module(*(list(input) + target), **kwargs)
TypeError: can only concatenate list (not "tuple") to list

and I found some solutions in your References ,
link: zhanghang1989/PyTorch-Encoding#116
but still some mistakes in validation
outputs = self.model(image)
And I use denseaspp model to train the data, And Could you give me some ideas about that. Thank you

Show more results

I hope you show more results, some new networks, such as icnet, bisenet, and the comparison with the results of the paper.

ImportError: No module named 'utils

hello, I run it on pytorch1.0.1 python3.5, but it has some problem with import models. when I run python ade20k.py --download-dir ./datasets/ade, I got "ImportError: No module named 'utils'"
How should I solve it? Thank you.

How should I set one particular GPU in your train.py code?

Hello, thanks for your great job!
I came up a problem when I try to set GPU in single GPU training. I can not figure out how you set
up the GPU through the arguments. For example, I have four GPUs in my server, I only want to use the second GPU,how should I set the arguments or change some codes in your train.py code?

error when running multi-gpu

I have run this program with one GPU sucessfully.
But failed in running multi-GPU, the log as follow:
I hope you could give me a favor, Thank you so much!

RuntimeError: Expected to have finished reduction in the prior iteration before starting a new one. This error indicates that your modul$
has parameters that were not used in producing its output (the return value of forward). You can enable unused parameter detection by
passing the keyword argument find_unused_parameters=True to torch.nn.parallel.DistributedDataParallel. If you already have this argu$
ent set, then the distributed data parallel module wasn't able to locate the output tensors in the return value of your module's forwar$ function. Please include the structure of the return value of forward of your module when reporting this issue (e.g. list, dict, ite$
able). (prepare_for_backward at /opt/conda/conda-bld/pytorch_1556653114079/work/torch/csrc/distributed/c10d/reducer.cpp:408)
frame #0: c10::Error::Error(c10::SourceLocation, std::string const&) + 0x45 (0x7f91725b4dc5 in /home/maobinjie/anaconda3/lib/python3.7/s$
te-packages/torch/lib/libc10.so)
frame #1: c10d::Reducer::prepare_for_backward(std::vector<torch::autograd::Variable, std::allocatortorch::autograd::Variable > const&)

  • 0x5ff (0x7f91a1b66bbf in /home/maobinjie/anaconda3/lib/python3.7/site-packages/torch/lib/libtorch_python.so)
    frame #2: + 0x6cb6c8 (0x7f91a1b5c6c8 in /home/maobinjie/anaconda3/lib/python3.7/site-packages/torch/lib/libtorch_pyth$
    n.so)
    frame #3: + 0x12d07a (0x7f91a15be07a in /home/maobinjie/anaconda3/lib/python3.7/site-packages/torch/lib/libtorch_pyth$
    n.so)

Validation pixAcc: 1.000, mIoU: 0.500

image
hi,thank you for your code,now I want to train my own data by pspnet。 this is my first time
to use pythorch, and I have added my own data.py in dataloader file. I don't know why pa is always 1.00 and miou is 0.5. Could you give me a hand? thank you very much.

about the INFO: mIoU

hello, I am wondering whether the mIoU in the logs file is about the whole eval dataset ,or it is just for one image. I want to know the whole dataset's mIoU , is the last mIoU value in the log what i want?
2019-07-29 20:52:15,674 semantic_segmentation INFO: Sample: 32, validation pixAcc: 68.658, mIoU: 28.800
2019-07-29 20:52:16,336 semantic_segmentation INFO: Sample: 33, validation pixAcc: 68.401, mIoU: 28.734
2019-07-29 20:52:17,001 semantic_segmentation INFO: Sample: 34, validation pixAcc: 68.754, mIoU: 28.657
2019-07-29 20:52:17,642 semantic_segmentation INFO: Sample: 35, validation pixAcc: 68.950, mIoU: 29.016
2019-07-29 20:52:18,285 semantic_segmentation INFO: Sample: 36, validation pixAcc: 68.805, mIoU: 28.987
2019-07-29 20:52:18,930 semantic_segmentation INFO: Sample: 37, validation pixAcc: 68.164, mIoU: 28.776
2019-07-29 20:52:19,568 semantic_segmentation INFO: Sample: 38, validation pixAcc: 67.401, mIoU: 28.977
2019-07-29 20:52:20,208 semantic_segmentation INFO: Sample: 39, validation pixAcc: 66.919, mIoU: 28.799
2019-07-29 20:52:20,858 semantic_segmentation INFO: Sample: 40, validation pixAcc: 67.337, mIoU: 28.945

about train dfanet error

when i trian dfanet :
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [4, 8, 128, 256]], which is output 0 of ReluBackward1, is at version 2; expected version 1 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).

Question

It has been confirmed that the learning is well done at 99% to 100% even in the alternative estimation.
Performance is also the same as Caffe and Tensorflow.
Then I want to know why it didn't work before.
What did you improve?

train error

python train.py

Traceback (most recent call last):
File "train.py", line 177, in
trainer.train()
File "train.py", line 147, in train
if not args.Namespace:
AttributeError: 'Namespace' object has no attribute 'Namespace'
&&&&&
pascal_voc.py

from utils import makedirs

cannot import name makedirs

undefined symbol: _Z23LeakyRelu_Backward_CUDAN2at6TensorES0_f

it occurs this error when I run train.py

Traceback (most recent call last):
File "scripts/train.py", line 17, in
from core.data.dataloader import get_segmentation_dataset
File "/mnt/v-yuxzho/code/awesome-semantic-segmentation-pytorch-master/core/init.py", line 1, in
from . import nn, models, utils, data
File "/mnt/v-yuxzho/code/awesome-semantic-segmentation-pytorch-master/core/nn/init.py", line 2, in
from .sync_bn.syncbn import *
File "/mnt/v-yuxzho/code/awesome-semantic-segmentation-pytorch-master/core/nn/sync_bn/syncbn.py", line 17, in
from .functions import *
File "/mnt/v-yuxzho/code/awesome-semantic-segmentation-pytorch-master/core/nn/sync_bn/functions.py", line 15, in
from core.nn.sync_bn import lib
File "/mnt/v-yuxzho/code/awesome-semantic-segmentation-pytorch-master/core/nn/sync_bn/lib/init.py", line 19, in
build_directory=gpu_path, verbose=False)
File "/mnt/yueshangGu/Apps/anaconda3/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 645, in load
is_python_module)
File "/mnt/yueshangGu/Apps/anaconda3/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 825, in _jit_compile
return _import_module_from_library(name, build_directory, is_python_module)
File "/mnt/yueshangGu/Apps/anaconda3/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 968, in _import_module_from_library
return imp.load_module(module_name, file, path, description)
File "/mnt/yueshangGu/Apps/anaconda3/lib/python3.7/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/mnt/yueshangGu/Apps/anaconda3/lib/python3.7/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /mnt/v-yuxzho/code/awesome-semantic-segmentation-pytorch-master/core/nn/sync_bn/lib/gpu/sync_gpu.so: undefined symbol: _Z23LeakyRelu_Backward_CUDAN2at6TensorES0_f

error when running demo.py with pascal voc 2012

python3 ex_demo.py --model fcn32s_vgg16_voc
Traceback (most recent call last):
File "ex_demo.py", line 12, in
from core.utils.visualize import get_color_pallete
File "/home/ubuntu/suliang_git/awesome-semantic-segmentation-pytorch/core/init.py", line 1, in
from . import nn, models, utils, data
File "/home/ubuntu/suliang_git/awesome-semantic-segmentation-pytorch/core/nn/init.py", line 4, in
from .ca_block import *
File "/home/ubuntu/suliang_git/awesome-semantic-segmentation-pytorch/core/nn/ca_block.py", line 6, in
from core.nn import _C
ImportError: /home/ubuntu/suliang_git/awesome-semantic-segmentation-pytorch/core/nn/_C.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN3c105ErrorC1ENS_14SourceLocationERKSs

hello, when i run demo.py, above error occured. seems related to compile, but i have run the setup.py successfully. my pytorch version is 1.01, cuda9.0, could you suggest what can i do next to fix it?

thanks

About DFAnet

Did u test the inference speed of DFAnet? The result of my test by mxnet is over 40ms for one image(size:1024*1024), which is far away from the speed reported in the paper. And it's really hard to train DFAnet. The best mIOU I got is close to 50% on Cityscape....

ImportError: cannot import name '_C'

When i try to run demo.py in windows 10 pytorch 1.1stable cuda10
C:\Users\123\Anaconda3\python.exe E:/awesome-semantic-segmentation-pytorch-master/awesome-semantic-segmentation-pytorch-master/scripts/demo.py
Traceback (most recent call last):
File "E:/awesome-semantic-segmentation-pytorch-master/awesome-semantic-segmentation-pytorch-master/scripts/demo.py", line 12, in
from core.utils.visualize import get_color_pallete
File "E:\awesome-semantic-segmentation-pytorch-master\awesome-semantic-segmentation-pytorch-master\core_init_.py", line 1, in
from . import nn, models, utils, data
File "E:\awesome-semantic-segmentation-pytorch-master\awesome-semantic-segmentation-pytorch-master\core\nn_init_.py", line 4, in
from .ca_block import *
File "E:\awesome-semantic-segmentation-pytorch-master\awesome-semantic-segmentation-pytorch-master\core\nn\ca_block.py", line 6, in
from core.nn import _C
ImportError: cannot import name '_C'

Process finished with exit code 1

core/nn build error

Hi, I follow installation steps to try to run this project. At the third step, i got errors when building core/nn lib with symbolic links.

The error info:

/home/tanmengwen/awesome-semantic-segmentation-pytorch/core/nn/csrc/syncbn.h:112:108: error: too few arguments to function ‘at::Tensor inp_expectation_backward_cuda(at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, at::Tensor, float)’
       return inp_expectation_backward_cuda(gradInput_, output_, gradEx_, gradExs_, ex_, exs_, gamma_, beta_);

/home/tanmengwen/awesome-semantic-segmentation-pytorch/core/nn/csrc/syncbn.h:137:46: error: could not convert ‘slope’ from ‘float’ to ‘at::Tensor’
       return leakyrelu_backward_cuda(z, slope);

As the error info, it just some small bugs because of the wrong inputs so I fix it as follows:

https://github.com/Tramac/awesome-semantic-segmentation-pytorch/blob/master/core/nn/csrc/syncbn.h#L112
return inp_expectation_backward_cuda(gradInput_, output_, gradEx_, gradExs_, ex_, exs_, gamma_, beta_, eps);

https://github.com/Tramac/awesome-semantic-segmentation-pytorch/blob/master/core/nn/csrc/syncbn.h#L137
return leakyrelu_backward_cuda(z, dz, slope);

Then I built again and got many strange errors:

/usr/local/cuda/include/thrust/system/cuda/detail/transform.h(331): here
            instantiation of "OutputIt thrust::cuda_cub::transform_if(thrust::cuda_cub::execution_policy<Derived> &, InputIt, InputIt, OutputIt, TransformOp, Predicate) [with Derived=thrust::cuda_cub::tag, InputIt=thrust::device_ptr<float>, OutputIt=thrust::device_ptr<float>, TransformOp=lambda [](const float &)->float, Predicate=lambda [](const float &)->__nv_bool]" 
/usr/local/cuda/include/thrust/detail/transform.inl(80): here
            instantiation of "ForwardIterator thrust::transform_if(const thrust::detail::execution_policy_base<DerivedPolicy> &, InputIterator, InputIterator, ForwardIterator, UnaryFunction, Predicate) [with DerivedPolicy=thrust::cuda_cub::tag, InputIterator=thrust::device_ptr<float>, ForwardIterator=thrust::device_ptr<float>, UnaryFunction=lambda [](const float &)->float, Predicate=lambda [](const float &)->__nv_bool]" 
/usr/local/cuda/include/thrust/detail/transform.inl(188): here
            instantiation of "ForwardIterator thrust::transform_if(InputIterator, InputIterator, ForwardIterator, UnaryFunction, Predicate) [with InputIterator=thrust::device_ptr<float>, ForwardIterator=thrust::device_ptr<float>, UnaryFunction=lambda [](const float &)->float, Predicate=lambda [](const float &)->__nv_bool]" 
/home/tanmengwen/awesome-semantic-segmentation-pytorch/core/nn/csrc/cuda/syncbn_cuda.cu(276): here
            instantiation of "void <unnamed>::leaky_relu_backward_impl(T *, T *, float, int64_t) [with T=float]" 
/home/tanmengwen/awesome-semantic-segmentation-pytorch/core/nn/csrc/cuda/syncbn_cuda.cu(516): here

20 errors detected in the compilation of "/tmp/tmpxft_000018cc_00000000-6_syncbn_cuda.cpp1.ii".

I think my conda env is clean, because I did maskrcnn-benchmark's step-by-step installation. https://github.com/facebookresearch/maskrcnn-benchmark/blob/master/INSTALL.md
And I build maskrcnn-benchmark successful.

Could you give me some advices to run your projects ?
Thank you very much for your good jobs.

TypeError: forward() takes 3 positional arguments but 4 were given

Hi, @Tramac :
I use command as follow:

CUDA_VISIBLE_DEVICES=4,5,6,7 python train.py --model psp --backbone resnet50 --dataset coco

then i got error

loading annotations into memory...
Done (t=2.22s)
creating index...
index created!
Starting Epoch: 0, Total Epochs: 60
Traceback (most recent call last):
  File "train.py", line 248, in <module>
    trainer.train()
  File "train.py", line 183, in train
    loss = self.criterion(outputs, targets)
  File "/home/luqi/anaconda3/envs/pytorch-1.0/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)
  File "/data/luqi/guojin/codes/awesome-semantic-segmentation-pytorch/core/utils/parallel.py", line 81, in forward
    outputs = criterion_parallel_apply(replicas, inputs, targets, kwargs)
  File "/data/luqi/guojin/codes/awesome-semantic-segmentation-pytorch/core/utils/parallel.py", line 163, in criterion_parallel_apply
    raise output
  File "/data/luqi/guojin/codes/awesome-semantic-segmentation-pytorch/core/utils/parallel.py", line 139, in _worker
    output = module(*(list(input) + [target]), **kwargs)
  File "/home/luqi/anaconda3/envs/pytorch-1.0/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)
  File "/data/luqi/guojin/codes/awesome-semantic-segmentation-pytorch/core/nn/loss.py", line 32, in forward
    return super(MixSoftmaxCrossEntropyLoss, self).forward(*inputs)
TypeError: forward() takes 3 positional arguments but 4 were given

I dont quite understand what it means. Can you help me?

run demo.py RuntimeError: invalid argument 6:

thanks for your help I just finished training and got the psanet model,then I just wanna run demo.py an error occurred ,can you help me to fix it again ,by the way os:win10 cuda10 pytorch1.1
C:\Users\123\Anaconda3\python.exe E:/awesome-semantic-segmentation-pytorch-master/awesome-semantic-segmentation-pytorch-master/scripts/demo.py
C:\Users\123/.torch/models\psanet_resnet50_pascal_voc.pth
Finished loading model!
Traceback (most recent call last):
File "E:/awesome-semantic-segmentation-pytorch-master/awesome-semantic-segmentation-pytorch-master/scripts/demo.py", line 58, in
demo(args)
File "E:/awesome-semantic-segmentation-pytorch-master/awesome-semantic-segmentation-pytorch-master/scripts/demo.py", line 49, in demo
output = model(images)
File "C:\Users\123\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "E:\awesome-semantic-segmentation-pytorch-master\awesome-semantic-segmentation-pytorch-master\core\models\psanet.py", line 48, in forward
x = self.head(c4)
File "C:\Users\123\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "E:\awesome-semantic-segmentation-pytorch-master\awesome-semantic-segmentation-pytorch-master\core\models\psanet.py", line 72, in forward
global_feature = self.psa(x)
File "C:\Users\123\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "E:\awesome-semantic-segmentation-pytorch-master\awesome-semantic-segmentation-pytorch-master\core\models\psanet.py", line 88, in forward
collect_fm = self.collect_attention(x)
File "C:\Users\123\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "E:\awesome-semantic-segmentation-pytorch-master\awesome-semantic-segmentation-pytorch-master\core\models\psanet.py", line 110, in forward
fm = torch.bmm(reduce_x, torch.softmax(attention, dim=1))
RuntimeError: invalid argument 6: wrong matrix size at C:/w/1/s/windows/pytorch/aten/src\THC/generic/THCTensorMathBlas.cu:494

Process finished with exit code 1

how to change the 'root' path about pretrained models

when i run train.py or demo.py, it always shows
'Model file /root/.torch/models/resnet50-25c4b509.pth is not found. Downloading
Downloading /root/.torch/models/resnet50-25c4b509.zip from https://hangzh.s3.amazonaws.com/encoding/models/resnet50-25c4b509.zip... '

i have downloaded the .pth and saved it in other path, how can i change the loading path from '/root/.torch/models' to a specify path.

i tried to modify 'root= ' in the function of 'get_models' or 'get_segmentation_model' ,but it didn't work, so how can i do next, thx!

python setup.py error

python setup.py build develop(pytorch ==1.1.0)

2 errors detected in the compilation of "/tmp/tmpxft_000015ae_00000000-7_psa_cuda.cpp1.ii".
error: command '/usr/local/cuda/bin/nvcc' failed with exit status 2

I can not setup.
I saw ”error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 #21” but I could not solve it

ModuleNotFoundError

@Tramac

Hello, Thank you for your wonderful work!

I run your code in Windows and I encounter this error:

Traceback (most recent call last):
File "train.py", line 11, in
from models.model_zoo import get_segmentation_model
File "D:\PyTorch\Awesome-semantic-segmentation-pytorch-master\models_init_.py", line 2, in
from .model_zoo import get_model, get_model_list
File "D:\PyTorch\Awesome-semantic-segmentation-pytorch-master\models\model_zoo.py", line 2, in
from .fcn import *
File "D:\PyTorch\Awesome-semantic-segmentation-pytorch-master\models\fcn.py", line 7, in
from models.utils import weights_init
ModuleNotFoundError: No module named 'models.utils'

Could you please help me? Thanks a lot!

The question

(The code is up to date.)
1.Is the loss small enough? (It is diverging during during this time->Loss: 2.0000~0.0200)
There is no change at all in accuracy in epoch 1, 10,100 or 1000.
I feel that processing is done with the weight of VGG16.
Is there a problem with running the python3 code with python2?

2.train.py
utils->loss.py
def _aux_forward(self, *inputs, **kwargs):
*preds, target = tuple(inputs)<-----error *preds

Is this okay with pred?
def _aux_forward(self, *inputs, **kwargs):
preds, target = tuple(inputs)

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.