{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "c6732614-7f59-056b-f061-0699d47c6fae"
      },
      "outputs": [],
      "source": [
        "#getting training and testing file's directories\n",
        "train_dir = '../input/train'\n",
        "test_dir = '../input/test'"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "_cell_guid": "ae8f121d-8c2f-20b8-6837-3c94dc56d649"
      },
      "source": [
        "# Exploring os module"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "af52f174-7352-f9fb-d0d8-386b15d757b9"
      },
      "outputs": [],
      "source": [
        "import os"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "e777c8fd-38bb-3653-da58-4092061cf54c"
      },
      "outputs": [],
      "source": [
        "#print cureent working directory\n",
        "print(os.getcwd())"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "683c40fd-74f9-688d-e187-e0d94e620fb6"
      },
      "outputs": [],
      "source": [
        "#list files and folders in train_dir directory\n",
        "#print(os.listdir(train_dir))\n",
        "\n",
        "#this will print all the image file names in this directory. So commented. "
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "fe848c37-c0a1-6c31-ed3e-1bcbcbc9d0f0"
      },
      "outputs": [],
      "source": [
        "#list files in test directory\n",
        "#print(os.listdir(test_dir))"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "5d83b440-1586-6cdb-a349-5a8a22ba3a74"
      },
      "outputs": [],
      "source": [
        "import random"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "_cell_guid": "7a398143-12e8-e815-3bfd-2fcc3732c9bf"
      },
      "source": [
        "# Show some 5 random images in training data"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "293c64c4-e101-d6e8-07b7-ad8eb7b2d3be"
      },
      "outputs": [],
      "source": [
        "image_filenames = os.listdir(train_dir)\n",
        "image_sample = random.sample(image_filenames, 5)\n",
        "print(image_sample)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "9c02adde-2b4d-9c74-1267-ec38ad36d9bf"
      },
      "outputs": [],
      "source": [
        "\n",
        "from IPython.display import display, Image"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "27f8f3ee-7ad5-e27d-2fdf-003d0ef30f9a"
      },
      "outputs": [],
      "source": [
        "for item in image_sample:\n",
        "    image_path = os.path.join(train_dir, item)\n",
        "    image = Image(filename=image_path)\n",
        "    print(image_path)\n",
        "    display(image)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "_cell_guid": "f6eab2ac-d114-caf9-fe58-421678d91807"
      },
      "source": [
        "# Show 5 random images from test data "
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "4f3dfbe1-288e-289c-a4da-b5a31abe8112"
      },
      "outputs": [],
      "source": [
        "image_filenames = os.listdir(test_dir)\n",
        "image_sample = random.sample(image_filenames, 5)\n",
        "print(image_sample)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "fe13f219-7a51-959b-9e60-c357f05d5324"
      },
      "outputs": [],
      "source": [
        "for item in image_sample:\n",
        "    image_path = os.path.join(test_dir, item)\n",
        "    image = Image(filename=image_path)\n",
        "    print(image_path)\n",
        "    display(image)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "_cell_guid": "0b90a16e-d669-f0c4-dc73-ef139f6f51fd"
      },
      "source": [
        "# Referece:\n",
        "Ziyan Feng's kernel:\n",
        "https://www.kaggle.com/ziyanfeng/dogs-vs-cats-redux-kernels-edition/dogs-vs-cats-processing-images"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "0456b27a-0721-c285-89f6-5ba71f5a1d9f"
      },
      "outputs": [],
      "source": ""
    }
  ],
  "metadata": {
    "_change_revision": 0,
    "_is_fork": false,
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.5.2"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}