Repository: azavea/raster-vision

Issue #976: Model bundles with polygon output try to write to private S3 bucket
Created: 2020-08-19T21:00:11Z
Running the following command tries to write a file to s3: //raster-vision-lf-dev/examples/spacenet-vegas-buildings-ss/output_6_27c/predict/1332-0-polygons.json which is in a private bucket. I never noticed it before because I have access to that bucket :) The predict command is trying to write to the same bucket used when the model bundle was generated. This usually doesn't happen, but it is because the polygon output uses a different code path.
rastervision predict https://s3.amazonaws.com/azavea-research-public-data/raster-vision/examples/model-zoo-0.12/spacenet-vegas-buildings-ss/model-bundle.zip https://s3.amazonaws.com/azavea-research-public-data/raster-vision/examples/model-zoo-0.12/spacenet-vegas-buildings-ss/1929.tif /opt/data/prediction.tif

To avoid something like this in the future, we should test the predict command with our usual AWS profile blanked out.

Duplicate issue #1070: Feature Request: example python codes for predicting with locally saved model-bundle.zip on a tif
Created: 2021-01-13T02:42:51Z
It would be nice to run a .py file for predicting with a locally saved model-bundle.zip on a tif.
I had the issue #976  and its fix #980 did not solve my problem. I also tried different versions with Docker such as:
 sudo docker run --rm -it \
     -v ${RV_QUICKSTART_CODE_DIR}:/opt/src/code  \
     -v ${RV_QUICKSTART_OUT_DIR}:/opt/data/output \
     quay.io/azavea/raster-vision:pytorch-0.12 /bin/bash

and
sudo docker run --rm -it \
     -v ${RV_QUICKSTART_CODE_DIR}:/opt/src/code  \
     -v ${RV_QUICKSTART_OUT_DIR}:/opt/data/output \
     quay.io/azavea/raster-vision:pytorch-latest /bin/bash

in vain.
I also tried both using downloaded model-bundle and tif (in local directory /tests/code  so that the files are also shown in root@14157fb3a93b:/opt/src/code,  then simply run rastervision predict model-bundle.zip 1929.tif prediction.tif which still reports exception)
and using online files as shown in tutorial. The bugs are the same.
It's great if there is a  .py file making predictions with pre-trained model-bundle.

Closing comment (2021-01-20T17:56:30Z): When running this with commit 0bbc4e1 I got the following error which is different than the one that was reported in #976. It looks like something was changed since #980 which is causing this problem. In the next few weeks we are going to make a new release which will fix this, but for now, as a workaround I would use image pytorch-45815af. This was the one published right after the #980.
root@8c4cc1cc5b65:/opt/src# rastervision predict https://s3.amazonaws.com/azavea-research-public-data/raster-vision/examples/model-zoo-0.12/spacenet-vegas-buildings-ss/model-bundle.zip https://s3.amazonaws.com/azavea-research-public-data/raster-vision/examples/model-zoo-0.12/spacenet-vegas-buildings-ss/1929.tif /opt/data/prediction.tif

Traceback (most recent call last):
  File "/opt/conda/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/opt/conda/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/opt/src/rastervision_pipeline/rastervision/pipeline/cli.py", line 248, in <module>
    main()
  File "/opt/conda/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/opt/conda/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/opt/conda/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/conda/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/conda/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/opt/src/rastervision_core/rastervision/core/cli.py", line 72, in predict
    channel_order)
  File "/opt/src/rastervision_core/rastervision/core/predictor.py", line 50, in __init__
    config_dict = upgrade_config(config_dict)
  File "/opt/src/rastervision_pipeline/rastervision/pipeline/config.py", line 239, in upgrade_config
    return _upgrade_config(config_dict, plugin_versions)
  File "/opt/src/rastervision_pipeline/rastervision/pipeline/config.py", line 178, in _upgrade_config
    new_x[k] = _upgrade_config(v, plugin_versions)
  File "/opt/src/rastervision_pipeline/rastervision/pipeline/config.py", line 189, in _upgrade_config
    new_x = upgrader(new_x, version)
  File "/opt/src/rastervision_pytorch_backend/rastervision/pytorch_backend/pytorch_semantic_segmentation_config.py", line 33, in ss_learner_backend_config_upgrader
    if data_cfg_dict['img_sz'] is None:
KeyError: 'img_sz'