{"cells":[{"metadata":{},"cell_type":"markdown","source":"# About\n\nThis kernel presents the [104 Flowers: Garden of Eden dataset](https://www.kaggle.com/msheriey/104-flowers-garden-of-eden) which is a JPEG conversion of the [Flower Classification with TPUs competition TFRecords dataset](https://www.kaggle.com/c/flower-classification-with-tpus). \n\nThe aim of this kernel and dataset is to help people:\n\n*     Practice transforming it back to TFRecords.\n*     Add it to the [Valentine's kernel](https://www.kaggle.com/mpwolke/valentine-s-day-no-tpu).\n*     View the original dataset more easily.\n*     Create EDAs.\n\nor else."},{"metadata":{},"cell_type":"markdown","source":"<font size=4 color='red'> If you find this kernel useful, please don't forget to upvote. Thank you. </font>"},{"metadata":{},"cell_type":"markdown","source":"# Reading Files"},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"import os\n\nimport random\n\nimport numpy as np\n\nimport matplotlib.pyplot as plt\n\nfrom PIL import Image","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"DATASET_DIR = '/kaggle/input/104-flowers-garden-of-eden/jpeg-512x512'\n\nTRAIN_DIR  = DATASET_DIR + '/train'","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"FLOWER_NAMES = []\n\nFLOWER_TRAIN_FILEPATHS = {}\n\nfor root, dir_names, _ in os.walk(TRAIN_DIR):\n    \n    for dir_name in dir_names:\n        FLOWER_NAMES.append(dir_name)\n        FLOWER_TRAIN_FILEPATHS[dir_name] = []\n    \n        for dir_root, _, dir_filenames in os.walk(os.path.join(root, dir_name)):\n            \n            for filename in dir_filenames: \n                FLOWER_TRAIN_FILEPATHS[dir_name].append(os.path.join(dir_root, filename))","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Flower Names"},{"metadata":{"trusted":true},"cell_type":"code","source":"print('len(FLOWER_NAMES): ', len(FLOWER_NAMES))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"FLOWER_NAMES","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Naviagation"},{"metadata":{"trusted":true,"_kg_hide-output":true},"cell_type":"code","source":"FLOWER_TRAIN_FILEPATHS['artichoke']","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Grow Flowers"},{"metadata":{"trusted":true},"cell_type":"code","source":"def grow_flowers(flower_type, sample_size=5):\n    flowers = [Image.open(flower).convert('RGB') for flower in random.sample(FLOWER_TRAIN_FILEPATHS[flower_type], sample_size)]\n                \n    n_flowers = len(flowers)\n    \n    figure = plt.figure()\n    for i, flower in enumerate(flowers):\n        figure.add_subplot(1, np.ceil(n_flowers), i + 1)\n        plt.axis('off')\n        plt.imshow(flower)\n        \n    figure.set_size_inches(np.array(figure.get_size_inches()) * n_flowers)\n    \n    plt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Garden of Eden"},{"metadata":{"trusted":true},"cell_type":"code","source":"for flower_name in FLOWER_NAMES:\n    print(flower_name)\n    grow_flowers(flower_name)","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":1}