Are there any complete examples for using user-defined input (i.e. not a bitmap) with Image classifiers?
I have read the existing posts about loading custom data, but I cannot go from that to actually feeding the image classifier with data of correct type, size & dimension.
to a 32x32x3 python array which I somehow (and this is the part I have trouble with) translate to a numpy/pytroch primitive of correct size and dimension that a standard image classifier would accept.
So far I have only been able to get this to work by generating intermediate Bitmap files and then using a standard image loader, but for my experiment this is very inefficient.
I’m not sure that I understand your problem. If your data translate to images, I would generate once all bitmaps and store in a folder. From there, I would train like a image classification problem.
However, from the data sample you posted, it seems that you have a csv file. So, I would treat your problem as tabular with 3 columns (size, color, type). See tabular docs. Also, you may split size into to column (height and width)
Finally, I don’t think that a image classifier will work in non image data as it uses convolutions to extract image features.
This was just an example, the actual data is more complex and results in a real bitmap.
Let me rephrase the problem:
ImageDataBunch needs a filename and in this case there is no file since the image is generated on the fly from the data.
It would be trivial to generate all bitmaps and save them to a file but there is a lot of data and the images are very small (around 32x32) so having them as a bitmap on disk or in memory would be very inefficient.
The generated 32x32 matrix is evaluated with different algorithms. To be able to compare it to someone elses work, one of them needs to be an image classifier using deep CNN.
There are also multiple parameters in generating the images, so generating them at runtime has the advantage of that I can play with the parameters.
def get(self, i):
fn = super().get(i) # In your case, returns data/10x10
res = self.open(fn). # <- Here, instead of opening an image, you need to create it.
self.sizes[i] = res.size
return res