@@ -149,7 +149,7 @@ def __retrieve_batch(self, index):
149149 find = {
150150 "FindImage" : {
151151 "constraints" : {
152- "_uniqueid" : ["==" , self .images_ids [idx ]]
152+ self . img_id_prop : ["==" , self .images_ids [idx ]]
153153 },
154154 }
155155 }
@@ -184,7 +184,7 @@ def __retrieve_polygons(self, index, constraints, tag_key, tag_format):
184184 "FindImage" : {
185185 "_ref" : 1 ,
186186 "constraints" : {
187- "_uniqueid" : ["==" , uniqueid ]
187+ self . img_id_prop : ["==" , uniqueid ]
188188 },
189189 "blobs" : False ,
190190 }
@@ -255,7 +255,7 @@ def __retrieve_bounding_boxes(self, index):
255255 "FindImage" : {
256256 "_ref" : 1 ,
257257 "constraints" : {
258- "_uniqueid" : ["==" , uniqueid ]
258+ self . img_id_prop : ["==" , uniqueid ]
259259 },
260260 "blobs" : False ,
261261 }
@@ -381,12 +381,12 @@ def search(self, constraints=None, operations=None, format=None, limit=None, sor
381381
382382 self .search_result = response
383383
384- def search_by_id (self , ids , id_key = "id" ):
384+ def search_by_property (self , prop_key , prop_values ):
385385 const = Constraints ()
386- const .is_in (id_key , ids )
386+ const .is_in (prop_key , prop_values )
387387 img_sort = {
388- "key" : id_key ,
389- "sequence" : ids ,
388+ "key" : prop_key ,
389+ "sequence" : prop_values ,
390390 }
391391 self .search (constraints = const , sort = img_sort )
392392
@@ -429,7 +429,7 @@ def get_similar_images(self, set_name, n_neighbors):
429429 "FindImage" : {
430430 "_ref" : 1 ,
431431 "constraints" : {
432- "_uniqueid" : ["==" , uniqueid ]
432+ self . img_id_prop : ["==" , uniqueid ]
433433 },
434434 "blobs" : False ,
435435 }
@@ -460,7 +460,7 @@ def get_similar_images(self, set_name, n_neighbors):
460460 "ref" : 1 ,
461461 },
462462 "results" : {
463- "list" : ["_uniqueid" ]
463+ "list" : [self . img_id_prop ]
464464 }
465465 }
466466 }]
@@ -581,9 +581,6 @@ def display(self, show_bboxes=False, show_polygons=False, limit=None, polygon_co
581581 if polygon_constraints :
582582 show_polygons = True
583583 self .images_polygons = {}
584- if "_uniqueid" in polygon_constraints .constraints .keys ():
585- print ("WARNING: don't use '_uniqueid' in polygon_constraints" )
586- print ("see https://github.com/aperture-data/athena/issues/532" )
587584
588585 for i in range (len (self .images_ids )):
589586
@@ -616,9 +613,12 @@ def display(self, show_bboxes=False, show_polygons=False, limit=None, polygon_co
616613 self .__retrieve_polygons (
617614 i , polygon_constraints , polygon_tag_key , polygon_tag_format )
618615
619- bounds = self .images_polygons [uniqueid ]["bounds" ]
620- polygons = self .images_polygons [uniqueid ]["polygons" ]
621- tags = self .images_polygons [uniqueid ]["tags" ]
616+ bounds = self .images_polygons [uniqueid ]["bounds" ] if uniqueid in self .images_polygons else [
617+ ]
618+ polygons = self .images_polygons [uniqueid ]["polygons" ] if uniqueid in self .images_polygons else [
619+ ]
620+ tags = self .images_polygons [uniqueid ]["tags" ] if uniqueid in self .images_polygons else [
621+ ]
622622
623623 for pi in range (len (polygons )):
624624 self .__draw_polygon_and_tag (image , polygons [pi ], tags [pi ] if pi < len (
@@ -670,7 +670,7 @@ def get_properties(self, prop_list=[]):
670670 "FindImage" : {
671671 "_ref" : 1 ,
672672 "constraints" : {
673- "_uniqueid" : ["==" , uniqueid ]
673+ self . img_id_prop : ["==" , uniqueid ]
674674 },
675675 "blobs" : False ,
676676 "results" : {
0 commit comments