Skip to content

Commit 085c254

Browse files
committed
match complex feature.h5 files
1 parent fc23cb2 commit 085c254

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

superpixel_classification/SuperpixelClassification/SuperpixelClassificationBase.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -425,18 +425,19 @@ def createFeatures(self, gc, folderId, annotationName, featureFolderId, patchSiz
425425
prog.items([item for item, _, _ in itemsAndAnnot])
426426
results = {}
427427
futures = []
428+
featureFiles = list(gc.listFile(featureFolderId))
428429
with concurrent.futures.ThreadPoolExecutor(max_workers=numWorkers) as executor:
429430
for item, _, elem in itemsAndAnnot:
430-
fileName = '%s.feature.h5' % (item['name'])
431-
found = False
432-
for existing in gc.listItem(featureFolderId, name=fileName):
433-
results[item['_id']] = next(gc.listFile(existing['_id'], limit=1))
434-
found = True
435-
break
436-
if not found:
431+
match = [
432+
f for f in featureFiles if
433+
re.match('^%s.*[.]feature.h5$' % re.escape(item['name']), f)
434+
]
435+
if len(match):
436+
results[item['_id']] = match[0][0]
437+
else:
437438
futures.append((item, executor.submit(
438-
self.createFeaturesForItem, gc, item, elem, featureFolderId, fileName,
439-
patchSize, prog)))
439+
self.createFeaturesForItem, gc, item, elem, featureFolderId,
440+
'%s.feature.h5' % (item['name']), patchSize, prog)))
440441
for item, future in futures:
441442
file = future.result()
442443
try:

0 commit comments

Comments
 (0)