What are the best Deep learning models(with how many layers) to use in a regression task for a custom dataset containing around 100 images of only one object per image which is more or less centralized? The object is measured manually with a weight scale and the output of the model is the estimation of the density of an object expressed in g/mm.
1 Answer
In general Convolutional Neural Networks work well with images, be it a regression or a classification problem. In your case the number of images is very small, so heavy data augmentation should be used. And the network itself has to be fairly simple, to avoid overfitting. But without access to the data it is hard to recommend any actual architecture (number of layers, kernels, activations, ...).
Estimating the density is an interesting problem, it is a property of the material (assuming it isn't hollow) and is independent of the size of the object. If your objects are quite uniform in size the network might have problem with smaller and bigger objects than what you have in the training data.
If your images are high resolution, I'd consider splitting them into smaller crops (optionally with varying sizes, then resizing them into a common resolution) to get more training data.
I would also try altering the model to predict the weight and thickness as separate outputs, this way you can see which property is more difficult to predict and you can focus on that. If you feel fancy your model can have three outputs (weight, thickness, density) and optimize a weighted loss on all of them at once.
If you can publish the data I'd be interested to implement a reference solution and see how accurate it would be. By default I would not share the source code with you, just the results and give you guidance.
Edit:
I sorted the images by the known density, and noticed that it correlates quite well with the object's apparent size. This is unexpected (if you weren't measuring the mass), it sounds implausible that the largest objects would be the densest. The opposite could be explained if they started at a similar size and weight, and some were compressed down into a more dense form.
Or is it that several smaller object will back denser than fewer larger ones? I had thought of this only in the context of a single object. edit 2: this is irrelevant, in the data largest objects are densest.
The change in hue is due to normalization, and I didn't convert the images to grayscale.
Looks like the grid's first image's (_DSC3479.JPG) data entry is incorrect, it may have an extra zero after the decimal comma.
Anyway, fitting a linear regression to this data will give you a good starting point. It would give a prediction of 0.099 (median of the six nearest neighbours), which is off by just 5% from the presumed correct value of 0.104.
It seems that CNNs will not help you much here, due to low amount of data and after all small size of the objects. There isn't much detail in the texture, but shading seems to give some hint of the 3D structure. If possible, I would take 10 photos of each object in a random orientation. Naturally you need to measure their density just once :) This would be much better than rotating the images after the fact. And try to place the camera closer, so that the objects would be 250 - 400 pixels in width.
The dirty background shouldn't be an issue, actually it would be a good exercise to train a pre-processing network which would do the job for you.
-
$\begingroup$ To be honest I did not load and preprocess this dataset yet since my coding knowledge is poor(I am an amateur student). I only made high-resolution images that are all same sized and have the same distance from objects: drive.google.com/file/d/1ZhvdIjY7SPrpkP6JgVfxqtre1Xr200ZQ/… I also forgot to mention that I should calculate some interesting properties such as the area/volume of an object(in this case fertilizer granule). But the output is the estimation of the density of an object as said in the post. However, I really appreciate your help and potential guidance. $\endgroup$– SevcenkoFeb 2, 2022 at 18:07
-
$\begingroup$ Thanks for the link, images are indeed high resolution but the objects are rather small (100 - 200 px wide). Could you also upload a file which has known densities of these objects? It could be for example a CSV, with columns "filename" and "density". $\endgroup$– NikoNyrhFeb 2, 2022 at 18:21
-
$\begingroup$ docs.google.com/spreadsheets/d/… Here is the link for the CSV file for manually measured weights. The excel automatically remove some 0s on the end so two and one-digit numbers are actually three-digit numbers (0.06 = 0.060 or 0.1 = 0.100). Column A is the filename and Column B is a weight, which is easy to notice. Btw, do you know some good tutorial to load and process images? $\endgroup$– SevcenkoFeb 2, 2022 at 19:45
-
$\begingroup$ There are several image libraries for python, such as Scipy, Python Image Library and OpenCV. Any convolutional neural network tutorial should have examples as well, although they might load a pre-existing dataset such as MNIST. Oh and Kaggle is full of examples, for all the popular deep learning libraries. $\endgroup$– NikoNyrhFeb 2, 2022 at 20:39
-
$\begingroup$ Thanks for the help and suggestions, but I think I did not explain it well and led you to misunderstand. The weights in CSV file are mass estimations expressed in grams measured manually on a scale. I think I need to measure area/volume using object localization(deep learning?) through CNNs and in the end calculate density with the simple formula g/mm. Anyway, I am thinking about making more photos tomorrow from a closer distance. Did you think of angles when you said taking pictures in a random orientation? I am very low on time and that is also a big setback. $\endgroup$– SevcenkoFeb 2, 2022 at 23:43