-
Notifications
You must be signed in to change notification settings - Fork 442
ImageDataGenerator resizing and transforming images before preprocessing #95
Comments
Agreed; Having the same problem. I'm resizing the images in the preprocessing function, but then batch_x[i] complains about the image being the wrong size. No, it's just using self.x.shape (older version, admittedly) or self.image_shape instead of determining the image shape from the images flowing into it. I do understand the dilemma here though. You don't want to run the batch process before setting self.image_shape, and you don't want to allow different batches to have different image sizes. It's tricky. Maybe if target_size were in flow, this problem could be avoided though. |
I would like to help you guys out. If I understand correctly you need to be able to crop images instead of resizing/stretching/etc? I just want to get the point clear. |
@rragundez, The specific need is the ability to resize the images in the preprocessing function. In the end, I wrote a generator specific to the application. |
@rragundez I jumped into the issue which you described where I want to crop the image and before other transformation in the images are done |
I think this will be solved in the new design? I know that this proposition is not yet accepted, but once it is, it should be pretty fast. |
I also find myself in the position where I would like to flow directly from a directory where images have different sizes because I can't hold all the images in memory and also would like to crop/rotate/pad on-the-fly. Currently I would need to implement my own The new design @Dref360 pointed out was closed I think sine die. I also think in this new design the pre-processing function (even if called before the resizing and augmentation) was supposed to keep the same size for input and output. Wouldn't it be possible to just add the possibility to "override" (i.e. provide our own) the resizing function when flowing from a directory? This wouldn't change the preprocessing function's behaviour and I guess (didn't look at the code for this) would mean just replacing the current resizing function if overridden. I can try and do a PR for this. |
For those interested by this problem, I have a fork where I implemented this idea, I have been using it and it's working great so far. |
I am trying to use the preprocessing function to take a network sized crop out of inconsistently sized input images instead of resizing to the network size. I have tried to do this using the preprocessing function but found that it is not easily possible. Using Keras 2.2.2
While looking into this I saw that the preprocessing function runs at the start of standardize, which is after the random transforms are applied. To me this sounds like preprocssing is a bad name since it isn't actually happening first.
The text was updated successfully, but these errors were encountered: