Skip to content

Commit

Permalink
explain mem inefficiency in resolve_conflicts (see issue #7)
Browse files Browse the repository at this point in the history
  • Loading branch information
aryarm committed Jul 24, 2020
1 parent b44262e commit 88af859
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions scripts/resolve_conflicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,14 @@ def resolve(segments):
else:
return pd.Series([sum(segments['prob.1'])], index=['prob.1'])

# first, load the image as an array, then get its shape
print('loading orthomosaic')
img_shape = np.asarray(Image.open(args.ortho)).shape[-2::-1]
def img_size(ortho=args.ortho):
# first, load the image as an array, then get its shape
print('loading orthomosaic')
# note that this step is extremely memory inefficient!
# it loads the entire image into memory just so that we can get the image size
# TODO: improve memory usage here, perhaps by getting the image size from the segments.json file (in the imageData tag) or by using a different library that can determine image size without loading the image into memory
return np.asarray(Image.open(args.ortho)).shape[-2::-1]
img_shape = img_size()

# next, load the segments coords
print('loading segments')
Expand Down

0 comments on commit 88af859

Please sign in to comment.