tensorlayer / TensorLayer

Deep Learning and Reinforcement Learning Library for Scientists and Engineers
http://tensorlayerx.com
Other
7.33k stars 1.61k forks source link

Load data from folder #187

Closed kindlychung closed 7 years ago

kindlychung commented 7 years ago

Would be nice to have something to load folder structures like this:

train_images
├── class1
│   ├── img1
│   ├── img2
│   ├── img3
│   └── img4
└── class2
    ├── img1
    ├── img2
    ├── img3
    └── img4
fangde commented 7 years ago

We use database to handle This

?取 Outlook for Androidhttps://aka.ms/ghei36


From: Kaiyin Zhong notifications@github.com Sent: Monday, August 7, 2017 9:23:45 AM To: zsdonghao/tensorlayer Cc: Subscribed Subject: [zsdonghao/tensorlayer] Load data from folder (#187)

Would be nice to have something to load folder structures like this:

train_images ├── class1 │ ├── img1 │ ├── img2 │ ├── img3 │ └── img4 └── class2 ├── img1 ├── img2 ├── img3 └── img4

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/zsdonghao/tensorlayer/issues/187, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AGMKGA_N2Mri8B7TSng_q7gtZbnIcNY4ks5sVsmRgaJpZM4OvIbT.

zsdonghao commented 7 years ago

@kindlychung try this:

    def load_image_from_folder(path):
        path_imgs = load_file_list(path=path, regx='\\.jpg', printable=False)
        return tl.vis.read_images(path_imgs, path=path, n_threads=10, printable=False)
    im_train_A = load_image_from_folder(path+"/"+filename+"/trainA")
    im_train_B = load_image_from_folder(path+"/"+filename+"/trainB")
    im_test_A = load_image_from_folder(path+"/"+filename+"/testA")
    im_test_B = load_image_from_folder(path+"/"+filename+"/testB")