karolyartur
commited on
Commit
·
3a77c97
1
Parent(s):
dc0e5e7
Load numpy arrays from path
Browse files
SMVB.py
CHANGED
@@ -17,7 +17,7 @@
|
|
17 |
"""SMVB dataset"""
|
18 |
|
19 |
import sys
|
20 |
-
import
|
21 |
if sys.version_info < (3, 9):
|
22 |
from typing import Sequence, Generator, Tuple
|
23 |
else:
|
@@ -135,7 +135,10 @@ class SMVBDataset(datasets.GeneratorBasedBuilder):
|
|
135 |
|
136 |
for i, info in enumerate(data):
|
137 |
if file_infos and i%len(keys) == 0:
|
138 |
-
|
|
|
|
|
|
|
139 |
file_infos = []
|
140 |
file_path, file_object = info
|
141 |
file_infos.append((file_path, file_object.read()))
|
|
|
17 |
"""SMVB dataset"""
|
18 |
|
19 |
import sys
|
20 |
+
import numpy as np
|
21 |
if sys.version_info < (3, 9):
|
22 |
from typing import Sequence, Generator, Tuple
|
23 |
else:
|
|
|
135 |
|
136 |
for i, info in enumerate(data):
|
137 |
if file_infos and i%len(keys) == 0:
|
138 |
+
img_features_dict = {k:{'path':d[0],'bytes':d[1]} for k,d in zip(keys,file_infos) if k in ['image','mask']}
|
139 |
+
array_features_dict = {k:np.load(d[0]) for k,d in zip(keys,file_infos) if not k in ['image','mask']}
|
140 |
+
data_dict = {**img_features_dict, **array_features_dict}
|
141 |
+
yield (i//len(keys))-1, data_dict
|
142 |
file_infos = []
|
143 |
file_path, file_object = info
|
144 |
file_infos.append((file_path, file_object.read()))
|