On Sun, Jan 24, 2016 at 5:59 AM, Abder-Rahman Ali
<abder.rahman....@gmail.com> wrote:
>
> I have two subdirectories: category-1 and category-2, each of which contains
> image files (.jpg) that belong to each category.
>
> How can I use those images and two categories with the train_test_split()
> function in Scikit-Learn? In other words, to arrange the training and
> testing data?

How about something like:

```
from skimage.io import ImageCollection
from sklearn.cross_validation import train_test_split
import os.path

ic = ImageCollection('/path/to/category-1:/path/to/category-2')
labels = [os.path.dirname(f) for f in ic.files]

train_images, test_images, train_labels, test_labels =
train_test_split(ic, labels)
```

Stéfan

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to