| 68 | |
| 69 | |
| 70 | def get_paths(opt): |
| 71 | if opt["type"] == "Segmentation": |
| 72 | images = sorted( |
| 73 | [ |
| 74 | os.path.join(opt["data_images"], img) |
| 75 | for img in os.listdir(opt["data_images"]) |
| 76 | ] |
| 77 | ) |
| 78 | masks = sorted( |
| 79 | [ |
| 80 | os.path.join(opt["data_masks"], msk) |
| 81 | for msk in os.listdir(opt["data_masks"]) |
| 82 | ] |
| 83 | ) |
| 84 | return images, masks |
| 85 | elif opt["type"] == "Classification": |
| 86 | images = glob(os.path.join(opt["data_images"], "*/*")) |
| 87 | labels = [class_mapping[str(lbl.split(os.path.sep)[-2])] for lbl in images] |
| 88 | return images, labels |
| 89 | else: |
| 90 | assert ( |
| 91 | False |
| 92 | ), f"Found data type as {opt['type']} but it should be one of Segmentation/Classification" |
| 93 | |
| 94 | |
| 95 | class LoadSegData: |