# Buggy code
def process(self, scenes, tmp_dir):
    evaluation = self.create_evaluation()
    vect_evaluation = self.create_evaluation()
    null_class_id = self.class_config.get_null_class_id()

    for scene in scenes:
        log.info("Computing evaluation for scene {}...".format(scene.id))
        label_source = scene.ground_truth_label_source
        label_store = scene.prediction_label_store
        with ActivateMixin.compose(label_source, label_store):
            ground_truth = label_source.get_labels()
            predictions = label_store.get_labels()

            if scene.aoi_polygons:
                # Filter labels based on AOI.
                ground_truth = ground_truth.filter_by_aoi(
                    scene.aoi_polygons, null_class_id
                )
                predictions = predictions.filter_by_aoi(
                    scene.aoi_polygons, null_class_id
                )
            scene_evaluation = self.create_evaluation()
            scene_evaluation.compute(ground_truth, predictions)
            evaluation.merge(scene_evaluation, scene_id=scene.id)

        if (
            hasattr(label_source, "raster_source")
            and hasattr(label_source.raster_source, "vector_source")
            and hasattr(label_store, "vector_output")
        ):
            gt_geojson = label_source.raster_source.vector_source.get_geojson()
            for vo in label_store.vector_output:
                pred_geojson_uri = vo.uri
                mode = vo.get_mode()
                class_id = vo.class_id
                pred_geojson_source = GeoJSONVectorSourceConfig(
                    uri=pred_geojson_uri, default_class_id=None
                ).build(self.class_config, scene.raster_source.get_crs_transformer())
                pred_geojson = pred_geojson_source.get_geojson()

                if scene.aoi_polygons:
                    gt_geojson = filter_geojson_by_aoi(gt_geojson, scene.aoi_polygons)
                    pred_geojson = filter_geojson_by_aoi(
                        pred_geojson, scene.aoi_polygons
                    )

                vect_scene_evaluation = self.create_evaluation()
                vect_scene_evaluation.compute_vector(
                    gt_geojson, pred_geojson, mode, class_id
                )
                vect_evaluation.merge(vect_scene_evaluation, scene_id=scene.id)

    if not evaluation.is_empty():
        evaluation.save(self.output_uri)
    if not vect_evaluation.is_empty():
        vect_evaluation.save(self.vector_output_uri)


# Traceback (json.decoder.JSONDecodeError)

17:55:54
2019-10-01 17:55:54:rastervision.utils.files: INFO - Downloading s3://raster-vision-lf-dev/examples/test-output/21/spacenet-vegas-buildings-semantic-segmentation-pytorch/predict/buildings-semantic_segmentation/5058.tif to /opt/data/temp/tmp5903c076/tmpk2r7cdga/s3/raster-vision-lf-dev/examples/test-output/21/spacenet-vegas-buildings-semantic-segmentation-pytorch/predict/buildings-semantic_segmentat
2019-10-01 17:55:54:rastervision.utils.files: INFO - Downloading s3://raster-vision-lf-dev/examples/test-output/21/spacenet-vegas-buildings-semantic-segmentation-pytorch/predict/buildings-semantic_segmentation/5058.tif to /opt/data/temp/tmp5903c076/tmpk2r7cdga/s3/raster-vision-lf-dev/examples/test-output/21/spacenet-vegas-buildings-semantic-segmentation-pytorch/predict/buildings-semantic_segmentation/5058.tif

17:55:56
Traceback (most recent call last):

17:55:56
File "/opt/conda/lib/python3.6/runpy.py", line 193, in _run_module_as_main

17:55:56
"__main__", mod_spec)

17:55:56
File "/opt/conda/lib/python3.6/runpy.py", line 85, in _run_code

17:55:56
exec(code, run_globals)

17:55:56
File "/opt/src/rastervision/__main__.py", line 17, in <module>

17:55:56
rv.main()

17:55:56
File "/opt/conda/lib/python3.6/site-packages/click/core.py", line 722, in __call__

17:55:56
return self.main(*args, **kwargs)

17:55:56
File "/opt/conda/lib/python3.6/site-packages/click/core.py", line 697, in main

17:55:56
rv = self.invoke(ctx)

17:55:56
File "/opt/conda/lib/python3.6/site-packages/click/core.py", line 1066, in invoke

17:55:56
return _process_result(sub_ctx.command.invoke(sub_ctx))

17:55:56
File "/opt/conda/lib/python3.6/site-packages/click/core.py", line 895, in invoke

17:55:56
return ctx.invoke(self.callback, **ctx.params)

17:55:56
File "/opt/conda/lib/python3.6/site-packages/click/core.py", line 535, in invoke

17:55:56
return callback(*args, **kwargs)

17:55:56
File "/opt/src/rastervision/cli/main.py", line 294, in run_command

17:55:56
rv.runner.CommandRunner.run(command_config_uri)

17:55:56
File "/opt/src/rastervision/runner/command_runner.py", line 11, in run

17:55:56
CommandRunner.run_from_proto(msg)

17:55:56
File "/opt/src/rastervision/runner/command_runner.py", line 17, in run_from_proto

17:55:56
command.run()

17:55:56
File "/opt/src/rastervision/command/eval_command.py", line 24, in run

17:55:56
evaluator.process(scenes, tmp_dir)

17:55:56
File "/opt/src/rastervision/evaluation/semantic_segmentation_evaluator.py", line 75, in process

17:55:56
pred_geojson = pred_geojson_source.get_geojson()

17:55:56
File "/opt/src/rastervision/data/vector_source/vector_source.py", line 153, in get_geojson

17:55:56
self.geojson = self._get_geojson()

17:55:56
File "/opt/src/rastervision/data/vector_source/geojson_vector_source.py", line 25, in _get_geojson

17:55:56
geojson = json.loads(file_to_str(self.uri))

17:55:56
File "/opt/conda/lib/python3.6/json/__init__.py", line 354, in loads

17:55:56
return _default_decoder.decode(s)

17:55:56
File "/opt/conda/lib/python3.6/json/decoder.py", line 339, in decode

17:55:56
obj, end = self.raw_decode(s, idx=_w(s, 0).end())

17:55:56
File "/opt/conda/lib/python3.6/json/decoder.py", line 357, in raw_decode

17:55:56
raise JSONDecodeError("Expecting value", s, err.value) from None

17:55:56
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

# Fixed code
def process(self, scenes, tmp_dir):
    evaluation = self.create_evaluation()
    vect_evaluation = self.create_evaluation()
    null_class_id = self.class_config.get_null_class_id()

    for scene in scenes:
        log.info("Computing evaluation for scene {}...".format(scene.id))
        label_source = scene.ground_truth_label_source
        label_store = scene.prediction_label_store
        with ActivateMixin.compose(label_source, label_store):
            ground_truth = label_source.get_labels()
            predictions = label_store.get_labels()

            if scene.aoi_polygons:
                # Filter labels based on AOI.
                ground_truth = ground_truth.filter_by_aoi(
                    scene.aoi_polygons, null_class_id
                )
                predictions = predictions.filter_by_aoi(
                    scene.aoi_polygons, null_class_id
                )
            scene_evaluation = self.create_evaluation()
            scene_evaluation.compute(ground_truth, predictions)
            evaluation.merge(scene_evaluation, scene_id=scene.id)

        if (
            hasattr(label_source, "raster_source")
            and hasattr(label_source.raster_source, "vector_source")
            and hasattr(label_store, "vector_output")
        ):
            gt_geojson = label_source.raster_source.vector_source.get_geojson()
            for vo in label_store.vector_output:
                pred_geojson_uri = vo.uri
                mode = vo.get_mode()
                class_id = vo.class_id
                pred_geojson_source = GeoJSONVectorSourceConfig(
                    uri=pred_geojson_uri, default_class_id=class_id
                ).build(self.class_config, scene.raster_source.get_crs_transformer())
                pred_geojson = pred_geojson_source.get_geojson()

                if scene.aoi_polygons:
                    gt_geojson = filter_geojson_by_aoi(gt_geojson, scene.aoi_polygons)
                    pred_geojson = filter_geojson_by_aoi(
                        pred_geojson, scene.aoi_polygons
                    )

                vect_scene_evaluation = self.create_evaluation()
                vect_scene_evaluation.compute_vector(
                    gt_geojson, pred_geojson, mode, class_id
                )
                vect_evaluation.merge(vect_scene_evaluation, scene_id=scene.id)

    if not evaluation.is_empty():
        evaluation.save(self.output_uri)
    if not vect_evaluation.is_empty():
        vect_evaluation.save(self.vector_output_uri)