(dir, class_to_idx, extensions)
| 35 | |
| 36 | |
| 37 | def make_dataset(dir, class_to_idx, extensions): |
| 38 | images = [] |
| 39 | dir = os.path.expanduser(dir) |
| 40 | for target in sorted(os.listdir(dir)): |
| 41 | d = os.path.join(dir, target) |
| 42 | if not os.path.isdir(d): |
| 43 | continue |
| 44 | |
| 45 | for root, _, fnames in sorted(os.walk(d)): |
| 46 | for fname in sorted(fnames): |
| 47 | if has_file_allowed_extension(fname, extensions): |
| 48 | path = os.path.join(root, fname) |
| 49 | item = (path, class_to_idx[target]) |
| 50 | images.append(item) |
| 51 | |
| 52 | return images |
| 53 | |
| 54 | |
| 55 | def make_dataset_with_ann(ann_file, img_prefix, extensions): |
no test coverage detected