Skip to content

Commit 2246832

Browse files
committed
use feature file list
1 parent ba2791f commit 2246832

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

superpixel_classification/SuperpixelClassification/SuperpixelClassificationBase.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,23 +426,26 @@ def createFeatures(self, gc, folderId, annotationName, featureFolderId, patchSiz
426426
prog.items([item for item, _, _ in itemsAndAnnot])
427427
results = {}
428428
futures = []
429-
featureFiles = list(gc.listFile(featureFolderId))
429+
featureFiles = [
430+
f for item in gc.listItem(featureFolderId) for f in gc.listFile(item['_id'])
431+
]
430432
with concurrent.futures.ThreadPoolExecutor(max_workers=numWorkers) as executor:
431433
for item, _, elem in itemsAndAnnot:
432434
match = [
433435
f for f in featureFiles if
434-
re.match('^%s.*[.]feature.h5$' % re.escape(item['name']), f)
436+
re.match('^%s.*[.]feature.h5$' % re.escape(item['name']), f['name'])
435437
]
436438
if len(match):
437-
results[item['_id']] = match[0][0]
439+
results[item['_id']] = match[0]
438440
else: # fallback to hash-based naming - generate features if necessary
439441
bbox = elem['user']['bbox']
440442
hashval = repr(dict(
441443
itemId=item['_id'], bbox=[int(v) for v in bbox], patchSize=patchSize))
442444
hashval = hashlib.new('sha256', hashval.encode()).hexdigest()
443445
fileName = 'feature-%s.h5' % (hashval)
444-
if fileName in featureFiles:
445-
results[item['_id']] = fileName
446+
match = [f for f in featureFiles if f['name'] == fileName]
447+
if len(match):
448+
results[item['_id']] = match[0]
446449
else:
447450
futures.append((item, executor.submit(
448451
self.createFeaturesForItem, gc, item, elem, featureFolderId,

0 commit comments

Comments
 (0)