Skip to content

Commit ba2791f

Browse files
committed
fallback to hash-based h5 naming
1 parent 085c254 commit ba2791f

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

superpixel_classification/SuperpixelClassification/SuperpixelClassificationBase.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import argparse
22
import concurrent.futures
33
import copy
4+
import hashlib
45
import json
56
import os
67
import pickle
@@ -434,10 +435,18 @@ def createFeatures(self, gc, folderId, annotationName, featureFolderId, patchSiz
434435
]
435436
if len(match):
436437
results[item['_id']] = match[0][0]
437-
else:
438-
futures.append((item, executor.submit(
439-
self.createFeaturesForItem, gc, item, elem, featureFolderId,
440-
'%s.feature.h5' % (item['name']), patchSize, prog)))
438+
else: # fallback to hash-based naming - generate features if necessary
439+
bbox = elem['user']['bbox']
440+
hashval = repr(dict(
441+
itemId=item['_id'], bbox=[int(v) for v in bbox], patchSize=patchSize))
442+
hashval = hashlib.new('sha256', hashval.encode()).hexdigest()
443+
fileName = 'feature-%s.h5' % (hashval)
444+
if fileName in featureFiles:
445+
results[item['_id']] = fileName
446+
else:
447+
futures.append((item, executor.submit(
448+
self.createFeaturesForItem, gc, item, elem, featureFolderId,
449+
'%s.feature.h5' % (item['name']), patchSize, prog)))
441450
for item, future in futures:
442451
file = future.result()
443452
try:

0 commit comments

Comments
 (0)