I want to create a ML classifier using images just like this example.
I have two classes of images in two different folders. Is there an easier way to import all images from both folders rather than inserting picture by picture?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityI want to create a ML classifier using images just like this example.
I have two classes of images in two different folders. Is there an easier way to import all images from both folders rather than inserting picture by picture?
Classify
actually supports a nice syntax for this:
Classify[<|"class1" -> Import["class1/*"], "class2" -> Import["class2/*"]|>]
Yes, in order to create your list of images you can use the following piece of code:
Join[
Thread@Rule[Import["~/Desktop/folder1/*.png"], "Day"],
Thread@Rule[Import["~/Desktop/folder2/*.png"], "Night"]
]
Of course you will need to change the file path and the properties (day/night) appropriately.
Thread @ Rule
stuff is totally unnecessary. Look at the third usage of Classify
$\endgroup$
Sep 24, 2014 at 5:30
Import[#] & /@ FileNames["folder/*.jpg"]
is what you want. Mathematica has about 3 gigabytes of documentation. $\endgroup$Import
$\endgroup$