@@ -192,6 +192,12 @@ def test_create_image_model_with_predicted_detections(
192
192
assert fx_points in db_point_lists
193
193
194
194
195
+ def _convert_bitstring_to_numpy (bitmask : models .Bitmask ):
196
+ return np .array ([bit == "1" for bit in bitmask .value ]).reshape (
197
+ (bitmask .height , bitmask .width )
198
+ )
199
+
200
+
195
201
def test_create_model_with_predicted_segmentations (
196
202
db : Session ,
197
203
client : Client ,
@@ -217,17 +223,21 @@ def test_create_model_with_predicted_segmentations(
217
223
# grab the segmentation from the db, recover the mask, and check
218
224
# its equal to the mask the client sent over
219
225
db_annotations = (
220
- db .query (models .Annotation )
226
+ db .query (models .Bitmask )
227
+ .join (
228
+ models .Annotation ,
229
+ models .Annotation .bitmask_id == models .Bitmask .id ,
230
+ )
221
231
.where (models .Annotation .model_id .isnot (None ))
222
232
.all ()
223
233
)
224
234
225
235
if db_annotations [0 ].datum_id < db_annotations [1 ].datum_id :
226
- raster_uid1 = db_annotations [0 ]. raster
227
- raster_uid2 = db_annotations [1 ]. raster
236
+ raster_uid1 = _convert_bitstring_to_numpy ( db_annotations [0 ])
237
+ raster_uid2 = _convert_bitstring_to_numpy ( db_annotations [1 ])
228
238
else :
229
- raster_uid1 = db_annotations [1 ]. raster
230
- raster_uid2 = db_annotations [0 ]. raster
239
+ raster_uid1 = _convert_bitstring_to_numpy ( db_annotations [1 ])
240
+ raster_uid2 = _convert_bitstring_to_numpy ( db_annotations [0 ])
231
241
232
242
# test raster 1
233
243
png_from_db = db .scalar (ST_AsPNG (raster_uid1 ))
0 commit comments