Created
October 19, 2022 14:45
-
-
Save songyuc/9fc8da3ad8b851353940e054b36bc7e1 to your computer and use it in GitHub Desktop.
Got WARNING with `auto_reset`.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nvidia.dali.fn as fn | |
from nvidia.dali import pipeline_def | |
from nvidia.dali.plugin.pytorch import DALIGenericIterator | |
from tqdm import tqdm | |
@pipeline_def | |
def coco_pipeline(): | |
coco_root = "/local/COCO" | |
images, bounding_boxes, labels, image_ids = fn.readers.coco( | |
file_root=coco_root + "/train2017", | |
image_ids=True, # return image_id for validation | |
annotations_file=coco_root + "/annotations_trainval2017/annotations/instances_train2017.json", | |
skip_empty=True, | |
ratio=True, | |
ltrb=True, | |
random_shuffle=False, | |
shuffle_after_epoch=True, # data shuffling | |
name="Reader") | |
return image_ids | |
def main(): | |
pipe = coco_pipeline(batch_size=4, num_threads=4, device_id=0) | |
# pipe.build() # only for debugging | |
train_loader = DALIGenericIterator( | |
pipe, | |
["image_ids", ], | |
reader_name="Reader", | |
auto_reset=True) | |
test_samples_number = 3 | |
for _ in range(2): | |
print("len(train_loader) = ", len(train_loader)) | |
list_image_ids = [] | |
for i, data in tqdm(enumerate(train_loader)): | |
list_image_ids.append(data[0]["image_ids"]) | |
if i < test_samples_number: | |
print(data[0]["image_ids"]) | |
return 0 | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment