7
$\begingroup$

I tried to build a classifier for some images that I have with the following code:

class1 = Import /@ 
   FileNames["*", 
    "location1"];

class2 = Import /@ 
   FileNames["*", 
    "location2"];

classifier = 
  Classify[Join[# -> "H" & /@ 
     class1, # -> "C" & /@ 
     class2]];

I believe that this would work, but it crashes with an out of memory error after the system tries to use more than 64GB of RAM.

Total size of all the images in collection is 42MB.

How can I build a classifier that in such a way that it doesn't require more than 64GB of RAM?

Update: I converted all the files to .jpg, and the issue remained.

$\endgroup$
  • $\begingroup$ What is the file format of the images? $\endgroup$ – C. E. Mar 9 '16 at 0:44
  • $\begingroup$ @C.E. .tiff. Does it matter? $\endgroup$ – soandos Mar 9 '16 at 0:44
  • $\begingroup$ Not always, but it can. There is a discussion specifically on .tiff images and memory consumption here. $\endgroup$ – C. E. Mar 9 '16 at 0:53
  • $\begingroup$ @C.E. h'm. Should what format should I convert them to as a test? $\endgroup$ – soandos Mar 9 '16 at 0:54
  • 2
    $\begingroup$ There's no simple answer to that question. You begin by guessing "what values are relevant in these images for an algorithm that would need to distinguish between them?" and then you'd extract values for each of those. So for example, you might extract the brightness of each image. Or maybe how green the image is. You then have a vector of each of these features and use these vectors instead of the image. $\endgroup$ – Searke Mar 9 '16 at 4:34
2
$\begingroup$

This isn't a complete answer (indeed, that would be impossible since we don't have access to the images), but is too long for a comment.

You might try ImageIdentify[image,category,n] to generate "feature vectors" consisting of n words. If you are lucky, the best n matches might contain enough information to distinguish the two kinds of images. The advantage of this approach is that you would leverage all the sophisticated image processing inherent in ImageIdentify and the classifier needs to only function on the words. So in outline, for each image you would get a list like

feat = ImageIdentify[image, All, 5]

which returns a 5-vector of where feat[[All, 2]] contains the best-match words. These sets of words could then be used in the Classify step.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.