allenai / satlas

Apache License 2.0
184 stars 19 forks source link

Bug: local variable 'vis' referenced before assignment #13

Closed robmarkcole closed 11 months ago

robmarkcole commented 11 months ago

Using the S2 inference example with the tree_cover model results in the error:

segmentation_mask_to_color(task, label_im, gt)
    629     for cls, color in enumerate(task['colors']):
    630         vis[label_im[cls, :, :]] = color
--> 632 return vis

UnboundLocalError: local variable 'vis' referenced before assignment

Since

config['Tasks'][head_idx]['Task']['type'] = 'regress'

Is not handled by segmentation_mask_to_color

favyen2 commented 11 months ago

The example shows how to apply the model but the visualization step is dependent on the output modality.

However I have refactored satlas.model.evaluate.visualize_outputs and updated the example so that it works for other output modalities like regression output.

https://github.com/allenai/satlas/blob/main/CustomInference.md#sentinel-2-inference-example

The tree cover model is the least accurate one of the four, it is okay after smoothing outputs across time but each output is susceptible to noise. We are working on improving it.

The visualization example generally uses confidence threshold of 0.5 but we use 0.8 for solar farm and 0.95 for onshore wind turbine and marine infrastructure. This can be achieved by passing evaluator_params=[0.95,0.95,0.95] to visualize_outputs.