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

Regarding the issue of not being able to run the code. #19

Open
9527950 opened this issue Jun 19, 2023 · 7 comments
Open

Regarding the issue of not being able to run the code. #19

9527950 opened this issue Jun 19, 2023 · 7 comments

Comments

@9527950
Copy link

9527950 commented Jun 19, 2023

(1)I have installed mmcv=1.4.1 and mmcv-full=1.4.0 versions, but I still encounter errors. I have tried multiple versions, but the errors persist. I would like to ask you about the specific version you have installed.
"
ext_module = ext_loader.load_ext(
File "/root/miniconda3/envs/YHG/lib/python3.8/site-packages/mmcv/utils/ext_loader.py", line 13, in load_ext
ext = importlib.import_module('mmcv.' + name)
File "/root/miniconda3/envs/YHG/lib/python3.8/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: libtorch_cuda_cu.so: cannot open shared object file: No such file or directory
"
(2)In the seaFormer/mmseg/models directory, I cannot find the file that corresponds to the overall network depicted in Figure 2 of the paper.
(3)Additionally, I may need to upscale the segmentation results, which are 1/8 of the original size, back to the original size. How should I handle this?

@wwqq
Copy link
Collaborator

wwqq commented Jun 19, 2023

@9527950
Copy link
Author

9527950 commented Jun 19, 2023

Where is the instantiation of the entire network implemented in the code? I couldn't find the specific instantiation operation in the build function.

@wwqq
Copy link
Collaborator

wwqq commented Jun 19, 2023

build model:

model = build_segmentor(

def build_segmentor(cfg, train_cfg=None, test_cfg=None):

return SEGMENTORS.build(

model type config:

class EncoderDecoder:
class EncoderDecoder(BaseSegmentor):

build backbone:
self.backbone = builder.build_backbone(backbone)

build head:
self.decode_head = builder.build_head(decode_head)

@9527950
Copy link
Author

9527950 commented Jun 19, 2023

I'm sorry for the confusion. Could you please provide me with a brief explanation of the build process here? Additionally, does the Encoder-Decoder file combine the backbone and the decode_head together? Thank you very much.


import warnings
from mmcv.cnn import MODELS as MMCV_MODELS
from mmcv.cnn.bricks.registry import ATTENTION as MMCV_ATTENTION
from mmcv.utils import Registry

MODELS = Registry('models', parent=MMCV_MODELS)
ATTENTION = Registry('attention', parent=MMCV_ATTENTION)

BACKBONES = MODELS
NECKS = MODELS
HEADS = MODELS
LOSSES = MODELS
SEGMENTORS = MODELS

def build_segmentor(cfg, train_cfg=None, test_cfg=None):
"""Build segmentor."""
if train_cfg is not None or test_cfg is not None:
warnings.warn(
'train_cfg and test_cfg is deprecated, '
'please specify them in model', UserWarning)
assert cfg.get('train_cfg') is None or train_cfg is None,
'train_cfg specified in both outer field and model field '
assert cfg.get('test_cfg') is None or test_cfg is None,
'test_cfg specified in both outer field and model field '
return SEGMENTORS.build(
cfg, default_args=dict(train_cfg=train_cfg, test_cfg=test_cfg))

@Katono5
Copy link

Katono5 commented Aug 16, 2023

build model:

model = build_segmentor(

def build_segmentor(cfg, train_cfg=None, test_cfg=None):

return SEGMENTORS.build(

model type config:

class EncoderDecoder:

class EncoderDecoder(BaseSegmentor):

build backbone:

self.backbone = builder.build_backbone(backbone)

build head:

self.decode_head = builder.build_head(decode_head)

I've tried running this code but it returns:
2023-08-16 22:02:45,352 - mmseg - INFO - Set random seed to 1704611828, deterministic: False
Traceback (most recent call last):
File "E:\Miniconda\envs\sea\lib\site-packages\mmcv\utils\registry.py", line 52, in build_from_cfg
return obj_cls(**args)
File "E:\Miniconda\envs\sea\lib\site-packages\mmseg\models\segmentors\encoder_decoder.py", line 36, in init
self.backbone = builder.build_backbone(backbone)
File "E:\Miniconda\envs\sea\lib\site-packages\mmseg\models\builder.py", line 20, in build_backbone
return BACKBONES.build(cfg)
File "E:\Miniconda\envs\sea\lib\site-packages\mmcv\utils\registry.py", line 212, in build
return self.build_func(*args, **kwargs, registry=self)
File "E:\Miniconda\envs\sea\lib\site-packages\mmcv\cnn\builder.py", line 27, in build_model_from_cfg
return build_from_cfg(cfg, registry, default_args)
File "E:\Miniconda\envs\sea\lib\site-packages\mmcv\utils\registry.py", line 44, in build_from_cfg
raise KeyError(
KeyError: 'SeaFormer is not in the models registry'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "tools/train.py", line 182, in <module>
    main()
  File "tools/train.py", line 137, in main
    model = build_segmentor(
  File "E:\Miniconda\envs\sea\lib\site-packages\mmseg\models\builder.py", line 48, in build_segmentor
    return SEGMENTORS.build(
  File "E:\Miniconda\envs\sea\lib\site-packages\mmcv\utils\registry.py", line 212, in build
    return self.build_func(*args, **kwargs, registry=self)
  File "E:\Miniconda\envs\sea\lib\site-packages\mmcv\cnn\builder.py", line 27, in build_model_from_cfg
    return build_from_cfg(cfg, registry, default_args)
  File "E:\Miniconda\envs\sea\lib\site-packages\mmcv\utils\registry.py", line 55, in build_from_cfg
    raise type(e)(f'{obj_cls.__name__}: {e}')
KeyError: "EncoderDecoder: 'SeaFormer is not in the models registry'"

I wanna know why this eccors since SeaFormer should have been registerd into backbone, have you ever got this error before cuz I didn't change a line of code so far.

my environment:
pytorch==1.9.1
cuda==11.1
mmcv-full==1.3.16
mmsegmentation==0.25.0

@9527950
Copy link
Author

9527950 commented Aug 16, 2023 via email

@Katono5
Copy link

Katono5 commented Aug 16, 2023

I'm not sure how this error was caused, but I deleted many unnecessary modules, and now it can run successfully. 笛卡尔式的梦 @.*** Original Email Sender:"Katono"< @.*** >; Sent Time:2023/8/16 22:08 To:"fudan-zvg/SeaFormer"< @.*** >; Cc recipient:"9527950"< @.*** >;"Mention"< @.*** >; Subject:Re: [fudan-zvg/SeaFormer] Regarding the issue of not being able torun the code. (Issue #19) build model:

model = build_segmentor(
def build_segmentor(cfg, train_cfg=None, test_cfg=None):
return SEGMENTORS.build(
model type config: class EncoderDecoder:
class EncoderDecoder(BaseSegmentor):
build backbone:
self.backbone = builder.build_backbone(backbone)
build head:
self.decode_head = builder.build_head(decode_head)
I've tried running this code but it returns: 2023-08-16 22:02:45,352 - mmseg - INFO - Set random seed to 1704611828, deterministic: False Traceback (most recent call last): File "E:\Miniconda\envs\sea\lib\site-packages\mmcv\utils\registry.py", line 52, in build_from_cfg return obj_cls(**args) File "E:\Miniconda\envs\sea\lib\site-packages\mmseg\models\segmentors\encoder_decoder.py", line 36, in init self.backbone = builder.build_backbone(backbone) File "E:\Miniconda\envs\sea\lib\site-packages\mmseg\models\builder.py", line 20, in build_backbone return BACKBONES.build(cfg) File "E:\Miniconda\envs\sea\lib\site-packages\mmcv\utils\registry.py", line 212, in build return self.build_func(*args, **kwargs, registry=self) File "E:\Miniconda\envs\sea\lib\site-packages\mmcv\cnn\builder.py", line 27, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "E:\Miniconda\envs\sea\lib\site-packages\mmcv\utils\registry.py", line 44, in build_from_cfg raise KeyError( KeyError: 'SeaFormer is not in the models registry' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "tools/train.py", line 182, in <module> main() File "tools/train.py", line 137, in main model = build_segmentor( File "E:\Miniconda\envs\sea\lib\site-packages\mmseg\models\builder.py", line 48, in build_segmentor return SEGMENTORS.build( File "E:\Miniconda\envs\sea\lib\site-packages\mmcv\utils\registry.py", line 212, in build return self.build_func(args, kwargs, registry=self) File "E:\Miniconda\envs\sea\lib\site-packages\mmcv\cnn\builder.py", line 27, in build_model_from_cfg return build_from_cfg(cfg, registry, default_args) File "E:\Miniconda\envs\sea\lib\site-packages\mmcv\utils\registry.py", line 55, in build_from_cfg raise type(e)(f'{obj_cls.name}: {e}') KeyError: "EncoderDecoder: 'SeaFormer is not in the models registry'" I wanna know why this eccors since SeaFormer should have been registerd into backbone, have you ever got this error before cuz I didn't change a line of code so far. my environment: pytorch==1.9.1 cuda==11.1 mmcv-full==1.3.16 mmsegmentation==1.0.0 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.>

Just reproduced this error on my linux computer, I follow the readme step by step only one different step: I directly use python tools/train.py instead of using the dist_train.sh since I only have one gpu, would that be the cause of the problem? If so how can I not using distribute train when using the .sh file.

Thx for replying tho, I would be really grateful if you could generously gimme a help. Appreciate your work!

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

3 participants