@@ -153,13 +153,16 @@ class CaptureAnnotatorLogic(HasTraits):
153153 all_none = Bool ()
154154
155155
156- def __init__ (self , project_path , question = None , image_dir = 'pics' , filter_files = None ):
156+ def __init__ (self , project_path , question = None , image_dir = 'pics' , filter_files = None , results_dir = None ):
157157 self .project_path = Path (project_path )
158- self .image_dir , self .annotation_file_path = setup_project_paths (self .project_path , image_dir = image_dir )
158+ self .image_dir , self .annotation_file_path = setup_project_paths (self .project_path , image_dir = image_dir , results_dir = results_dir )
159159
160160 self .image_paths = sorted (get_image_list_from_folder (self .image_dir )) #todo: use sorted in storage?
161+
161162 if filter_files :
162- self .image_paths = [p for p in self .image_paths if p .name in filter_files ]
163+ self .image_paths = [p for p in self .image_paths if str (p ) in filter_files ]
164+ if not self .image_paths :
165+ raise UserWarning ("No image files to display! Check image_dir of filter." )
163166 self .current_im_num = len (self .image_paths )
164167 self .annotations = AnnotationStorage (self .image_paths )
165168 if question :
@@ -172,15 +175,14 @@ def _update_state(self, change=None): # from annotations
172175 state_images = self ._get_state_names (self .index )
173176 current_state = {}
174177 for im_path in state_images :
175- in_name = im_path .name
176- current_state [im_path ] = self .annotations .get (in_name ) or {}
178+ current_state [str (im_path )] = self .annotations .get (str (im_path )) or {}
177179 self .all_none = all (value == {'answer' : False } for value in current_state .values ())
178180 self .current_state = current_state
179181
182+
180183 def _update_annotations (self , index ): # from screen
181184 for p , anno in self .current_state .items ():
182- self .annotations [Path (p ).name ] = anno
183-
185+ self .annotations [str (p )] = anno
184186
185187 def _save_annotations (self , * args , ** kwargs ): # to disk
186188 index = kwargs .pop ('old_index' , self .index )
@@ -213,7 +215,7 @@ def _handle_grid_click(self, event, name=None):
213215 p = Path (self .image_dir , name )
214216 current_state = self .current_state .copy ()
215217 if not p .is_dir ():
216- current_state [p ] = {'answer' : not self .current_state [p ].get ('answer' , False )}
218+ current_state [str ( p ) ] = {'answer' : not self .current_state [str ( p ) ].get ('answer' , False )}
217219 if self .all_none :
218220 self .all_none = False
219221 else :
@@ -237,12 +239,12 @@ class CaptureAnnotator(CaptureAnnotatorGUI):
237239 """
238240
239241 def __init__ (self , project_path , image_dir = 'pics' , image_width = 150 , image_height = 150 ,
240- n_rows = 3 , n_cols = 3 , question = None , filter_files = None ):
242+ n_rows = 3 , n_cols = 3 , question = None , filter_files = None , results_dir = None ):
241243
242244 super ().__init__ (image_width , image_height , n_rows , n_cols )
243245
244246 self ._model = CaptureAnnotatorLogic (project_path , question , image_dir ,
245- filter_files = filter_files )
247+ filter_files = filter_files , results_dir = results_dir )
246248
247249 self ._save_btn .on_click (self ._model ._save_annotations )
248250
0 commit comments