|
12 | 12 | import numpy as np |
13 | 13 |
|
14 | 14 | import lib.transform_cv2 as T |
15 | | -from lib.sampler import RepeatedDistSampler |
16 | | -from lib.base_dataset import BaseDataset, TransformationTrain, TransformationVal |
| 15 | +from lib.base_dataset import BaseDataset |
17 | 16 |
|
18 | 17 |
|
19 | 18 | labels_info = [ |
@@ -74,48 +73,6 @@ def __init__(self, dataroot, annpath, trans_func=None, mode='train'): |
74 | 73 | ) |
75 | 74 |
|
76 | 75 |
|
77 | | -def get_data_loader(datapth, annpath, ims_per_gpu, scales, cropsize, max_iter=None, mode='train', distributed=True): |
78 | | - if mode == 'train': |
79 | | - trans_func = TransformationTrain(scales, cropsize) |
80 | | - batchsize = ims_per_gpu |
81 | | - shuffle = True |
82 | | - drop_last = True |
83 | | - elif mode == 'val': |
84 | | - trans_func = TransformationVal() |
85 | | - batchsize = ims_per_gpu |
86 | | - shuffle = False |
87 | | - drop_last = False |
88 | | - |
89 | | - ds = CityScapes(datapth, annpath, trans_func=trans_func, mode=mode) |
90 | | - |
91 | | - if distributed: |
92 | | - assert dist.is_available(), "dist should be initialzed" |
93 | | - if mode == 'train': |
94 | | - assert not max_iter is None |
95 | | - n_train_imgs = ims_per_gpu * dist.get_world_size() * max_iter |
96 | | - sampler = RepeatedDistSampler(ds, n_train_imgs, shuffle=shuffle) |
97 | | - else: |
98 | | - sampler = torch.utils.data.distributed.DistributedSampler( |
99 | | - ds, shuffle=shuffle) |
100 | | - batchsampler = torch.utils.data.sampler.BatchSampler( |
101 | | - sampler, batchsize, drop_last=drop_last |
102 | | - ) |
103 | | - dl = DataLoader( |
104 | | - ds, |
105 | | - batch_sampler=batchsampler, |
106 | | - num_workers=4, |
107 | | - pin_memory=True, |
108 | | - ) |
109 | | - else: |
110 | | - dl = DataLoader( |
111 | | - ds, |
112 | | - batch_size=batchsize, |
113 | | - shuffle=shuffle, |
114 | | - drop_last=drop_last, |
115 | | - num_workers=4, |
116 | | - pin_memory=True, |
117 | | - ) |
118 | | - return dl |
119 | 76 |
|
120 | 77 |
|
121 | 78 |
|
|
0 commit comments