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

Running Spacenet Vegas Semantic Segmentation Example #1427

Closed
yashgharat opened this issue Jun 27, 2022 · 5 comments · Fixed by #1436
Closed

Running Spacenet Vegas Semantic Segmentation Example #1427

yashgharat opened this issue Jun 27, 2022 · 5 comments · Fixed by #1436
Labels

Comments

@yashgharat
Copy link

🐛 Bug

So when I follow the instructions and have a local copy of the spacenet vegas folder, I get the error:

root@cca5d668d324:/opt/src# rastervision run local code/spacenet_vegas.py -a raw_uri $RAW_URI -a root_uri $ROOT_URI
Traceback (most recent call last):
  File "/opt/conda/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/opt/conda/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/opt/src/rastervision_pipeline/rastervision/pipeline/cli.py", line 250, in <module>
    _main()
  File "/opt/src/rastervision_pipeline/rastervision/pipeline/cli.py", line 246, in _main
    main()
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/opt/src/rastervision_pipeline/rastervision/pipeline/cli.py", line 170, in run
    cfgs = get_configs(cfg_module, runner, args)
  File "/opt/src/rastervision_pipeline/rastervision/pipeline/cli.py", line 74, in get_configs
    cfgs = _get_configs(runner, **args)
  File "code/spacenet_vegas.py", line 229, in get_config
    chip_options=chip_options
  File "pydantic/main.py", line 331, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for SemanticSegmentationConfig
img_format
  extra fields not permitted (type=value_error.extra)

This references the img_format option on line 227 although it mentions line 228. However, I notice that the tiny_spacenet example and the actual SemanticSegmentationConfig Class say those two params are optional. so when removing it to test, I end with another error.

root@cca5d668d324:/opt/src# rastervision run local code/spacenet_vegas.py -a raw_uri $RAW_URI -a root_uri $ROOT_URI
Traceback (most recent call last):
  File "/opt/conda/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/opt/conda/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/opt/src/rastervision_pipeline/rastervision/pipeline/cli.py", line 250, in <module>
    _main()
  File "/opt/src/rastervision_pipeline/rastervision/pipeline/cli.py", line 246, in _main
    main()
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/opt/src/rastervision_pipeline/rastervision/pipeline/cli.py", line 175, in run
    pipeline_run_name)
  File "/opt/src/rastervision_pipeline/rastervision/pipeline/cli.py", line 117, in _run_pipeline
    build_config(cfg.dict())
  File "/opt/src/rastervision_pipeline/rastervision/pipeline/config.py", line 163, in build_config
    new_x[k] = build_config(v)
  File "/opt/src/rastervision_pipeline/rastervision/pipeline/config.py", line 163, in build_config
    new_x[k] = build_config(v)
  File "/opt/src/rastervision_pipeline/rastervision/pipeline/config.py", line 167, in build_config
    new_x = config_cls(**new_x)
  File "pydantic/main.py", line 331, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for SemanticSegmentationGeoDataConfig
__root__
  len(class_colors) != len(class_names) (type=value_error.config)

I also agree that these above errors are from pulling the master directly. However, when I run the 0.13 branch, I still get an error that says

Traceback (most recent call last):
  File "/opt/conda/lib/python3.6/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/opt/conda/lib/python3.6/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/opt/src/rastervision_pipeline/rastervision/pipeline/__init__.py", line 19, in <module>
    registry.load_plugins()
  File "/opt/src/rastervision_pipeline/rastervision/pipeline/registry.py", line 238, in load_plugins
    for finder, name, ispkg in iter_namespace(rastervision)
  File "/opt/src/rastervision_pipeline/rastervision/pipeline/registry.py", line 238, in <dictcomp>
    for finder, name, ispkg in iter_namespace(rastervision)
  File "/opt/conda/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/opt/src/rastervision_pytorch_backend/rastervision/pytorch_backend/__init__.py", line 4, in <module>
    from rastervision.pytorch_backend.pytorch_chip_classification_config import *
  File "/opt/src/rastervision_pytorch_backend/rastervision/pytorch_backend/pytorch_chip_classification_config.py", line 2, in <module>
    from rastervision.pytorch_backend.pytorch_learner_backend_config import (
  File "/opt/src/rastervision_pytorch_backend/rastervision/pytorch_backend/pytorch_learner_backend_config.py", line 6, in <module>
    from rastervision.pytorch_learner.learner_config import (
  File "/opt/src/rastervision_pytorch_learner/rastervision/pytorch_learner/__init__.py", line 4, in <module>
    from rastervision.pytorch_learner.learner_config import *
  File "/opt/src/rastervision_pytorch_learner/rastervision/pytorch_learner/learner_config.py", line 11, in <module>
    import albumentations as A
  File "/opt/conda/lib/python3.6/site-packages/albumentations/__init__.py", line 5, in <module>
    from .core.composition import *
  File "/opt/conda/lib/python3.6/site-packages/albumentations/core/composition.py", line 8, in <module>
    from albumentations.augmentations.keypoints_utils import KeypointsProcessor
  File "/opt/conda/lib/python3.6/site-packages/albumentations/augmentations/__init__.py", line 4, in <module>
    from .functional import *
  File "/opt/conda/lib/python3.6/site-packages/albumentations/augmentations/functional.py", line 7, in <module>
    import cv2
  File "/opt/conda/lib/python3.6/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/opt/conda/lib/python3.6/site-packages/cv2/__init__.py", line 175, in bootstrap
    if __load_extra_py_code_for_module("cv2", submodule, DEBUG):
  File "/opt/conda/lib/python3.6/site-packages/cv2/__init__.py", line 28, in __load_extra_py_code_for_module
    py_module = importlib.import_module(module_name)
  File "/opt/conda/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/opt/conda/lib/python3.6/site-packages/cv2/mat_wrapper/__init__.py", line 33, in <module>
    cv._registerMatType(Mat)
AttributeError: module 'cv2' has no attribute '_registerMatType'

To Reproduce

Steps to reproduce the behavior:

  1. Follow the setup instructions
  2. Mount Spacenet Vegas data locally
  3. Run the rastervision model with rastervision run local code/spacenet_vegas.py -a raw_uri $RAW_URI -a root_uri $ROOT_URI -a test FALSE

The config can be found in the experiment
but just in case:

   return SemanticSegmentationConfig(
       root_uri=root_uri,
       dataset=scene_dataset,
       backend=backend,
       train_chip_sz=chip_sz,
       predict_chip_sz=chip_sz,
       #img_format='npy',
       chip_options=chip_options
   )

Expected behavior

Environment

Running Raster Vision directly in Windows is not supported, and we recommend that you run it from within a Docker container.

  • How you installed and are running Raster Vision (pip install on local vs. inside Docker image):
    • I'm using the docker/build and docker/run --gpu from the Github and mounting my local data with it
  • Raster Vision version or commit:
    • 0.13, just pulled it last week and followed the setup instructions
  • OS (e.g., Linux):
    • Ubuntu 22.04
  • Python version:
    • 3.6.9
  • CUDA/cuDNN version if running on GPU:
    • 10.2 because of the docker

Any direction of the source of the errors would be helpful.

@yashgharat
Copy link
Author

So the master branch does not work.
But the 0.13 needed an openCV update. I installed with pip install opencv-python-headless==4.5.4.60

Not sure to close this since the first two error messages are still valid. Feel free to close otherwise.

@AdeelH
Copy link
Collaborator

AdeelH commented Jun 28, 2022

Hi, thanks for the report!

Yes, some examples are not yet updated to be compatible with the master branch. I would recommend using the 0.13 branch for now.

I would keep this PR open because this is something we definitely need to fix.

@AdeelH
Copy link
Collaborator

AdeelH commented Jun 28, 2022

Did installing opencv via pip fix the problem?

@yashgharat
Copy link
Author

@AdeelH for the 0.13 branch yes installing opencv fixed the line. I added this line to the Dockerfile.
RUN pip install opencv-python-headless==4.5.4.60
that solved the error for
AttributeError: module 'cv2' has no attribute '_registerMatType'

@AdeelH
Copy link
Collaborator

AdeelH commented Jul 14, 2022

BTW, this same opencv error was fixed on master earlier this year in this PR: #1323

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants