File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed 
cellseg_models_pytorch/inference Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -44,9 +44,6 @@ def __init__(
4444        if  not  folder_path .is_dir ():
4545            raise  ValueError (f"path: { folder_path }   is not a folder" )
4646
47-         if  not  all ([f .suffix  in  SUFFIXES  for  f  in  folder_path .iterdir ()]):
48-             raise  ValueError (f"files formats in given folder need to be in { SUFFIXES }  " )
49- 
5047        self .fnames  =  sorted (folder_path .glob (pattern ))
5148        if  n_images  is  not   None :
5249            self .fnames  =  self .fnames [:n_images ]
@@ -58,7 +55,14 @@ def __len__(self) -> int:
5855    def  __getitem__ (self , ix : int ) ->  torch .Tensor :
5956        """Read image.""" 
6057        fn  =  self .fnames [ix ]
61-         im  =  FileHandler .read_img (fn .as_posix ())
62-         im  =  torch .from_numpy (im .transpose (2 , 0 , 1 ))
58+         if  fn .suffix  in  SUFFIXES :
59+             im  =  FileHandler .read_img (fn .as_posix ())
60+             im  =  torch .from_numpy (im .transpose (2 , 0 , 1 ))
61+         else :
62+             raise  ValueError (
63+                 f"Received an illegal file format in: { fn }  ." 
64+                 f"file format { fn .suffix }   not supported." 
65+                 f"Supported formats: { SUFFIXES }  ." 
66+             )
6367
6468        return  {"im" : im , "file" : fn .with_suffix ("" ).name }
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments