@@ -1262,6 +1262,9 @@ def dict_to_store_semantic_segmentor(
1262
1262
layer_list = np .delete (layer_list , np .where (layer_list == 0 ))
1263
1263
layer_info_dict = {}
1264
1264
count = 1
1265
+ store = SQLiteStore ()
1266
+
1267
+ annotations = []
1265
1268
1266
1269
for type_class in layer_list :
1267
1270
layer = np .where (preds == type_class , 1 , 0 ).astype ("uint8" )
@@ -1278,6 +1281,23 @@ def dict_to_store_semantic_segmentor(
1278
1281
}
1279
1282
count += 1
1280
1283
1284
+ origin = (0 , 0 )
1285
+
1286
+ annotations .append (
1287
+ Annotation (
1288
+ geometry = make_valid_poly (
1289
+ feature2geometry (
1290
+ {
1291
+ "type" : "Polygon" ,
1292
+ "coordinates" : scale_factor * coords ,
1293
+ },
1294
+ ),
1295
+ origin = origin ,
1296
+ ),
1297
+ properties = {},
1298
+ )
1299
+ )
1300
+
1281
1301
# return layer_info_dict
1282
1302
1283
1303
# if "coordinates" not in patch_output:
@@ -1323,19 +1343,18 @@ def dict_to_store_semantic_segmentor(
1323
1343
# )
1324
1344
#
1325
1345
# store = SQLiteStore()
1326
- # _ = store.append_many(annotations, [str(i) for i in range(len(annotations))])
1327
- #
1346
+ _ = store .append_many (annotations , [str (i ) for i in range (len (annotations ))])
1347
+
1328
1348
# # if a save director is provided, then dump store into a file
1329
- # if save_path:
1330
- # # ensure parent directory exists
1331
- # save_path.parent.absolute().mkdir(parents=True, exist_ok=True)
1332
- # # ensure proper db extension
1333
- # save_path = save_path.parent.absolute() / (save_path.stem + ".db")
1334
- # store.dump(save_path)
1335
- # return save_path
1336
- #
1337
- # return store
1349
+ if save_path :
1350
+ # ensure parent directory exists
1351
+ save_path .parent .absolute ().mkdir (parents = True , exist_ok = True )
1352
+ # ensure proper db extension
1353
+ save_path = save_path .parent .absolute () / (save_path .stem + ".db" )
1354
+ store .dump (save_path )
1355
+ return save_path
1338
1356
1357
+ return store
1339
1358
1340
1359
1341
1360
def get_zarr_array (zarr_array : zarr .core .Array | np .ndarray | list ) -> np .ndarray :
0 commit comments