Last active
October 19, 2022 14:01
-
-
Save songyuc/3759a1de255cabf4510cc692fcef80ad to your computer and use it in GitHub Desktop.
There was a warning from DALI iterator.
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 = "/***/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") | |
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"]) | |
train_loader.reset() | |
return 0 | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment