Hacker way to enlarge multi-channel images in Keras

I need to enlarge multi-channel images and would like to use ImageDataGenerator Unfortunately, it only supports 1.3 and 4-channel images, and I need much more. Would it be ok to directly edit the site packages / Keras / preprocessing / image.py, adding the required number of channels?

if x.shape[self.channel_axis] not in {1, 3, 4, XXX}: raise ValueError( 'Expected input to be images (as Numpy array) ' 'following the dimension ordering convention "' + self.dim_ordering + '" ' '(channels on axis ' + str(self.channel_axis) + '), ie expected ' 'either 1, 3 or 4 channels on axis ' + str(self.channel_axis) + '. ' 'However, it was passed an array with shape ' + str(x.shape) + ' (' + str(x.shape[self.channel_axis]) + ' channels).') 

where XXX is the number of channels I need. Does it break anything? Thanks!

+5
source share
1 answer

I tried this anyway and it seems to work without too many side effects. However, I did not study all the possible problems. Therefore, if you have multi-channel data (for example, satellite images, etc.), you can try this hack. There are several places where you need to increase the add-on code :)

+1
source

Source: https://habr.com/ru/post/1263107/


All Articles