Skip to content

Commit

Permalink
metrics will now recompute if area_error missing to handle upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
Abe404 committed Dec 10, 2022
1 parent 16362d4 commit d3b0219
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions painter/src/main/python/plot_seg_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,15 @@ def run(self):
# cache_dir = os.path.join(self.proj_dir, 'metrics_cache')
cache_key = get_cache_key(self.seg_dir, self.annot_dir, fname)
metrics = None
if cache_key in cache_dict:
if cache_key in cache_dict:
metrics = cache_dict[cache_key]
# ignore cached metric if it does not include area error.
# This is because the cached metric is from an older version of RootPainter
# and we now need to recompute the metrics to include area error
if metrics and 'area_error' not in metrics:
metrics = None



# also recompute is metrics is None (even if found in cache) as None could indicate
# that the segmentation was previously missing when metrics was last computed.
Expand Down Expand Up @@ -199,7 +206,7 @@ def run(self):

with open(cache_dict_path, 'wb') as cache_file:
pickle.dump(cache_dict, cache_file)
print('time to get metrics =', time.time() - start)
print('Seconds to get metrics: ', round(time.time() - start, 2))
self.done.emit(json.dumps([all_fnames, all_metrics]))


Expand Down

0 comments on commit d3b0219

Please sign in to comment.