python - Writing many tif files into h5 file format -


i trying prepare data cnn training in keras unfortunately images have (more 10kk) in tif format 3 channels keras not able read. need convert them , think best choice tif conversion numpy array , save h5 format.

images selected few classes , want create few h5 files classes in them. wondering how should create h5 file able read keras , create labels later. way of generating h5 files correct? able read files without problems , shuffle them in batches different classes in each?

thanks !

import h5py, os import matplotlib.pyplot plt  folderwithtifsclass0 = "path/to/tifs/with/class/0" folderwithtifsclass1 = "path/to/tifs/with/class/1" folderwithtifsclass2 = "path/to/tifs/with/class/2" tablewithtifs0, tablewithtifs1, tablewithtifs2 = [], [], []  # writing tifs class 0 array tiffile in os.listdir(folderwithtifsclass0):     img = plt.imread(tiffile)     tablewithtifs0.append(img)  # writing tifs class 1 array tiffile in os.listdir(folderwithtifsclass1):     img = plt.imread(tiffile)     tablewithtifs1.append(img)  # writing tifs class 2 array tiffile in os.listdir(folderwithtifsclass2):     img = plt.imread(tiffile)     tablewithtifs2.append(img)  h5py.file("data.h5", "w") hf:      hf.create_dataset("class0", data=tablewithtifs0)     hf.create_dataset("class1", data=tablewithtifs1)     hf.create_dataset("class2", data=tablewithtifs2)      hf.close() 


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -