(dirs, mode='img')
| 25 | return any(filename.endswith(extension) for extension in NP_EXTENSIONS) |
| 26 | |
| 27 | def make_dataset(dirs, mode='img'): |
| 28 | if(not isinstance(dirs,list)): |
| 29 | dirs = [dirs,] |
| 30 | |
| 31 | images = [] |
| 32 | for dir in dirs: |
| 33 | assert os.path.isdir(dir), '%s is not a valid directory' % dir |
| 34 | for root, _, fnames in sorted(os.walk(dir)): |
| 35 | for fname in fnames: |
| 36 | if is_image_file(fname, mode=mode): |
| 37 | path = os.path.join(root, fname) |
| 38 | images.append(path) |
| 39 | |
| 40 | # print("Found %i images in %s"%(len(images),root)) |
| 41 | return images |
| 42 | |
| 43 | def default_loader(path): |
| 44 | return Image.open(path).convert('RGB') |
no test coverage detected