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__(
44
44
if not folder_path .is_dir ():
45
45
raise ValueError (f"path: { folder_path } is not a folder" )
46
46
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
-
50
47
self .fnames = sorted (folder_path .glob (pattern ))
51
48
if n_images is not None :
52
49
self .fnames = self .fnames [:n_images ]
@@ -58,7 +55,14 @@ def __len__(self) -> int:
58
55
def __getitem__ (self , ix : int ) -> torch .Tensor :
59
56
"""Read image."""
60
57
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
+ )
63
67
64
68
return {"im" : im , "file" : fn .with_suffix ("" ).name }
You can’t perform that action at this time.
0 commit comments