Repository: azavea/raster-vision

Issue:
Question about using model buddles. 
Hi, 
thank you for sharing the trained buddles.
However, when I tried ISPRS Potsdam segementation buddle, I can not get the prediction.
The command is here and you can see the error message.
The buddle is downloaded form your example homepage. 
```
rastervision predict $buddle $image_uri $label_uri
```
ERROR:
```
FileNotFoundError: [Errno 2] No such file or directory: '/opt/data/tmp/tmp6ut8_2hy/tmpa7bi6qk2'
```
and 
```
rastervision.pipeline.file_system.file_system.NotReadableError: Could not read s3://raster-vision-raw-data/isprs-potsdam/4_Ortho_RGBIR/top_potsdam_2_10_RGBIR.tif
```
I just use local buddle and image. Can you tell me what is wrong with it?
The same command shows no problem when using other buddles.

Thanks.


Discussion:
You're right -- this problem started occurring some time after the 0.12 release. I will try to find a fix. In the meantime, you should be able to use the 0.12 tag.
Actually, 0.12 won't work because of a separate bug which was fixed after 0.12 in #980 

Resolving patch:
diff --git a/rastervision_core/rastervision/core/data/raster_transformer/stats_transformer_config.py b/rastervision_core/rastervision/core/data/raster_transformer/stats_transformer_config.py
--- a/rastervision_core/rastervision/core/data/raster_transformer/stats_transformer_config.py
+++ b/rastervision_core/rastervision/core/data/raster_transformer/stats_transformer_config.py
@@ -18,7 +18,7 @@ class StatsTransformerConfig(RasterTransformerConfig):
          'inside an RVPipeline, then this field will be auto-generated.'))
 
     def update(self, pipeline=None, scene=None):
-        if pipeline is not None:
+        if pipeline is not None and self.stats_uri is None:
             self.stats_uri = join(pipeline.analyze_uri, 'stats.json')
 
     def build(self):
diff --git a/rastervision_core/rastervision/core/data/scene_config.py b/rastervision_core/rastervision/core/data/scene_config.py
--- a/rastervision_core/rastervision/core/data/scene_config.py
+++ b/rastervision_core/rastervision/core/data/scene_config.py
@@ -60,7 +60,8 @@ def update(self, pipeline=None):
         super().update()
 
         self.raster_source.update(pipeline=pipeline, scene=self)
-        self.label_source.update(pipeline=pipeline, scene=self)
+        if self.label_source is not None:
+            self.label_source.update(pipeline=pipeline, scene=self)
         if self.label_store is None and pipeline is not None:
             self.label_store = pipeline.get_default_label_store(scene=self)
         if self.label_store is not None:
diff --git a/rastervision_core/rastervision/core/predictor.py b/rastervision_core/rastervision/core/predictor.py
--- a/rastervision_core/rastervision/core/predictor.py
+++ b/rastervision_core/rastervision/core/predictor.py
@@ -48,15 +48,8 @@ def __init__(self,
         rv_config.set_everett_config(
             config_overrides=config_dict.get('rv_config'))
         config_dict = upgrade_config(config_dict)
-
-        self.pipeline = build_config(config_dict).build(tmp_dir)
-        self.scene = None
-
-        if not hasattr(self.pipeline, 'predict'):
-            raise Exception(
-                'pipeline in model bundle must have predict method')
-
-        self.scene = self.pipeline.config.dataset.validation_scenes[0]
+        self.config = build_config(config_dict)
+        self.scene = self.config.dataset.validation_scenes[0]
 
         if not hasattr(self.scene.raster_source, 'uris'):
             raise Exception(
@@ -72,18 +65,20 @@ def __init__(self,
         if self.update_stats:
             stats_analyzer = StatsAnalyzerConfig(
                 output_uri=join(bundle_dir, 'stats.json'))
-            self.pipeline.config.analyzers = [stats_analyzer]
+            self.config.analyzers = [stats_analyzer]
 
         self.scene.label_source = None
         self.scene.aoi_uris = None
-        self.pipeline.config.dataset.train_scenes = [self.scene]
-        self.pipeline.config.dataset.validation_scenes = [self.scene]
-        self.pipeline.config.dataset.test_scenes = None
-        self.pipeline.config.train_uri = bundle_dir
+        self.config.dataset.train_scenes = [self.scene]
+        self.config.dataset.validation_scenes = [self.scene]
+        self.config.dataset.test_scenes = []
+        self.config.train_uri = bundle_dir
 
         if channel_order is not None:
             self.scene.raster_source.channel_order = channel_order
 
+        self.pipeline = None
+
     def predict(self, image_uris, label_uri, vector_label_uri=None):
         """Generate predictions for the given image.
 
@@ -95,6 +90,13 @@ def predict(self, image_uris, label_uri, vector_label_uri=None):
             vector_label_uri: URI to save vectorized labels for semantic segmentation
                 model bundles that support it
         """
+        if self.pipeline is None:
+            self.scene.raster_source.uris = image_uris
+            self.pipeline = self.config.build(self.tmp_dir)
+            if not hasattr(self.pipeline, 'predict'):
+                raise Exception(
+                    'pipeline in model bundle must have predict method')
+
         try:
             self.scene.raster_source.uris = image_uris
             self.scene.label_store.uri = label_uri


Test patch: