{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.7.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"<br>\n\n<br><center><img src=\"https://i.ibb.co/zr0kVr8/0-S4-LF1-Obk-Vh2ke-I.jpg\" width=100%></center>\n\n<h2 style=\"text-align: center; font-family: Verdana; font-size: 24px; font-style: normal; font-weight: bold; text-decoration: underline; text-transform: none; letter-spacing: 2px; color: #DA9186; background-color: #ffffff;\">Google Universal Image Embedding</h2>\n<h5 style=\"text-align: center; font-family: Verdana; font-size: 12px; font-style: normal; font-weight: bold; text-decoration: None; text-transform: none; letter-spacing: 1px; color: black; background-color: #ffffff;\">CREATED BY: DARIEN SCHETTLER</h5>\n\n<br>\n\n---\n\n<br>\n\n<center><div class=\"alert alert-block alert-danger\" style=\"margin: 2em; line-height: 1.7em; font-family: Verdana;\">\n    <b style=\"font-size: 18px;\">🛑 &nbsp; WARNING:</b><br><br><b>THIS IS A WORK IN PROGRESS</b><br>\n</div></center>\n\n\n<center><div class=\"alert alert-block alert-warning\" style=\"margin: 2em; line-height: 1.7em; font-family: Verdana;\">\n    <b style=\"font-size: 18px;\">👏 &nbsp; IF YOU FORK THIS OR FIND THIS HELPFUL &nbsp; 👏</b><br><br><b style=\"font-size: 22px; color: darkorange\">PLEASE UPVOTE!</b><br><br>This was a lot of work for me and while it may seem silly, it makes me feel appreciated when others like my work. 😅\n</div></center>\n\n\n","metadata":{}},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"markdown","source":"<p id=\"toc\"></p>\n\n<br><br>\n\n<h1 style=\"font-family: Verdana; font-size: 24px; font-style: normal; font-weight: bold; text-decoration: none; text-transform: none; letter-spacing: 3px; color: #DA9186; background-color: #ffffff;\">TABLE OF CONTENTS</h1>\n\n---\n\n<h3 style=\"text-indent: 10vw; font-family: Verdana; font-size: 20px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: navy; background-color: #ffffff;\"><a href=\"#imports\">0&nbsp;&nbsp;&nbsp;&nbsp;IMPORTS</a></h3>\n\n---\n\n<h3 style=\"text-indent: 10vw; font-family: Verdana; font-size: 20px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: navy; background-color: #ffffff;\"><a href=\"#background_information\">1&nbsp;&nbsp;&nbsp;&nbsp;BACKGROUND INFORMATION</a></h3>\n\n---\n\n<h3 style=\"text-indent: 10vw; font-family: Verdana; font-size: 20px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: navy; background-color: #ffffff;\"><a href=\"#setup\">2&nbsp;&nbsp;&nbsp;&nbsp;SETUP</a></h3>\n\n---\n\n<h3 style=\"text-indent: 10vw; font-family: Verdana; font-size: 20px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: navy; background-color: #ffffff;\"><a href=\"#helper_functions\">3&nbsp;&nbsp;&nbsp;&nbsp;HELPER FUNCTIONS</a></h3>\n\n---\n\n<h3 style=\"text-indent: 10vw; font-family: Verdana; font-size: 20px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: navy; background-color: #ffffff;\"><a href=\"#dataset_exploration\">4&nbsp;&nbsp;&nbsp;&nbsp;DATASET EXPLORATION</a></h3>\n\n---\n\n<h3 style=\"text-indent: 10vw; font-family: Verdana; font-size: 20px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: navy; background-color: #ffffff;\"><a href=\"#modelling\">5&nbsp;&nbsp;&nbsp;&nbsp;MODELLING</a></h3>\n\n---","metadata":{}},{"cell_type":"markdown","source":"<br>\n\n<a id=\"imports\"></a>\n\n<h1 style=\"font-family: Verdana; font-size: 24px; font-style: normal; font-weight: bold; text-decoration: none; text-transform: none; letter-spacing: 3px; background-color: #ffffff; color: #DA9186;\" id=\"imports\">0&nbsp;&nbsp;IMPORTS&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#toc\">&#10514;</a></h1>","metadata":{}},{"cell_type":"code","source":"print(\"\\n... IMPORTS STARTING ...\\n\")\n\nprint(\"\\n\\tVERSION INFORMATION\")\n# Machine Learning and Data Science Imports\nimport tensorflow as tf; print(f\"\\t\\t– TENSORFLOW VERSION: {tf.__version__}\");\nimport tensorflow_hub as tfhub; print(f\"\\t\\t– TENSORFLOW HUB VERSION: {tfhub.__version__}\");\nimport tensorflow_addons as tfa; print(f\"\\t\\t– TENSORFLOW ADDONS VERSION: {tfa.__version__}\");\nimport tensorflow_io as tfio; print(f\"\\t\\t– TENSORFLOW I/O VERSION: {tfio.__version__}\");\nimport pandas as pd; pd.options.mode.chained_assignment = None;\nimport numpy as np; print(f\"\\t\\t– NUMPY VERSION: {np.__version__}\");\nimport sklearn; print(f\"\\t\\t– SKLEARN VERSION: {sklearn.__version__}\");\nfrom sklearn.preprocessing import RobustScaler, PolynomialFeatures\nfrom pandarallel import pandarallel; pandarallel.initialize();\nfrom sklearn.model_selection import GroupKFold, StratifiedKFold\nfrom scipy.spatial import cKDTree\n\n# RAPIDS\n# import cudf, cupy, cuml\n# from cuml.neighbors import NearestNeighbors\n# from cuml.manifold import TSNE, UMAP\n# from cuml import PCA\n\n# Built In Imports\nfrom kaggle_datasets import KaggleDatasets\nfrom collections import Counter\nfrom datetime import datetime\nfrom zipfile import ZipFile\nfrom glob import glob\nimport openslide\nimport warnings\nimport requests\nimport hashlib\nimport imageio\nimport IPython\nimport sklearn\nimport urllib\nimport zipfile\nimport pickle\nimport random\nimport shutil\nimport string\nimport json\nimport math\nimport time\nimport gzip\nimport ast\nimport sys\nimport io\nimport os\nimport gc\nimport re\n\n# Visualization Imports\nfrom matplotlib.colors import ListedColormap\nfrom matplotlib.patches import Rectangle\nimport matplotlib.patches as patches\nimport plotly.graph_objects as go\nimport matplotlib.pyplot as plt\nfrom tqdm.notebook import tqdm; tqdm.pandas();\nimport plotly.express as px\nimport tifffile as tif\nimport seaborn as sns\nfrom PIL import Image, ImageEnhance; Image.MAX_IMAGE_PIXELS = 5_000_000_000;\nimport matplotlib; print(f\"\\t\\t– MATPLOTLIB VERSION: {matplotlib.__version__}\");\nfrom matplotlib import animation, rc; rc('animation', html='jshtml')\nimport plotly\nimport PIL\nimport cv2\n\nimport plotly.io as pio\nprint(pio.renderers)\n\ndef seed_it_all(seed=7):\n    \"\"\" Attempt to be Reproducible \"\"\"\n    os.environ['PYTHONHASHSEED'] = str(seed)\n    random.seed(seed)\n    np.random.seed(seed)\n    tf.random.set_seed(seed)\n\n    \nprint(\"\\n\\n... IMPORTS COMPLETE ...\\n\")","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:22:34.921199Z","iopub.execute_input":"2023-04-19T02:22:34.92232Z","iopub.status.idle":"2023-04-19T02:22:47.449632Z","shell.execute_reply.started":"2023-04-19T02:22:34.922276Z","shell.execute_reply":"2023-04-19T02:22:47.448484Z"},"trusted":true},"execution_count":1,"outputs":[{"name":"stdout","text":"\n... IMPORTS STARTING ...\n\n\n\tVERSION INFORMATION\n\t\t– TENSORFLOW VERSION: 2.11.0\n\t\t– TENSORFLOW HUB VERSION: 0.12.0\n\t\t– TENSORFLOW ADDONS VERSION: 0.19.0\n\t\t– TENSORFLOW I/O VERSION: 0.29.0\n\t\t– NUMPY VERSION: 1.21.6\n\t\t– SKLEARN VERSION: 1.0.2\nINFO: Pandarallel will run on 2 workers.\nINFO: Pandarallel will use Memory file system to transfer data between the main process and workers.\n\t\t– MATPLOTLIB VERSION: 3.5.3\nRenderers configuration\n-----------------------\n    Default renderer: 'kaggle'\n    Available renderers:\n        ['plotly_mimetype', 'jupyterlab', 'nteract', 'vscode',\n         'notebook', 'notebook_connected', 'kaggle', 'azure', 'colab',\n         'cocalc', 'databricks', 'json', 'png', 'jpeg', 'jpg', 'svg',\n         'pdf', 'browser', 'firefox', 'chrome', 'chromium', 'iframe',\n         'iframe_connected', 'sphinx_gallery', 'sphinx_gallery_png']\n\n\n\n... IMPORTS COMPLETE ...\n\n","output_type":"stream"}]},{"cell_type":"markdown","source":"<br>\n\n<a id=\"background_information\"></a>\n\n<h1 style=\"font-family: Verdana; font-size: 24px; font-style: normal; font-weight: bold; text-decoration: none; text-transform: none; letter-spacing: 3px; color: #DA9186; background-color: #ffffff;\" id=\"background_information\">1&nbsp;&nbsp;BACKGROUND INFORMATION&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#toc\">&#10514;</a></h1>\n\n---\n\nThis notebook will create a dataset that spans all the required categories. It will also add in various miscellaneous datasets.\n\nThe list of datasets being used are as follows:","metadata":{}},{"cell_type":"markdown","source":"<br>\n\n<a id=\"background_information\"></a>\n\n<h1 style=\"font-family: Verdana; font-size: 24px; font-style: normal; font-weight: bold; text-decoration: none; text-transform: none; letter-spacing: 3px; color: #DA9186; background-color: #ffffff;\" id=\"setup\">2&nbsp;&nbsp;SETUP&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#toc\">&#10514;</a></h1>\n\n---\n","metadata":{}},{"cell_type":"markdown","source":"<br>\n\n<h3 style=\"font-family: Verdana; font-size: 20px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: #DA9186; background-color: #ffffff;\">2.1 ACCELERATOR DETECTION</h3>\n\n---\n\nIn order to use **`TPU`**, we use **`TPUClusterResolver`** for the initialization which is necessary to connect to the remote cluster and initialize cloud TPUs. Let's go over two important points\n\n1. When using TPU on Kaggle, you don't need to specify arguments for **`TPUClusterResolver`**\n2. However, on **G**oogle **C**ompute **E**ngine (**GCE**), you will need to do the following:\n\n<br>\n\n```python\n# The name you gave to the TPU to use\nTPU_WORKER = 'my-tpu-name'\n\n# or you can also specify the grpc path directly\n# TPU_WORKER = 'grpc://xxx.xxx.xxx.xxx:8470'\n\n# The zone you chose when you created the TPU to use on GCP.\nZONE = 'us-east1-b'\n\n# The name of the GCP project where you created the TPU to use on GCP.\nPROJECT = 'my-tpu-project'\n\ntpu = tf.distribute.cluster_resolver.TPUClusterResolver(tpu=TPU_WORKER, zone=ZONE, project=PROJECT)\n```\n\n<div class=\"alert alert-block alert-danger\" style=\"margin: 2em; line-height: 1.7em; font-family: Verdana;\">\n    <b style=\"font-size: 16px;\">🛑 &nbsp; WARNING:</b><br><br>- Although the Tensorflow documentation says it is the <b>project name</b> that should be provided for the argument <b><code>`project`</code></b>, it is actually the <b>Project ID</b>, that you should provide. This can be found on the GCP project dashboard page.<br>\n</div>\n\n<div class=\"alert alert-block alert-info\" style=\"margin: 2em; line-height: 1.7em; font-family: Verdana;\">\n    <b style=\"font-size: 16px;\">📖 &nbsp; REFERENCES:</b><br><br>\n    - <a href=\"https://www.tensorflow.org/guide/tpu#tpu_initialization\"><b>Guide - Use TPUs</b></a><br>\n    - <a href=\"https://www.tensorflow.org/api_docs/python/tf/distribute/cluster_resolver/TPUClusterResolver\"><b>Doc - TPUClusterResolver</b></a><br>\n\n</div>","metadata":{}},{"cell_type":"code","source":"print(f\"\\n... ACCELERATOR SETUP STARTING ...\\n\")\n\n# Detect hardware, return appropriate distribution strategy\ntry:\n    # TPU detection. No parameters necessary if TPU_NAME environment variable is set. On Kaggle this is always the case.\n    TPU = tf.distribute.cluster_resolver.TPUClusterResolver()  \nexcept ValueError:\n    TPU = None\n\nif TPU:\n    print(f\"\\n... RUNNING ON TPU - {TPU.master()}...\")\n    tf.config.experimental_connect_to_cluster(TPU)\n    tf.tpu.experimental.initialize_tpu_system(TPU)\n    strategy = tf.distribute.experimental.TPUStrategy(TPU)\nelse:\n    print(f\"\\n... RUNNING ON CPU/GPU ...\")\n    # Yield the default distribution strategy in Tensorflow\n    #   --> Works on CPU and single GPU.\n    strategy = tf.distribute.get_strategy()\n    # tf.config.experimental.set_memory_growth(tf.config.list_physical_devices('GPU')[0], True)\n\n# What Is a Replica?\n#    --> A single Cloud TPU device consists of FOUR chips, each of which has TWO TPU cores. \n#    --> Therefore, for efficient utilization of Cloud TPU, a program should make use of each of the EIGHT (4x2) cores. \n#    --> Each replica is essentially a copy of the training graph that is run on each core and \n#        trains a mini-batch containing 1/8th of the overall batch size\nN_REPLICAS = strategy.num_replicas_in_sync\n    \nprint(f\"... # OF REPLICAS: {N_REPLICAS} ...\\n\")\n\nprint(f\"\\n... ACCELERATOR SETUP COMPLTED ...\\n\")","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:22:47.451608Z","iopub.execute_input":"2023-04-19T02:22:47.452007Z","iopub.status.idle":"2023-04-19T02:22:47.467348Z","shell.execute_reply.started":"2023-04-19T02:22:47.451976Z","shell.execute_reply":"2023-04-19T02:22:47.465935Z"},"trusted":true},"execution_count":2,"outputs":[{"name":"stdout","text":"\n... ACCELERATOR SETUP STARTING ...\n\n\n... RUNNING ON CPU/GPU ...\n... # OF REPLICAS: 1 ...\n\n\n... ACCELERATOR SETUP COMPLTED ...\n\n","output_type":"stream"}]},{"cell_type":"markdown","source":"<br>\n\n<h3 style=\"font-family: Verdana; font-size: 20px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: #DA9186; background-color: #ffffff;\">2.2 COMPETITION DATA ACCESS</h3>\n\n---\n\nTPUs read data must be read directly from **G**oogle **C**loud **S**torage **(GCS)**. Kaggle provides a utility library – **`KaggleDatasets`** – which has a utility function **`.get_gcs_path`** that will allow us to access the location of our input datasets within **GCS**.<br><br>\n\n<div class=\"alert alert-block alert-info\" style=\"margin: 2em; line-height: 1.7em; font-family: Verdana;\">\n    <b style=\"font-size: 16px;\">📌 &nbsp; TIPS:</b><br><br>- If you have multiple datasets attached to the notebook, you should pass the name of a specific dataset to the <b><code>`get_gcs_path()`</code></b> function. <i>In our case, the name of the dataset is the name of the directory the dataset is mounted within.</i><br><br>\n</div>","metadata":{}},{"cell_type":"code","source":"print(\"\\n... DATA ACCESS SETUP STARTED ...\\n\")\n\n# Root folder definitions\nINPUT_DIR = \"/kaggle/input\"\nWORKING_DIR = \"/kaggle/working\"\n\nif TPU:\n    save_locally = tf.saved_model.SaveOptions(experimental_io_device='/job:localhost')\n    load_locally = tf.saved_model.LoadOptions(experimental_io_device='/job:localhost')\nelse:\n    save_locally = None\n    load_locally = None\n\nprint(\"\\n\\n... DATASETS LOADED ...\")\nfor x in os.listdir(INPUT_DIR): print(f\"\\t--> {x}\")\n    \nprint(\"\\n\\n... DATA ACCESS SETUP COMPLETED ...\\n\")","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:22:47.468738Z","iopub.execute_input":"2023-04-19T02:22:47.469101Z","iopub.status.idle":"2023-04-19T02:22:47.478327Z","shell.execute_reply.started":"2023-04-19T02:22:47.469059Z","shell.execute_reply":"2023-04-19T02:22:47.47697Z"},"trusted":true},"execution_count":3,"outputs":[{"name":"stdout","text":"\n... DATA ACCESS SETUP STARTED ...\n\n\n\n... DATASETS LOADED ...\n\t--> memotion-dataset-7k\n\t--> imagenetsketch\n\t--> pixiv-popular-illustrations\n\t--> caltech256\n\t--> toy-car-dataset-lear\n\t--> objectnet-1-of-10\n\t--> imagenetmini-1000\n\t--> food-recognition-2022\n\t--> the-met-dataset\n\t--> shopee-product-matching\n\t--> google-universal-image-embedding\n\t--> landmark-recognition-2021\n\t--> best-artworks-of-all-time\n\t--> imaterialist-fashion-2020-fgvc7\n\t--> guie-toys-dataset\n\t--> furniture-images-dataset\n\t--> the-car-connection-picture-dataset\n\n\n... DATA ACCESS SETUP COMPLETED ...\n\n","output_type":"stream"}]},{"cell_type":"markdown","source":"<br>\n\n<h3 style=\"font-family: Verdana; font-size: 20px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: #DA9186; background-color: #ffffff;\">2.3 LEVERAGING XLA OPTIMIZATIONS</h3>\n\n---\n\n\n**XLA** (Accelerated Linear Algebra) is a domain-specific compiler for linear algebra that can accelerate TensorFlow models with potentially no source code changes. **The results are improvements in speed and memory usage**.\n\n<br>\n\nWhen a TensorFlow program is run, all of the operations are executed individually by the TensorFlow executor. Each TensorFlow operation has a precompiled GPU/TPU kernel implementation that the executor dispatches to.\n\nXLA provides us with an alternative mode of running models: it compiles the TensorFlow graph into a sequence of computation kernels generated specifically for the given model. Because these kernels are unique to the model, they can exploit model-specific information for optimization.<br><br>\n\n<div class=\"alert alert-block alert-danger\" style=\"margin: 2em; line-height: 1.7em; font-family: Verdana;\">\n    <b style=\"font-size: 16px;\">🛑 &nbsp; WARNING:</b><br><br>- XLA can not currently compile functions where dimensions are not inferrable: that is, if it's not possible to infer the dimensions of all tensors without running the entire computation<br>\n</div>\n\n<div class=\"alert alert-block alert-info\" style=\"margin: 2em; line-height: 1.7em; font-family: Verdana;\">\n    <b style=\"font-size: 16px;\">📌 &nbsp; NOTE:</b><br><br>- XLA compilation is only applied to code that is compiled into a graph (in <b>TF2</b> that's only a code inside <b><code>tf.function</code></b>).<br>- The <b><code>jit_compile</code></b> API has must-compile semantics, i.e. either the entire function is compiled with XLA, or an <b><code>errors.InvalidArgumentError</code></b> exception is thrown)\n</div>\n\n<div class=\"alert alert-block alert-info\" style=\"margin: 2em; line-height: 1.7em; font-family: Verdana;\">\n    <b style=\"font-size: 16px;\">📖 &nbsp; REFERENCE:</b><br><br>    - <a href=\"https://www.tensorflow.org/xla\"><b>XLA: Optimizing Compiler for Machine Learning</b></a><br>\n</div>","metadata":{}},{"cell_type":"code","source":"print(f\"\\n... XLA OPTIMIZATIONS STARTING ...\\n\")\n\nprint(f\"\\n... CONFIGURE JIT (JUST IN TIME) COMPILATION ...\\n\")\n# enable XLA optmizations (10% speedup when using @tf.function calls)\ntf.config.optimizer.set_jit(True)\n\nprint(f\"\\n... XLA OPTIMIZATIONS COMPLETED ...\\n\")","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:22:47.481816Z","iopub.execute_input":"2023-04-19T02:22:47.482235Z","iopub.status.idle":"2023-04-19T02:22:47.49138Z","shell.execute_reply.started":"2023-04-19T02:22:47.4822Z","shell.execute_reply":"2023-04-19T02:22:47.490115Z"},"trusted":true},"execution_count":4,"outputs":[{"name":"stdout","text":"\n... XLA OPTIMIZATIONS STARTING ...\n\n\n... CONFIGURE JIT (JUST IN TIME) COMPILATION ...\n\n\n... XLA OPTIMIZATIONS COMPLETED ...\n\n","output_type":"stream"}]},{"cell_type":"markdown","source":"<br>\n\n<h3 style=\"font-family: Verdana; font-size: 20px; font-style: normal; font-weight: normal; text-decoration: none; text-transform: none; letter-spacing: 2px; color: #DA9186; background-color: #ffffff;\">2.4 FILE PATH AND METADATA</h3>\n\n---\n","metadata":{}},{"cell_type":"code","source":"print(\"\\n... BASIC DATA SETUP STARTING ...\\n\\n\")\ndataset_dir_map = {_ds:os.path.join(INPUT_DIR, _ds) for _ds in os.listdir(INPUT_DIR) if \"universal-image\" not in _ds}\nfor k,v in dataset_dir_map.items(): print(f\"{k:>40} --> {v}\")\n\n\nprint(\"\\n... BASIC DATA SETUP FINISHED ...\\n\\n\")","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:22:47.492837Z","iopub.execute_input":"2023-04-19T02:22:47.493906Z","iopub.status.idle":"2023-04-19T02:22:47.502948Z","shell.execute_reply.started":"2023-04-19T02:22:47.49386Z","shell.execute_reply":"2023-04-19T02:22:47.501981Z"},"trusted":true},"execution_count":5,"outputs":[{"name":"stdout","text":"\n... BASIC DATA SETUP STARTING ...\n\n\n                     memotion-dataset-7k --> /kaggle/input/memotion-dataset-7k\n                          imagenetsketch --> /kaggle/input/imagenetsketch\n             pixiv-popular-illustrations --> /kaggle/input/pixiv-popular-illustrations\n                              caltech256 --> /kaggle/input/caltech256\n                    toy-car-dataset-lear --> /kaggle/input/toy-car-dataset-lear\n                       objectnet-1-of-10 --> /kaggle/input/objectnet-1-of-10\n                       imagenetmini-1000 --> /kaggle/input/imagenetmini-1000\n                   food-recognition-2022 --> /kaggle/input/food-recognition-2022\n                         the-met-dataset --> /kaggle/input/the-met-dataset\n                 shopee-product-matching --> /kaggle/input/shopee-product-matching\n               landmark-recognition-2021 --> /kaggle/input/landmark-recognition-2021\n               best-artworks-of-all-time --> /kaggle/input/best-artworks-of-all-time\n         imaterialist-fashion-2020-fgvc7 --> /kaggle/input/imaterialist-fashion-2020-fgvc7\n                       guie-toys-dataset --> /kaggle/input/guie-toys-dataset\n                furniture-images-dataset --> /kaggle/input/furniture-images-dataset\n      the-car-connection-picture-dataset --> /kaggle/input/the-car-connection-picture-dataset\n\n... BASIC DATA SETUP FINISHED ...\n\n\n","output_type":"stream"}]},{"cell_type":"markdown","source":"**HELPERS**","metadata":{}},{"cell_type":"code","source":"def load_json_to_dict(json_path):\n    \"\"\" tbd \"\"\"\n    with open(json_path) as json_file:\n        data = json.load(json_file)\n    return data\n\ndef flatten_l_o_l(nested_list):\n    \"\"\" Flatten a list of lists \"\"\"\n    return [item for sublist in nested_list for item in sublist]\n\ndef print_ln(symbol=\"-\", line_len=110):\n    print(symbol*line_len)","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:22:47.504883Z","iopub.execute_input":"2023-04-19T02:22:47.505225Z","iopub.status.idle":"2023-04-19T02:22:47.513424Z","shell.execute_reply.started":"2023-04-19T02:22:47.505193Z","shell.execute_reply":"2023-04-19T02:22:47.512616Z"},"trusted":true},"execution_count":6,"outputs":[]},{"cell_type":"markdown","source":"<br>\n\n**INITIALIZE MASTER DATAFRAME**","metadata":{}},{"cell_type":"code","source":"master_df = pd.DataFrame({\n    \"img_path\":[],\n    \"supercls\":[],\n    \"cls\":[],\n    \"dataset\":[],\n    \"val_only\":[],\n})\nmaster_df","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:22:47.51486Z","iopub.execute_input":"2023-04-19T02:22:47.515482Z","iopub.status.idle":"2023-04-19T02:22:47.548348Z","shell.execute_reply.started":"2023-04-19T02:22:47.515449Z","shell.execute_reply":"2023-04-19T02:22:47.547203Z"},"trusted":true},"execution_count":7,"outputs":[{"execution_count":7,"output_type":"execute_result","data":{"text/plain":"Empty DataFrame\nColumns: [img_path, supercls, cls, dataset, val_only]\nIndex: []","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>img_path</th>\n      <th>supercls</th>\n      <th>cls</th>\n      <th>dataset</th>\n      <th>val_only</th>\n    </tr>\n  </thead>\n  <tbody>\n  </tbody>\n</table>\n</div>"},"metadata":{}}]},{"cell_type":"markdown","source":"<br>\n\n**FASHION FROM IMATERIALIST 2020**\n* Take 5000","metadata":{}},{"cell_type":"code","source":"# Class mapping\nimaterialist_fashion_2020_class_map = load_json_to_dict(\"../input/imaterialist-fashion-2020-fgvc7/label_descriptions.json\")\nimaterialist_fashion_2020_class_map = {_cls[\"id\"]:_cls[\"name\"] for _cls in imaterialist_fashion_2020_class_map[\"categories\"]}\n\n# How many to take\nimaterialist_n = 5_000\n\n# Make temporary dataframe\ntmp_df = pd.read_csv(os.path.join(INPUT_DIR, \"imaterialist-fashion-2020-fgvc7\", \"train.csv\"))\ntmp_df[\"img_path\"] = \"../input/imaterialist-fashion-2020-fgvc7/train/\"+tmp_df[\"ImageId\"]+\".jpg\"\ntmp_df[\"cls\"] = tmp_df[\"ClassId\"].map(imaterialist_fashion_2020_class_map)\n\ntmp_df[\"cls_cnt\"] = tmp_df.groupby(\"cls\")[\"cls\"].transform(\"count\")\ntmp_df = tmp_df.sort_values(by=\"cls_cnt\", ascending=False).reset_index(drop=True).iloc[:100000]\ntmp_df = tmp_df.sample(imaterialist_n).reset_index(drop=True)\n\ntmp_df = tmp_df[[\"img_path\", \"cls\"]]\ntmp_df[\"supercls\"] = \"apparel & accessories\"\ntmp_df[\"dataset\"] = \"imaterialist-fashion-2020-fgvc7\"\ntmp_df[\"val_only\"] = False\n\n# Update master dataframe\nmaster_df = pd.concat([master_df, tmp_df], ignore_index=True)\nmaster_df","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:22:47.550067Z","iopub.execute_input":"2023-04-19T02:22:47.550594Z","iopub.status.idle":"2023-04-19T02:23:19.746524Z","shell.execute_reply.started":"2023-04-19T02:22:47.550546Z","shell.execute_reply":"2023-04-19T02:23:19.745234Z"},"trusted":true},"execution_count":8,"outputs":[{"execution_count":8,"output_type":"execute_result","data":{"text/plain":"                                               img_path  \\\n0     ../input/imaterialist-fashion-2020-fgvc7/train...   \n1     ../input/imaterialist-fashion-2020-fgvc7/train...   \n2     ../input/imaterialist-fashion-2020-fgvc7/train...   \n3     ../input/imaterialist-fashion-2020-fgvc7/train...   \n4     ../input/imaterialist-fashion-2020-fgvc7/train...   \n...                                                 ...   \n4995  ../input/imaterialist-fashion-2020-fgvc7/train...   \n4996  ../input/imaterialist-fashion-2020-fgvc7/train...   \n4997  ../input/imaterialist-fashion-2020-fgvc7/train...   \n4998  ../input/imaterialist-fashion-2020-fgvc7/train...   \n4999  ../input/imaterialist-fashion-2020-fgvc7/train...   \n\n                   supercls     cls                          dataset  val_only  \n0     apparel & accessories  sleeve  imaterialist-fashion-2020-fgvc7       0.0  \n1     apparel & accessories  sleeve  imaterialist-fashion-2020-fgvc7       0.0  \n2     apparel & accessories  sleeve  imaterialist-fashion-2020-fgvc7       0.0  \n3     apparel & accessories    shoe  imaterialist-fashion-2020-fgvc7       0.0  \n4     apparel & accessories  sleeve  imaterialist-fashion-2020-fgvc7       0.0  \n...                     ...     ...                              ...       ...  \n4995  apparel & accessories  sleeve  imaterialist-fashion-2020-fgvc7       0.0  \n4996  apparel & accessories    shoe  imaterialist-fashion-2020-fgvc7       0.0  \n4997  apparel & accessories  sleeve  imaterialist-fashion-2020-fgvc7       0.0  \n4998  apparel & accessories  sleeve  imaterialist-fashion-2020-fgvc7       0.0  \n4999  apparel & accessories  sleeve  imaterialist-fashion-2020-fgvc7       0.0  \n\n[5000 rows x 5 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>img_path</th>\n      <th>supercls</th>\n      <th>cls</th>\n      <th>dataset</th>\n      <th>val_only</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>shoe</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>4995</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>4996</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>shoe</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>4997</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>4998</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>4999</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n  </tbody>\n</table>\n<p>5000 rows × 5 columns</p>\n</div>"},"metadata":{}}]},{"cell_type":"markdown","source":"<br>\n\n**FURNITURE IMAGE DATASET**\n* Take 5000","metadata":{}},{"cell_type":"code","source":"# How many to take\nfurniture_n = 5_000\n\n# Make temporary dataframe\ntmp_df = pd.read_csv(os.path.join(INPUT_DIR, \"furniture-images-dataset\", \"furniture_data_img.csv\"))\ntmp_df[\"img_path\"] = \"/kaggle/input/furniture-images-dataset/furniture_images\"+ tmp_df[\"Image_File\"]\ntmp_df[\"cls\"] = tmp_df[\"Furniture_Type\"]\ntmp_df[\"cls_cnt\"] = tmp_df.groupby(\"cls\")[\"cls\"].transform(\"count\")\ntmp_df = tmp_df.sort_values(by=\"cls_cnt\", ascending=False)\ntmp_df = tmp_df.head(furniture_n).sample(imaterialist_n).reset_index(drop=True)\n\ntmp_df = tmp_df[[\"img_path\", \"cls\"]]\ntmp_df[\"supercls\"] = \"furniture\"\ntmp_df[\"dataset\"] = \"furniture-images-dataset\"\ntmp_df[\"val_only\"] = False\n\n# Update master dataframe\nmaster_df = pd.concat([master_df, tmp_df], ignore_index=True)\nmaster_df","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:23:19.74795Z","iopub.execute_input":"2023-04-19T02:23:19.748623Z","iopub.status.idle":"2023-04-19T02:23:19.817056Z","shell.execute_reply.started":"2023-04-19T02:23:19.748587Z","shell.execute_reply":"2023-04-19T02:23:19.816172Z"},"trusted":true},"execution_count":9,"outputs":[{"execution_count":9,"output_type":"execute_result","data":{"text/plain":"                                               img_path  \\\n0     ../input/imaterialist-fashion-2020-fgvc7/train...   \n1     ../input/imaterialist-fashion-2020-fgvc7/train...   \n2     ../input/imaterialist-fashion-2020-fgvc7/train...   \n3     ../input/imaterialist-fashion-2020-fgvc7/train...   \n4     ../input/imaterialist-fashion-2020-fgvc7/train...   \n...                                                 ...   \n9995  /kaggle/input/furniture-images-dataset/furnitu...   \n9996  /kaggle/input/furniture-images-dataset/furnitu...   \n9997  /kaggle/input/furniture-images-dataset/furnitu...   \n9998  /kaggle/input/furniture-images-dataset/furnitu...   \n9999  /kaggle/input/furniture-images-dataset/furnitu...   \n\n                   supercls                 cls  \\\n0     apparel & accessories              sleeve   \n1     apparel & accessories              sleeve   \n2     apparel & accessories              sleeve   \n3     apparel & accessories                shoe   \n4     apparel & accessories              sleeve   \n...                     ...                 ...   \n9995              furniture  Bed / bedroom item   \n9996              furniture       Table / chair   \n9997              furniture       Table / chair   \n9998              furniture       Table / chair   \n9999              furniture       Table / chair   \n\n                              dataset  val_only  \n0     imaterialist-fashion-2020-fgvc7       0.0  \n1     imaterialist-fashion-2020-fgvc7       0.0  \n2     imaterialist-fashion-2020-fgvc7       0.0  \n3     imaterialist-fashion-2020-fgvc7       0.0  \n4     imaterialist-fashion-2020-fgvc7       0.0  \n...                               ...       ...  \n9995         furniture-images-dataset       0.0  \n9996         furniture-images-dataset       0.0  \n9997         furniture-images-dataset       0.0  \n9998         furniture-images-dataset       0.0  \n9999         furniture-images-dataset       0.0  \n\n[10000 rows x 5 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>img_path</th>\n      <th>supercls</th>\n      <th>cls</th>\n      <th>dataset</th>\n      <th>val_only</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>shoe</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>9995</th>\n      <td>/kaggle/input/furniture-images-dataset/furnitu...</td>\n      <td>furniture</td>\n      <td>Bed / bedroom item</td>\n      <td>furniture-images-dataset</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>9996</th>\n      <td>/kaggle/input/furniture-images-dataset/furnitu...</td>\n      <td>furniture</td>\n      <td>Table / chair</td>\n      <td>furniture-images-dataset</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>9997</th>\n      <td>/kaggle/input/furniture-images-dataset/furnitu...</td>\n      <td>furniture</td>\n      <td>Table / chair</td>\n      <td>furniture-images-dataset</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>9998</th>\n      <td>/kaggle/input/furniture-images-dataset/furnitu...</td>\n      <td>furniture</td>\n      <td>Table / chair</td>\n      <td>furniture-images-dataset</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>9999</th>\n      <td>/kaggle/input/furniture-images-dataset/furnitu...</td>\n      <td>furniture</td>\n      <td>Table / chair</td>\n      <td>furniture-images-dataset</td>\n      <td>0.0</td>\n    </tr>\n  </tbody>\n</table>\n<p>10000 rows × 5 columns</p>\n</div>"},"metadata":{}}]},{"cell_type":"markdown","source":"<br>\n\n**SHOPEE PRODUCT DATASET**\n* Take 2500","metadata":{}},{"cell_type":"code","source":"# How many to take\nshopee_n = 2_500\n\n# Make temporary dataframe\ntmp_df = pd.read_csv(os.path.join(INPUT_DIR, \"shopee-product-matching\", \"train.csv\"))\ncnt_map = tmp_df.label_group.value_counts().to_dict()\ntmp_df[\"lbl_group_cnt\"] = tmp_df.label_group.map(cnt_map)\ntmp_df = tmp_df.sort_values(by=[\"lbl_group_cnt\", \"label_group\"], ascending=False).reset_index(drop=True).head(shopee_n)\ntmp_df[\"img_path\"] = \"/kaggle/input/shopee-product-matching/train_images/\"+ tmp_df[\"image\"]\n\ntmp_df[\"cls\"] = tmp_df[\"label_group\"]\ntmp_df = tmp_df[[\"img_path\", \"cls\"]]\ntmp_df[\"supercls\"] = \"packaged goods\"\ntmp_df[\"dataset\"] = \"shopee-product-matching\"\ntmp_df[\"val_only\"] = False\n\n# Update master dataframe\nmaster_df = pd.concat([master_df, tmp_df], ignore_index=True)\nmaster_df","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:23:19.820765Z","iopub.execute_input":"2023-04-19T02:23:19.821453Z","iopub.status.idle":"2023-04-19T02:23:20.062405Z","shell.execute_reply.started":"2023-04-19T02:23:19.821414Z","shell.execute_reply":"2023-04-19T02:23:20.061294Z"},"trusted":true},"execution_count":10,"outputs":[{"execution_count":10,"output_type":"execute_result","data":{"text/plain":"                                                img_path  \\\n0      ../input/imaterialist-fashion-2020-fgvc7/train...   \n1      ../input/imaterialist-fashion-2020-fgvc7/train...   \n2      ../input/imaterialist-fashion-2020-fgvc7/train...   \n3      ../input/imaterialist-fashion-2020-fgvc7/train...   \n4      ../input/imaterialist-fashion-2020-fgvc7/train...   \n...                                                  ...   \n12495  /kaggle/input/shopee-product-matching/train_im...   \n12496  /kaggle/input/shopee-product-matching/train_im...   \n12497  /kaggle/input/shopee-product-matching/train_im...   \n12498  /kaggle/input/shopee-product-matching/train_im...   \n12499  /kaggle/input/shopee-product-matching/train_im...   \n\n                    supercls         cls                          dataset  \\\n0      apparel & accessories      sleeve  imaterialist-fashion-2020-fgvc7   \n1      apparel & accessories      sleeve  imaterialist-fashion-2020-fgvc7   \n2      apparel & accessories      sleeve  imaterialist-fashion-2020-fgvc7   \n3      apparel & accessories        shoe  imaterialist-fashion-2020-fgvc7   \n4      apparel & accessories      sleeve  imaterialist-fashion-2020-fgvc7   \n...                      ...         ...                              ...   \n12495         packaged goods  2315452163          shopee-product-matching   \n12496         packaged goods  2315452163          shopee-product-matching   \n12497         packaged goods  2315452163          shopee-product-matching   \n12498         packaged goods  2315452163          shopee-product-matching   \n12499         packaged goods  2315452163          shopee-product-matching   \n\n       val_only  \n0           0.0  \n1           0.0  \n2           0.0  \n3           0.0  \n4           0.0  \n...         ...  \n12495       0.0  \n12496       0.0  \n12497       0.0  \n12498       0.0  \n12499       0.0  \n\n[12500 rows x 5 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>img_path</th>\n      <th>supercls</th>\n      <th>cls</th>\n      <th>dataset</th>\n      <th>val_only</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>shoe</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>12495</th>\n      <td>/kaggle/input/shopee-product-matching/train_im...</td>\n      <td>packaged goods</td>\n      <td>2315452163</td>\n      <td>shopee-product-matching</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>12496</th>\n      <td>/kaggle/input/shopee-product-matching/train_im...</td>\n      <td>packaged goods</td>\n      <td>2315452163</td>\n      <td>shopee-product-matching</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>12497</th>\n      <td>/kaggle/input/shopee-product-matching/train_im...</td>\n      <td>packaged goods</td>\n      <td>2315452163</td>\n      <td>shopee-product-matching</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>12498</th>\n      <td>/kaggle/input/shopee-product-matching/train_im...</td>\n      <td>packaged goods</td>\n      <td>2315452163</td>\n      <td>shopee-product-matching</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>12499</th>\n      <td>/kaggle/input/shopee-product-matching/train_im...</td>\n      <td>packaged goods</td>\n      <td>2315452163</td>\n      <td>shopee-product-matching</td>\n      <td>0.0</td>\n    </tr>\n  </tbody>\n</table>\n<p>12500 rows × 5 columns</p>\n</div>"},"metadata":{}}]},{"cell_type":"markdown","source":"<br>\n\n**CAR CONNECTION DATASET**\n* Take 5000","metadata":{}},{"cell_type":"code","source":"n_cc = 5000\n\ntmp_df = pd.DataFrame({\"img_path\":glob(\"/kaggle/input/the-car-connection-picture-dataset/*.jpg\")})\ntmp_df[\"cls\"] = tmp_df[\"img_path\"].progress_apply(lambda x: \"_\".join(x.rsplit(\"/\", 1)[-1].split(\"_\",2)[:2]))\n\ntmp_df[\"cls_cnt\"] = tmp_df.groupby(\"cls\")[\"cls\"].transform(\"count\")\ntmp_df = tmp_df.sort_values(by=\"cls_cnt\", ascending=False)\ntmp_df = tmp_df.head(n_cc).sample(n_cc).reset_index(drop=True)\ntmp_df = tmp_df[[\"img_path\", \"cls\"]]\n\ntmp_df[\"supercls\"] = \"cars\"\ntmp_df[\"dataset\"] = \"the-car-connectino-picture-dataset\"\ntmp_df[\"val_only\"] = False\ntmp_df\n\n# Update master dataframe\nmaster_df = pd.concat([master_df, tmp_df], ignore_index=True)\nmaster_df","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:23:20.063916Z","iopub.execute_input":"2023-04-19T02:23:20.064362Z","iopub.status.idle":"2023-04-19T02:23:29.834811Z","shell.execute_reply.started":"2023-04-19T02:23:20.064317Z","shell.execute_reply":"2023-04-19T02:23:29.833369Z"},"trusted":true},"execution_count":11,"outputs":[{"output_type":"display_data","data":{"text/plain":"  0%|          | 0/64467 [00:00<?, ?it/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"099b843cc30f4d2196d6bd6c8690561a"}},"metadata":{}},{"execution_count":11,"output_type":"execute_result","data":{"text/plain":"                                                img_path  \\\n0      ../input/imaterialist-fashion-2020-fgvc7/train...   \n1      ../input/imaterialist-fashion-2020-fgvc7/train...   \n2      ../input/imaterialist-fashion-2020-fgvc7/train...   \n3      ../input/imaterialist-fashion-2020-fgvc7/train...   \n4      ../input/imaterialist-fashion-2020-fgvc7/train...   \n...                                                  ...   \n17495  /kaggle/input/the-car-connection-picture-datas...   \n17496  /kaggle/input/the-car-connection-picture-datas...   \n17497  /kaggle/input/the-car-connection-picture-datas...   \n17498  /kaggle/input/the-car-connection-picture-datas...   \n17499  /kaggle/input/the-car-connection-picture-datas...   \n\n                    supercls          cls                             dataset  \\\n0      apparel & accessories       sleeve     imaterialist-fashion-2020-fgvc7   \n1      apparel & accessories       sleeve     imaterialist-fashion-2020-fgvc7   \n2      apparel & accessories       sleeve     imaterialist-fashion-2020-fgvc7   \n3      apparel & accessories         shoe     imaterialist-fashion-2020-fgvc7   \n4      apparel & accessories       sleeve     imaterialist-fashion-2020-fgvc7   \n...                      ...          ...                                 ...   \n17495                   cars  Ford_Ranger  the-car-connectino-picture-dataset   \n17496                   cars  Porsche_911  the-car-connectino-picture-dataset   \n17497                   cars  MINI_Cooper  the-car-connectino-picture-dataset   \n17498                   cars  MINI_Cooper  the-car-connectino-picture-dataset   \n17499                   cars  Ford_Ranger  the-car-connectino-picture-dataset   \n\n       val_only  \n0           0.0  \n1           0.0  \n2           0.0  \n3           0.0  \n4           0.0  \n...         ...  \n17495       0.0  \n17496       0.0  \n17497       0.0  \n17498       0.0  \n17499       0.0  \n\n[17500 rows x 5 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>img_path</th>\n      <th>supercls</th>\n      <th>cls</th>\n      <th>dataset</th>\n      <th>val_only</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>shoe</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>17495</th>\n      <td>/kaggle/input/the-car-connection-picture-datas...</td>\n      <td>cars</td>\n      <td>Ford_Ranger</td>\n      <td>the-car-connectino-picture-dataset</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>17496</th>\n      <td>/kaggle/input/the-car-connection-picture-datas...</td>\n      <td>cars</td>\n      <td>Porsche_911</td>\n      <td>the-car-connectino-picture-dataset</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>17497</th>\n      <td>/kaggle/input/the-car-connection-picture-datas...</td>\n      <td>cars</td>\n      <td>MINI_Cooper</td>\n      <td>the-car-connectino-picture-dataset</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>17498</th>\n      <td>/kaggle/input/the-car-connection-picture-datas...</td>\n      <td>cars</td>\n      <td>MINI_Cooper</td>\n      <td>the-car-connectino-picture-dataset</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>17499</th>\n      <td>/kaggle/input/the-car-connection-picture-datas...</td>\n      <td>cars</td>\n      <td>Ford_Ranger</td>\n      <td>the-car-connectino-picture-dataset</td>\n      <td>0.0</td>\n    </tr>\n  </tbody>\n</table>\n<p>17500 rows × 5 columns</p>\n</div>"},"metadata":{}}]},{"cell_type":"markdown","source":"<br>\n\n**CALTECH-256**\n* Take 10_000","metadata":{}},{"cell_type":"code","source":"n_caltech = 10_000\ntmp_df = pd.DataFrame({\"img_path\":tf.io.gfile.glob(os.path.join(INPUT_DIR, \"caltech256\", \"**\", \"**\", \"*.jpg\"))})\ntmp_df[\"cls\"] = tmp_df[\"img_path\"].apply(lambda x: x.rsplit(\"/\", 2)[1][4:])\n\ntmp_df[\"cls_cnt\"] = tmp_df.groupby(\"cls\")[\"cls\"].transform(\"count\")\ntmp_df = tmp_df.sort_values(by=\"cls_cnt\", ascending=False)\ntmp_df = tmp_df.head(n_caltech).sample(n_caltech).reset_index(drop=True)\ntmp_df = tmp_df[[\"img_path\", \"cls\"]]\n\ntmp_df[\"supercls\"] = \"other\"\ntmp_df[\"dataset\"] = \"caltech256\"\ntmp_df[\"val_only\"] = False\n\n# Update master dataframe\nmaster_df = pd.concat([master_df, tmp_df], ignore_index=True)\nmaster_df","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:23:29.836428Z","iopub.execute_input":"2023-04-19T02:23:29.836917Z","iopub.status.idle":"2023-04-19T02:23:33.876911Z","shell.execute_reply.started":"2023-04-19T02:23:29.836885Z","shell.execute_reply":"2023-04-19T02:23:33.87561Z"},"trusted":true},"execution_count":12,"outputs":[{"execution_count":12,"output_type":"execute_result","data":{"text/plain":"                                                img_path  \\\n0      ../input/imaterialist-fashion-2020-fgvc7/train...   \n1      ../input/imaterialist-fashion-2020-fgvc7/train...   \n2      ../input/imaterialist-fashion-2020-fgvc7/train...   \n3      ../input/imaterialist-fashion-2020-fgvc7/train...   \n4      ../input/imaterialist-fashion-2020-fgvc7/train...   \n...                                                  ...   \n27495  /kaggle/input/caltech256/256_ObjectCategories/...   \n27496  /kaggle/input/caltech256/256_ObjectCategories/...   \n27497  /kaggle/input/caltech256/256_ObjectCategories/...   \n27498  /kaggle/input/caltech256/256_ObjectCategories/...   \n27499  /kaggle/input/caltech256/256_ObjectCategories/...   \n\n                    supercls             cls                          dataset  \\\n0      apparel & accessories          sleeve  imaterialist-fashion-2020-fgvc7   \n1      apparel & accessories          sleeve  imaterialist-fashion-2020-fgvc7   \n2      apparel & accessories          sleeve  imaterialist-fashion-2020-fgvc7   \n3      apparel & accessories            shoe  imaterialist-fashion-2020-fgvc7   \n4      apparel & accessories          sleeve  imaterialist-fashion-2020-fgvc7   \n...                      ...             ...                              ...   \n27495                  other  faces-easy-101                       caltech256   \n27496                  other         minaret                       caltech256   \n27497                  other         gorilla                       caltech256   \n27498                  other           horse                       caltech256   \n27499                  other      bonsai-101                       caltech256   \n\n       val_only  \n0           0.0  \n1           0.0  \n2           0.0  \n3           0.0  \n4           0.0  \n...         ...  \n27495       0.0  \n27496       0.0  \n27497       0.0  \n27498       0.0  \n27499       0.0  \n\n[27500 rows x 5 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>img_path</th>\n      <th>supercls</th>\n      <th>cls</th>\n      <th>dataset</th>\n      <th>val_only</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>shoe</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>27495</th>\n      <td>/kaggle/input/caltech256/256_ObjectCategories/...</td>\n      <td>other</td>\n      <td>faces-easy-101</td>\n      <td>caltech256</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>27496</th>\n      <td>/kaggle/input/caltech256/256_ObjectCategories/...</td>\n      <td>other</td>\n      <td>minaret</td>\n      <td>caltech256</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>27497</th>\n      <td>/kaggle/input/caltech256/256_ObjectCategories/...</td>\n      <td>other</td>\n      <td>gorilla</td>\n      <td>caltech256</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>27498</th>\n      <td>/kaggle/input/caltech256/256_ObjectCategories/...</td>\n      <td>other</td>\n      <td>horse</td>\n      <td>caltech256</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>27499</th>\n      <td>/kaggle/input/caltech256/256_ObjectCategories/...</td>\n      <td>other</td>\n      <td>bonsai-101</td>\n      <td>caltech256</td>\n      <td>0.0</td>\n    </tr>\n  </tbody>\n</table>\n<p>27500 rows × 5 columns</p>\n</div>"},"metadata":{}}]},{"cell_type":"markdown","source":"<br>\n\n**Food Recognition 2022**\n* Take 5000","metadata":{}},{"cell_type":"code","source":"n_food = 5000\nfood_rec_meta = load_json_to_dict(\"../input/food-recognition-2022/raw_data/public_training_set_release_2.0/annotations.json\")\nfood_cat_map = {x[\"id\"]:x[\"name\"] for x in food_rec_meta[\"categories\"]}\nimage_id_map = {x[\"image_id\"]:food_cat_map[x[\"category_id\"]] for x in food_rec_meta[\"annotations\"]}\n\ntmp_df = pd.DataFrame({\"img_path\":tf.io.gfile.glob(os.path.join(INPUT_DIR, \"food-recognition-2022\", \"raw_data\", \"public_training_set_release_2.0\", \"images\", \"*.jpg\"))})\ntmp_df[\"cls\"]=tmp_df.img_path.progress_apply(lambda x: image_id_map[int(x.rsplit(\"/\", 1)[-1][:-4])])\n\ntmp_df[\"cls_cnt\"] = tmp_df.groupby(\"cls\")[\"cls\"].transform(\"count\")\ntmp_df = tmp_df.sort_values(by=\"cls_cnt\", ascending=False)\ntmp_df = tmp_df.head(n_food*2).sample(n_food).reset_index(drop=True)\ntmp_df = tmp_df[[\"img_path\", \"cls\"]]\n\ntmp_df[\"supercls\"] = \"dishes\"\ntmp_df[\"dataset\"] = \"food-recognition-2022\"\ntmp_df[\"val_only\"] = False\n\n# Update master dataframe\nmaster_df = pd.concat([master_df, tmp_df], ignore_index=True)\nmaster_df","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:23:33.878717Z","iopub.execute_input":"2023-04-19T02:23:33.880141Z","iopub.status.idle":"2023-04-19T02:23:55.462238Z","shell.execute_reply.started":"2023-04-19T02:23:33.879978Z","shell.execute_reply":"2023-04-19T02:23:55.46067Z"},"trusted":true},"execution_count":13,"outputs":[{"output_type":"display_data","data":{"text/plain":"  0%|          | 0/39962 [00:00<?, ?it/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"f77fa7d9f5544ee7bc52cf14f16f3ac8"}},"metadata":{}},{"execution_count":13,"output_type":"execute_result","data":{"text/plain":"                                                img_path  \\\n0      ../input/imaterialist-fashion-2020-fgvc7/train...   \n1      ../input/imaterialist-fashion-2020-fgvc7/train...   \n2      ../input/imaterialist-fashion-2020-fgvc7/train...   \n3      ../input/imaterialist-fashion-2020-fgvc7/train...   \n4      ../input/imaterialist-fashion-2020-fgvc7/train...   \n...                                                  ...   \n32495  /kaggle/input/food-recognition-2022/raw_data/p...   \n32496  /kaggle/input/food-recognition-2022/raw_data/p...   \n32497  /kaggle/input/food-recognition-2022/raw_data/p...   \n32498  /kaggle/input/food-recognition-2022/raw_data/p...   \n32499  /kaggle/input/food-recognition-2022/raw_data/p...   \n\n                    supercls         cls                          dataset  \\\n0      apparel & accessories      sleeve  imaterialist-fashion-2020-fgvc7   \n1      apparel & accessories      sleeve  imaterialist-fashion-2020-fgvc7   \n2      apparel & accessories      sleeve  imaterialist-fashion-2020-fgvc7   \n3      apparel & accessories        shoe  imaterialist-fashion-2020-fgvc7   \n4      apparel & accessories      sleeve  imaterialist-fashion-2020-fgvc7   \n...                      ...         ...                              ...   \n32495                 dishes    wine-red            food-recognition-2022   \n32496                 dishes    wine-red            food-recognition-2022   \n32497                 dishes      butter            food-recognition-2022   \n32498                 dishes       water            food-recognition-2022   \n32499                 dishes  tomato-raw            food-recognition-2022   \n\n       val_only  \n0           0.0  \n1           0.0  \n2           0.0  \n3           0.0  \n4           0.0  \n...         ...  \n32495       0.0  \n32496       0.0  \n32497       0.0  \n32498       0.0  \n32499       0.0  \n\n[32500 rows x 5 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>img_path</th>\n      <th>supercls</th>\n      <th>cls</th>\n      <th>dataset</th>\n      <th>val_only</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>shoe</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>32495</th>\n      <td>/kaggle/input/food-recognition-2022/raw_data/p...</td>\n      <td>dishes</td>\n      <td>wine-red</td>\n      <td>food-recognition-2022</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>32496</th>\n      <td>/kaggle/input/food-recognition-2022/raw_data/p...</td>\n      <td>dishes</td>\n      <td>wine-red</td>\n      <td>food-recognition-2022</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>32497</th>\n      <td>/kaggle/input/food-recognition-2022/raw_data/p...</td>\n      <td>dishes</td>\n      <td>butter</td>\n      <td>food-recognition-2022</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>32498</th>\n      <td>/kaggle/input/food-recognition-2022/raw_data/p...</td>\n      <td>dishes</td>\n      <td>water</td>\n      <td>food-recognition-2022</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>32499</th>\n      <td>/kaggle/input/food-recognition-2022/raw_data/p...</td>\n      <td>dishes</td>\n      <td>tomato-raw</td>\n      <td>food-recognition-2022</td>\n      <td>0.0</td>\n    </tr>\n  </tbody>\n</table>\n<p>32500 rows × 5 columns</p>\n</div>"},"metadata":{}}]},{"cell_type":"markdown","source":"<br>\n\n**Google Landmarks Dataset**\n* Take 5000","metadata":{}},{"cell_type":"code","source":"n_landmark = 5_000\ntmp_df = pd.read_csv(os.path.join(INPUT_DIR, \"landmark-recognition-2021\", \"train.csv\"))\ntmp_df[\"landmark_cnt\"] = tmp_df.groupby(\"landmark_id\")[\"landmark_id\"].transform(\"count\")\ntmp_df = tmp_df.sort_values(by=\"landmark_cnt\", ascending=False)\ntmp_df = tmp_df.reset_index(drop=True)\ntmp_df = tmp_df.head(100_000)\ntmp_df = tmp_df.sample(n_landmark).reset_index(drop=True)\ntmp_df[\"img_path\"] = \"/kaggle/input/landmark-recognition-2021/train/\"+\\\n                     tmp_df[\"id\"].str[0]+\"/\"+tmp_df[\"id\"].str[1]+\"/\"+tmp_df[\"id\"].str[2]\\\n                     +\"/\"+tmp_df[\"id\"]+\".jpg\"\ntmp_df[\"cls\"] = \"landmark_\"+tmp_df[\"landmark_id\"].astype(str)\ntmp_df = tmp_df[[\"img_path\", \"cls\"]]\ntmp_df[\"supercls\"] = \"landmarks\"\ntmp_df[\"dataset\"] = \"landmark-recognition-2021\"\ntmp_df[\"val_only\"] = False\n\n# Update master dataframe\nmaster_df = pd.concat([master_df, tmp_df], ignore_index=True)\nmaster_df","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:23:55.464082Z","iopub.execute_input":"2023-04-19T02:23:55.464758Z","iopub.status.idle":"2023-04-19T02:23:57.564671Z","shell.execute_reply.started":"2023-04-19T02:23:55.464715Z","shell.execute_reply":"2023-04-19T02:23:57.563452Z"},"trusted":true},"execution_count":14,"outputs":[{"execution_count":14,"output_type":"execute_result","data":{"text/plain":"                                                img_path  \\\n0      ../input/imaterialist-fashion-2020-fgvc7/train...   \n1      ../input/imaterialist-fashion-2020-fgvc7/train...   \n2      ../input/imaterialist-fashion-2020-fgvc7/train...   \n3      ../input/imaterialist-fashion-2020-fgvc7/train...   \n4      ../input/imaterialist-fashion-2020-fgvc7/train...   \n...                                                  ...   \n37495  /kaggle/input/landmark-recognition-2021/train/...   \n37496  /kaggle/input/landmark-recognition-2021/train/...   \n37497  /kaggle/input/landmark-recognition-2021/train/...   \n37498  /kaggle/input/landmark-recognition-2021/train/...   \n37499  /kaggle/input/landmark-recognition-2021/train/...   \n\n                    supercls              cls  \\\n0      apparel & accessories           sleeve   \n1      apparel & accessories           sleeve   \n2      apparel & accessories           sleeve   \n3      apparel & accessories             shoe   \n4      apparel & accessories           sleeve   \n...                      ...              ...   \n37495              landmarks  landmark_177870   \n37496              landmarks  landmark_102850   \n37497              landmarks  landmark_168098   \n37498              landmarks  landmark_102850   \n37499              landmarks  landmark_138982   \n\n                               dataset  val_only  \n0      imaterialist-fashion-2020-fgvc7       0.0  \n1      imaterialist-fashion-2020-fgvc7       0.0  \n2      imaterialist-fashion-2020-fgvc7       0.0  \n3      imaterialist-fashion-2020-fgvc7       0.0  \n4      imaterialist-fashion-2020-fgvc7       0.0  \n...                                ...       ...  \n37495        landmark-recognition-2021       0.0  \n37496        landmark-recognition-2021       0.0  \n37497        landmark-recognition-2021       0.0  \n37498        landmark-recognition-2021       0.0  \n37499        landmark-recognition-2021       0.0  \n\n[37500 rows x 5 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>img_path</th>\n      <th>supercls</th>\n      <th>cls</th>\n      <th>dataset</th>\n      <th>val_only</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>shoe</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>37495</th>\n      <td>/kaggle/input/landmark-recognition-2021/train/...</td>\n      <td>landmarks</td>\n      <td>landmark_177870</td>\n      <td>landmark-recognition-2021</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>37496</th>\n      <td>/kaggle/input/landmark-recognition-2021/train/...</td>\n      <td>landmarks</td>\n      <td>landmark_102850</td>\n      <td>landmark-recognition-2021</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>37497</th>\n      <td>/kaggle/input/landmark-recognition-2021/train/...</td>\n      <td>landmarks</td>\n      <td>landmark_168098</td>\n      <td>landmark-recognition-2021</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>37498</th>\n      <td>/kaggle/input/landmark-recognition-2021/train/...</td>\n      <td>landmarks</td>\n      <td>landmark_102850</td>\n      <td>landmark-recognition-2021</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>37499</th>\n      <td>/kaggle/input/landmark-recognition-2021/train/...</td>\n      <td>landmarks</td>\n      <td>landmark_138982</td>\n      <td>landmark-recognition-2021</td>\n      <td>0.0</td>\n    </tr>\n  </tbody>\n</table>\n<p>37500 rows × 5 columns</p>\n</div>"},"metadata":{}}]},{"cell_type":"markdown","source":"<br>\n\n**ImageNetMini 1000**\n* Take 5000","metadata":{}},{"cell_type":"code","source":"n_imagenetmini = 5000\nimagenet_cls_map = {'n02119789': 'kit fox, Vulpes macrotis', 'n02100735': 'English setter', 'n02096294': 'Australian terrier', 'n02066245': 'grey whale, gray whale, devilfish, Eschrichtius gibbosus, Eschrichtius robustus', 'n02509815': 'lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens', 'n02124075': 'Egyptian cat', 'n02417914': 'ibex, Capra ibex', 'n02123394': 'Persian cat', 'n02125311': 'cougar, puma, catamount, mountain lion, painter, panther, Felis concolor', 'n02423022': 'gazelle', 'n02346627': 'porcupine, hedgehog', 'n02077923': 'sea lion', 'n02447366': 'badger', 'n02109047': 'Great Dane', 'n02092002': 'Scottish deerhound, deerhound', 'n02071294': 'killer whale, killer, orca, grampus, sea wolf, Orcinus orca', 'n02442845': 'mink', 'n02504458': 'African elephant, Loxodonta africana', 'n02114712': 'red wolf, maned wolf, Canis rufus, Canis niger', 'n02128925': 'jaguar, panther, Panthera onca, Felis onca', 'n02117135': 'hyena, hyaena', 'n02493509': 'titi, titi monkey', 'n02457408': 'three-toed sloth, ai, Bradypus tridactylus', 'n02389026': 'sorrel', 'n02443484': 'black-footed ferret, ferret, Mustela nigripes', 'n02110341': 'dalmatian, coach dog, carriage dog', 'n02093256': 'Staffordshire bullterrier, Staffordshire bull terrier', 'n02106382': 'Bouvier des Flandres, Bouviers des Flandres', 'n02441942': 'weasel', 'n02113712': 'miniature poodle', 'n02415577': 'bighorn, bighorn sheep, cimarron, Rocky Mountain bighorn, Rocky Mountain sheep, Ovis canadensis', 'n02356798': 'fox squirrel, eastern fox squirrel, Sciurus niger', 'n02488702': 'colobus, colobus monkey', 'n02123159': 'tiger cat', 'n02422699': 'impala, Aepyceros melampus', 'n02114855': 'coyote, prairie wolf, brush wolf, Canis latrans', 'n02094433': 'Yorkshire terrier', 'n02111277': 'Newfoundland, Newfoundland dog', 'n02119022': 'red fox, Vulpes vulpes', 'n02422106': 'hartebeest', 'n02120505': 'grey fox, gray fox, Urocyon cinereoargenteus', 'n02086079': 'Pekinese, Pekingese, Peke', 'n02484975': 'guenon, guenon monkey', 'n02137549': 'mongoose', 'n02500267': 'indri, indris, Indri indri, Indri brevicaudatus', 'n02129604': 'tiger, Panthera tigris', 'n02396427': 'wild boar, boar, Sus scrofa', 'n02391049': 'zebra', 'n02412080': 'ram, tup', 'n02480495': 'orangutan, orang, orangutang, Pongo pygmaeus', 'n02110806': 'basenji', 'n02128385': 'leopard, Panthera pardus', 'n02100583': 'vizsla, Hungarian pointer', 'n02494079': 'squirrel monkey, Saimiri sciureus', 'n02123597': 'Siamese cat, Siamese', 'n02481823': 'chimpanzee, chimp, Pan troglodytes', 'n02105505': 'komondor', 'n02489166': 'proboscis monkey, Nasalis larvatus', 'n02364673': 'guinea pig, Cavia cobaya', 'n02114548': 'white wolf, Arctic wolf, Canis lupus tundrarum', 'n02134084': 'ice bear, polar bear, Ursus Maritimus, Thalarctos maritimus', 'n02480855': 'gorilla, Gorilla gorilla', 'n02403003': 'ox', 'n02108551': 'Tibetan mastiff', 'n02493793': 'spider monkey, Ateles geoffroyi', 'n02107142': 'Doberman, Doberman pinscher', 'n02397096': 'warthog', 'n02437312': 'Arabian camel, dromedary, Camelus dromedarius', 'n02483708': 'siamang, Hylobates syndactylus, Symphalangus syndactylus', 'n02099601': 'golden retriever', 'n02106166': 'Border collie', 'n02326432': 'hare', 'n02108089': 'boxer', 'n02486261': 'patas, hussar monkey, Erythrocebus patas', 'n02486410': 'baboon', 'n02487347': 'macaque', 'n02492035': 'capuchin, ringtail, Cebus capucinus', 'n02099267': 'flat-coated retriever', 'n02395406': 'hog, pig, grunter, squealer, Sus scrofa', 'n02109961': 'Eskimo dog, husky', 'n02101388': 'Brittany spaniel', 'n03187595': 'dial telephone, dial phone', 'n03733281': 'maze, labyrinth', 'n02101006': 'Gordon setter', 'n02115641': 'dingo, warrigal, warragal, Canis dingo', 'n02342885': 'hamster', 'n02120079': 'Arctic fox, white fox, Alopex lagopus', 'n02408429': 'water buffalo, water ox, Asiatic buffalo, Bubalus bubalis', 'n02133161': 'American black bear, black bear, Ursus americanus, Euarctos americanus', 'n02328150': 'Angora, Angora rabbit', 'n02410509': 'bison', 'n02492660': 'howler monkey, howler', 'n02398521': 'hippopotamus, hippo, river horse, Hippopotamus amphibius', 'n02510455': 'giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca', 'n02123045': 'tabby, tabby cat', 'n02490219': 'marmoset', 'n02109525': 'Saint Bernard, St Bernard', 'n02454379': 'armadillo', 'n02090379': 'redbone', 'n02443114': 'polecat, fitch, foulmart, foumart, Mustela putorius', 'n02361337': 'marmot', 'n02483362': 'gibbon, Hylobates lar', 'n02437616': 'llama', 'n02325366': 'wood rabbit, cottontail, cottontail rabbit', 'n02129165': 'lion, king of beasts, Panthera leo', 'n02100877': 'Irish setter, red setter', 'n02074367': 'dugong, Dugong dugon', 'n02504013': 'Indian elephant, Elephas maximus', 'n02363005': 'beaver', 'n02497673': 'Madagascar cat, ring-tailed lemur, Lemur catta', 'n02087394': 'Rhodesian ridgeback', 'n02127052': 'lynx, catamount', 'n02116738': 'African hunting dog, hyena dog, Cape hunting dog, Lycaon pictus', 'n02488291': 'langur', 'n02114367': 'timber wolf, grey wolf, gray wolf, Canis lupus', 'n02130308': 'cheetah, chetah, Acinonyx jubatus', 'n02134418': 'sloth bear, Melursus ursinus, Ursus ursinus', 'n02106662': 'German shepherd, German shepherd dog, German police dog, alsatian', 'n02444819': 'otter', 'n01882714': 'koala, koala bear, kangaroo bear, native bear, Phascolarctos cinereus', 'n01871265': 'tusker', 'n01872401': 'echidna, spiny anteater, anteater', 'n01877812': 'wallaby, brush kangaroo', 'n01873310': 'platypus, duckbill, duckbilled platypus, duck-billed platypus, Ornithorhynchus anatinus', 'n01883070': 'wombat', 'n04086273': 'revolver, six-gun, six-shooter', 'n04507155': 'umbrella', 'n04147183': 'schooner', 'n04254680': 'soccer ball', 'n02672831': 'accordion, piano accordion, squeeze box', 'n02219486': 'ant, emmet, pismire', 'n02317335': 'starfish, sea star', 'n01968897': 'chambered nautilus, pearly nautilus, nautilus', 'n03452741': 'grand piano, grand', 'n03642806': 'laptop, laptop computer', 'n07745940': 'strawberry', 'n02690373': 'airliner', 'n04552348': 'warplane, military plane', 'n02692877': 'airship, dirigible', 'n02782093': 'balloon', 'n04266014': 'space shuttle', 'n03344393': 'fireboat', 'n03447447': 'gondola', 'n04273569': 'speedboat', 'n03662601': 'lifeboat', 'n02951358': 'canoe', 'n04612504': 'yawl', 'n02981792': 'catamaran', 'n04483307': 'trimaran', 'n03095699': 'container ship, containership, container vessel', 'n03673027': 'liner, ocean liner', 'n03947888': 'pirate, pirate ship', 'n02687172': 'aircraft carrier, carrier, flattop, attack aircraft carrier', 'n04347754': 'submarine, pigboat, sub, U-boat', 'n04606251': 'wreck', 'n03478589': 'half track', 'n04389033': 'tank, army tank, armored combat vehicle, armoured combat vehicle', 'n03773504': 'missile', 'n02860847': 'bobsled, bobsleigh, bob', 'n03218198': 'dogsled, dog sled, dog sleigh', 'n02835271': 'bicycle-built-for-two, tandem bicycle, tandem', 'n03792782': 'mountain bike, all-terrain bike, off-roader', 'n03393912': 'freight car', 'n03895866': 'passenger car, coach, carriage', 'n02797295': 'barrow, garden cart, lawn cart, wheelbarrow', 'n04204347': 'shopping cart', 'n03791053': 'motor scooter, scooter', 'n03384352': 'forklift', 'n03272562': 'electric locomotive', 'n04310018': 'steam locomotive', 'n02704792': 'amphibian, amphibious vehicle', 'n02701002': 'ambulance', 'n02814533': 'beach wagon, station wagon, wagon, estate car, beach waggon, station waggon, waggon', 'n02930766': 'cab, hack, taxi, taxicab', 'n03100240': 'convertible', 'n03594945': 'jeep, landrover', 'n03670208': 'limousine, limo', 'n03770679': 'minivan', 'n03777568': 'Model T', 'n04037443': 'racer, race car, racing car', 'n04285008': 'sports car, sport car', 'n03444034': 'go-kart', 'n03445924': 'golfcart, golf cart', 'n03785016': 'moped', 'n04252225': 'snowplow, snowplough', 'n03345487': 'fire engine, fire truck', 'n03417042': 'garbage truck, dustcart', 'n03930630': 'pickup, pickup truck', 'n04461696': 'tow truck, tow car, wrecker', 'n04467665': 'trailer truck, tractor trailer, trucking rig, rig, articulated lorry, semi', 'n03796401': 'moving van', 'n03977966': 'police van, police wagon, paddy wagon, patrol wagon, wagon, black Maria', 'n04065272': 'recreational vehicle, RV, R.V.', 'n04335435': 'streetcar, tram, tramcar, trolley, trolley car', 'n04252077': 'snowmobile', 'n04465501': 'tractor', 'n03776460': 'mobile home, manufactured home', 'n04482393': 'tricycle, trike, velocipede', 'n04509417': 'unicycle, monocycle', 'n03538406': 'horse cart, horse-cart', 'n03788365': 'mosquito net', 'n03868242': 'oxcart', 'n02804414': 'bassinet', 'n03125729': 'cradle', 'n03131574': 'crib, cot', 'n03388549': 'four-poster', 'n02870880': 'bookcase', 'n03018349': 'china cabinet, china closet', 'n03742115': 'medicine chest, medicine cabinet', 'n03016953': 'chiffonier, commode', 'n04380533': 'table lamp', 'n03337140': 'file, file cabinet, filing cabinet', 'n03902125': 'pay-phone, pay-station', 'n03891251': 'park bench', 'n02791124': 'barber chair', 'n04429376': 'throne', 'n03376595': 'folding chair', 'n04099969': 'rocking chair, rocker', 'n04344873': 'studio couch, day bed', 'n04447861': 'toilet seat', 'n03179701': 'desk', 'n03982430': 'pool table, billiard table, snooker table', 'n03201208': 'dining table, board', 'n03290653': 'entertainment center', 'n04550184': 'wardrobe, closet, press', 'n07742313': 'Granny Smith', 'n07747607': 'orange', 'n07749582': 'lemon', 'n07753113': 'fig', 'n07753275': 'pineapple, ananas', 'n07753592': 'banana', 'n07754684': 'jackfruit, jak, jack', 'n07760859': 'custard apple', 'n07768694': 'pomegranate', 'n12267677': 'acorn', 'n12620546': 'hip, rose hip, rosehip', 'n13133613': 'ear, spike, capitulum', 'n11879895': 'rapeseed', 'n12144580': 'corn', 'n12768682': 'buckeye, horse chestnut, conker', 'n03854065': 'organ, pipe organ', 'n04515003': 'upright, upright piano', 'n03017168': 'chime, bell, gong', 'n03249569': 'drum, membranophone, tympan', 'n03447721': 'gong, tam-tam', 'n03720891': 'maraca', 'n03721384': 'marimba, xylophone', 'n04311174': 'steel drum', 'n02787622': 'banjo', 'n02992211': 'cello, violoncello', 'n03637318': 'lampshade, lamp shade', 'n03495258': 'harp', 'n02676566': 'acoustic guitar', 'n03272010': 'electric guitar', 'n03110669': 'cornet, horn, trumpet, trump', 'n03394916': 'French horn, horn', 'n04487394': 'trombone', 'n03494278': 'harmonica, mouth organ, harp, mouth harp', 'n03840681': 'ocarina, sweet potato', 'n03884397': 'panpipe, pandean pipe, syrinx', 'n02804610': 'bassoon', 'n04141076': 'sax, saxophone', 'n03372029': 'flute, transverse flute', 'n11939491': 'daisy', 'n12057211': \"yellow lady's slipper, yellow lady-slipper, Cypripedium calceolus, Cypripedium parviflorum\", 'n09246464': 'cliff, drop, drop-off', 'n09468604': 'valley, vale', 'n09193705': 'alp', 'n09472597': 'volcano', 'n09399592': 'promontory, headland, head, foreland', 'n09421951': 'sandbar, sand bar', 'n09256479': 'coral reef', 'n09332890': 'lakeside, lakeshore', 'n09428293': 'seashore, coast, seacoast, sea-coast', 'n09288635': 'geyser', 'n03498962': 'hatchet', 'n03041632': 'cleaver, meat cleaver, chopper', 'n03658185': 'letter opener, paper knife, paperknife', 'n03954731': \"plane, carpenter's plane, woodworking plane\", 'n03995372': 'power drill', 'n03649909': 'lawn mower, mower', 'n03481172': 'hammer', 'n03109150': 'corkscrew, bottle screw', 'n02951585': 'can opener, tin opener', 'n03970156': \"plunger, plumber's helper\", 'n04154565': 'screwdriver', 'n04208210': 'shovel', 'n03967562': 'plow, plough', 'n03000684': 'chain saw, chainsaw', 'n01514668': 'cock', 'n01514859': 'hen', 'n01518878': 'ostrich, Struthio camelus', 'n01530575': 'brambling, Fringilla montifringilla', 'n01531178': 'goldfinch, Carduelis carduelis', 'n01532829': 'house finch, linnet, Carpodacus mexicanus', 'n01534433': 'junco, snowbird', 'n01537544': 'indigo bunting, indigo finch, indigo bird, Passerina cyanea', 'n01558993': 'robin, American robin, Turdus migratorius', 'n01560419': 'bulbul', 'n01580077': 'jay', 'n01582220': 'magpie', 'n01592084': 'chickadee', 'n01601694': 'water ouzel, dipper', 'n01608432': 'kite', 'n01614925': 'bald eagle, American eagle, Haliaeetus leucocephalus', 'n01616318': 'vulture', 'n01622779': 'great grey owl, great gray owl, Strix nebulosa', 'n01795545': 'black grouse', 'n01796340': 'ptarmigan', 'n01797886': 'ruffed grouse, partridge, Bonasa umbellus', 'n01798484': 'prairie chicken, prairie grouse, prairie fowl', 'n01806143': 'peacock', 'n01806567': 'quail', 'n01807496': 'partridge', 'n01817953': 'African grey, African gray, Psittacus erithacus', 'n01818515': 'macaw', 'n01819313': 'sulphur-crested cockatoo, Kakatoe galerita, Cacatua galerita', 'n01820546': 'lorikeet', 'n01824575': 'coucal', 'n01828970': 'bee eater', 'n01829413': 'hornbill', 'n01833805': 'hummingbird', 'n01843065': 'jacamar', 'n01843383': 'toucan', 'n01847000': 'drake', 'n01855032': 'red-breasted merganser, Mergus serrator', 'n01855672': 'goose', 'n01860187': 'black swan, Cygnus atratus', 'n02002556': 'white stork, Ciconia ciconia', 'n02002724': 'black stork, Ciconia nigra', 'n02006656': 'spoonbill', 'n02007558': 'flamingo', 'n02009912': 'American egret, great white heron, Egretta albus', 'n02009229': 'little blue heron, Egretta caerulea', 'n02011460': 'bittern', 'n02012849': 'crane', 'n02013706': 'limpkin, Aramus pictus', 'n02018207': 'American coot, marsh hen, mud hen, water hen, Fulica americana', 'n02018795': 'bustard', 'n02025239': 'ruddy turnstone, Arenaria interpres', 'n02027492': 'red-backed sandpiper, dunlin, Erolia alpina', 'n02028035': 'redshank, Tringa totanus', 'n02033041': 'dowitcher', 'n02037110': 'oystercatcher, oyster catcher', 'n02017213': 'European gallinule, Porphyrio porphyrio', 'n02051845': 'pelican', 'n02056570': 'king penguin, Aptenodytes patagonica', 'n02058221': 'albatross, mollymawk', 'n01484850': 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias', 'n01491361': 'tiger shark, Galeocerdo cuvieri', 'n01494475': 'hammerhead, hammerhead shark', 'n01496331': 'electric ray, crampfish, numbfish, torpedo', 'n01498041': 'stingray', 'n02514041': 'barracouta, snoek', 'n02536864': 'coho, cohoe, coho salmon, blue jack, silver salmon, Oncorhynchus kisutch', 'n01440764': 'tench, Tinca tinca', 'n01443537': 'goldfish, Carassius auratus', 'n02526121': 'eel', 'n02606052': 'rock beauty, Holocanthus tricolor', 'n02607072': 'anemone fish', 'n02643566': 'lionfish', 'n02655020': 'puffer, pufferfish, blowfish, globefish', 'n02640242': 'sturgeon', 'n02641379': 'gar, garfish, garpike, billfish, Lepisosteus osseus', 'n01664065': 'loggerhead, loggerhead turtle, Caretta caretta', 'n01667114': 'mud turtle', 'n01667778': 'terrapin', 'n01669191': 'box turtle, box tortoise', 'n01675722': 'banded gecko', 'n01677366': 'common iguana, iguana, Iguana iguana', 'n01682714': 'American chameleon, anole, Anolis carolinensis', 'n01685808': 'whiptail, whiptail lizard', 'n01687978': 'agama', 'n01688243': 'frilled lizard, Chlamydosaurus kingi', 'n01689811': 'alligator lizard', 'n01692333': 'Gila monster, Heloderma suspectum', 'n01693334': 'green lizard, Lacerta viridis', 'n01694178': 'African chameleon, Chamaeleo chamaeleon', 'n01695060': 'Komodo dragon, Komodo lizard, dragon lizard, giant lizard, Varanus komodoensis', 'n01704323': 'triceratops', 'n01697457': 'African crocodile, Nile crocodile, Crocodylus niloticus', 'n01698640': 'American alligator, Alligator mississipiensis', 'n01728572': 'thunder snake, worm snake, Carphophis amoenus', 'n01728920': 'ringneck snake, ring-necked snake, ring snake', 'n01729322': 'hognose snake, puff adder, sand viper', 'n01729977': 'green snake, grass snake', 'n01734418': 'king snake, kingsnake', 'n01735189': 'garter snake, grass snake', 'n01737021': 'water snake', 'n01739381': 'vine snake', 'n01740131': 'night snake, Hypsiglena torquata', 'n01742172': 'boa constrictor, Constrictor constrictor', 'n01744401': 'rock python, rock snake, Python sebae', 'n01748264': 'Indian cobra, Naja naja', 'n01749939': 'green mamba', 'n01751748': 'sea snake', 'n01753488': 'horned viper, cerastes, sand viper, horned asp, Cerastes cornutus', 'n04326547': 'stone wall', 'n01756291': 'sidewinder, horned rattlesnake, Crotalus cerastes', 'n01629819': 'European fire salamander, Salamandra salamandra', 'n01630670': 'common newt, Triturus vulgaris', 'n01631663': 'eft', 'n01632458': 'spotted salamander, Ambystoma maculatum', 'n01632777': 'axolotl, mud puppy, Ambystoma mexicanum', 'n01641577': 'bullfrog, Rana catesbeiana', 'n01644373': 'tree frog, tree-frog', 'n01644900': 'tailed frog, bell toad, ribbed toad, tailed toad, Ascaphus trui', 'n04579432': 'whistle', 'n04592741': 'wing', 'n03876231': 'paintbrush', 'n03868863': 'oxygen mask', 'n04251144': 'snorkel', 'n03691459': 'loudspeaker, speaker, speaker unit, loudspeaker system, speaker system', 'n03759954': 'microphone, mike', 'n04152593': 'screen, CRT screen', 'n03793489': 'mouse, computer mouse', 'n03271574': 'electric fan, blower', 'n03843555': 'oil filter', 'n04332243': 'strainer', 'n04265275': 'space heater', 'n04330267': 'stove', 'n03467068': 'guillotine', 'n02794156': 'barometer', 'n04118776': 'rule, ruler', 'n03841143': 'odometer, hodometer, mileometer, milometer', 'n04141975': 'scale, weighing machine', 'n02708093': 'analog clock', 'n03196217': 'digital clock', 'n04548280': 'wall clock', 'n03544143': 'hourglass', 'n04355338': 'sundial', 'n03891332': 'parking meter', 'n04328186': 'stopwatch, stop watch', 'n03197337': 'digital watch', 'n04317175': 'stethoscope', 'n04376876': 'syringe', 'n03706229': 'magnetic compass', 'n02841315': 'binoculars, field glasses, opera glasses', 'n04009552': 'projector', 'n04356056': 'sunglasses, dark glasses, shades', 'n03692522': \"loupe, jeweler's loupe\", 'n04044716': 'radio telescope, radio reflector', 'n02879718': 'bow', 'n02950826': 'cannon', 'n02749479': 'assault rifle, assault gun', 'n04090263': 'rifle', 'n04008634': 'projectile, missile', 'n03085013': 'computer keyboard, keypad', 'n04505470': 'typewriter keyboard', 'n03126707': 'crane', 'n03666591': 'lighter, light, igniter, ignitor', 'n02666196': 'abacus', 'n02977058': 'cash machine, cash dispenser, automated teller machine, automatic teller machine, automated teller, automatic teller, ATM', 'n04238763': 'slide rule, slipstick', 'n03180011': 'desktop computer', 'n03485407': 'hand-held computer, hand-held microcomputer', 'n03832673': 'notebook, notebook computer', 'n03874599': 'padlock', 'n03496892': 'harvester, reaper', 'n04428191': 'thresher, thrasher, threshing machine', 'n04004767': 'printer', 'n04243546': 'slot, one-armed bandit', 'n04525305': 'vending machine', 'n04179913': 'sewing machine', 'n03602883': 'joystick', 'n04372370': 'switch, electric switch, electrical switch', 'n03532672': 'hook, claw', 'n02974003': 'car wheel', 'n03874293': 'paddlewheel, paddle wheel', 'n03944341': 'pinwheel', 'n03992509': \"potter's wheel\", 'n03425413': 'gas pump, gasoline pump, petrol pump, island dispenser', 'n02966193': 'carousel, carrousel, merry-go-round, roundabout, whirligig', 'n04371774': 'swing', 'n04067472': 'reel', 'n04040759': 'radiator', 'n04019541': 'puck, hockey puck', 'n03492542': 'hard disc, hard disk, fixed disk', 'n04355933': 'sunglass', 'n03929660': 'pick, plectrum, plectron', 'n02965783': 'car mirror', 'n04258138': 'solar dish, solar collector, solar furnace', 'n04074963': 'remote control, remote', 'n03208938': 'disk brake, disc brake', 'n02910353': 'buckle', 'n03476684': 'hair slide', 'n03627232': 'knot', 'n03075370': 'combination lock', 'n06359193': 'web site, website, internet site, site', 'n03804744': 'nail', 'n04127249': 'safety pin', 'n04153751': 'screw', 'n03803284': 'muzzle', 'n04162706': 'seat belt, seatbelt', 'n04228054': 'ski', 'n02948072': 'candle, taper, wax light', 'n03590841': \"jack-o'-lantern\", 'n04286575': 'spotlight, spot', 'n04456115': 'torch', 'n03814639': 'neck brace', 'n03933933': 'pier', 'n04485082': 'tripod', 'n03733131': 'maypole', 'n03483316': 'hand blower, blow dryer, blow drier, hair dryer, hair drier', 'n03794056': 'mousetrap', 'n04275548': \"spider web, spider's web\", 'n01768244': 'trilobite', 'n01770081': 'harvestman, daddy longlegs, Phalangium opilio', 'n01770393': 'scorpion', 'n01773157': 'black and gold garden spider, Argiope aurantia', 'n01773549': 'barn spider, Araneus cavaticus', 'n01773797': 'garden spider, Aranea diademata', 'n01774384': 'black widow, Latrodectus mactans', 'n01774750': 'tarantula', 'n01775062': 'wolf spider, hunting spider', 'n01776313': 'tick', 'n01784675': 'centipede', 'n01990800': 'isopod', 'n01978287': 'Dungeness crab, Cancer magister', 'n01978455': 'rock crab, Cancer irroratus', 'n01980166': 'fiddler crab', 'n01981276': 'king crab, Alaska crab, Alaskan king crab, Alaska king crab, Paralithodes camtschatica', 'n01983481': 'American lobster, Northern lobster, Maine lobster, Homarus americanus', 'n01984695': 'spiny lobster, langouste, rock lobster, crawfish, crayfish, sea crawfish', 'n01985128': 'crayfish, crawfish, crawdad, crawdaddy', 'n01986214': 'hermit crab', 'n02165105': 'tiger beetle', 'n02165456': 'ladybug, ladybeetle, lady beetle, ladybird, ladybird beetle', 'n02167151': 'ground beetle, carabid beetle', 'n02168699': 'long-horned beetle, longicorn, longicorn beetle', 'n02169497': 'leaf beetle, chrysomelid', 'n02172182': 'dung beetle', 'n02174001': 'rhinoceros beetle', 'n02177972': 'weevil', 'n02190166': 'fly', 'n02206856': 'bee', 'n02226429': 'grasshopper, hopper', 'n02229544': 'cricket', 'n02231487': 'walking stick, walkingstick, stick insect', 'n02233338': 'cockroach, roach', 'n02236044': 'mantis, mantid', 'n02256656': 'cicada, cicala', 'n02259212': 'leafhopper', 'n02264363': 'lacewing, lacewing fly', 'n02268443': \"dragonfly, darning needle, devil's darning needle, sewing needle, snake feeder, snake doctor, mosquito hawk, skeeter hawk\", 'n02268853': 'damselfly', 'n02276258': 'admiral', 'n02277742': 'ringlet, ringlet butterfly', 'n02279972': 'monarch, monarch butterfly, milkweed butterfly, Danaus plexippus', 'n02280649': 'cabbage butterfly', 'n02281406': 'sulphur butterfly, sulfur butterfly', 'n02281787': 'lycaenid, lycaenid butterfly', 'n01910747': 'jellyfish', 'n01914609': 'sea anemone, anemone', 'n01917289': 'brain coral', 'n01924916': 'flatworm, platyhelminth', 'n01930112': 'nematode, nematode worm, roundworm', 'n01943899': 'conch', 'n01944390': 'snail', 'n01945685': 'slug', 'n01950731': 'sea slug, nudibranch', 'n01955084': 'chiton, coat-of-mail shell, sea cradle, polyplacophore', 'n02319095': 'sea urchin', 'n02321529': 'sea cucumber, holothurian', 'n03584829': 'iron, smoothing iron', 'n03297495': 'espresso maker', 'n03761084': 'microwave, microwave oven', 'n03259280': 'Dutch oven', 'n04111531': 'rotisserie', 'n04442312': 'toaster', 'n04542943': 'waffle iron', 'n04517823': 'vacuum, vacuum cleaner', 'n03207941': 'dishwasher, dish washer, dishwashing machine', 'n04070727': 'refrigerator, icebox', 'n04554684': 'washer, automatic washer, washing machine', 'n03133878': 'Crock Pot', 'n03400231': 'frying pan, frypan, skillet', 'n04596742': 'wok', 'n02939185': 'caldron, cauldron', 'n03063689': 'coffeepot', 'n04398044': 'teapot', 'n04270147': 'spatula', 'n02699494': 'altar', 'n04486054': 'triumphal arch', 'n03899768': 'patio, terrace', 'n04311004': 'steel arch bridge', 'n04366367': 'suspension bridge', 'n04532670': 'viaduct', 'n02793495': 'barn', 'n03457902': 'greenhouse, nursery, glasshouse', 'n03877845': 'palace', 'n03781244': 'monastery', 'n03661043': 'library', 'n02727426': 'apiary, bee house', 'n02859443': 'boathouse', 'n03028079': 'church, church building', 'n03788195': 'mosque', 'n04346328': 'stupa, tope', 'n03956157': 'planetarium', 'n04081281': 'restaurant, eating house, eating place, eatery', 'n03032252': 'cinema, movie theater, movie theatre, movie house, picture palace', 'n03529860': 'home theater, home theatre', 'n03697007': 'lumbermill, sawmill', 'n03065424': 'coil, spiral, volute, whorl, helix', 'n03837869': 'obelisk', 'n04458633': 'totem pole', 'n02980441': 'castle', 'n04005630': 'prison, prison house', 'n03461385': 'grocery store, grocery, food market, market', 'n02776631': 'bakery, bakeshop, bakehouse', 'n02791270': 'barbershop', 'n02871525': 'bookshop, bookstore, bookstall', 'n02927161': 'butcher shop, meat market', 'n03089624': 'confectionery, confectionary, candy store', 'n04200800': 'shoe shop, shoe-shop, shoe store', 'n04443257': 'tobacco shop, tobacconist shop, tobacconist', 'n04462240': 'toyshop', 'n03388043': 'fountain', 'n03042490': 'cliff dwelling', 'n04613696': 'yurt', 'n03216828': 'dock, dockage, docking facility', 'n02892201': 'brass, memorial tablet, plaque', 'n03743016': 'megalith, megalithic structure', 'n02788148': 'bannister, banister, balustrade, balusters, handrail', 'n02894605': 'breakwater, groin, groyne, mole, bulwark, seawall, jetty', 'n03160309': 'dam, dike, dyke', 'n03000134': 'chainlink fence', 'n03930313': 'picket fence, paling', 'n04604644': 'worm fence, snake fence, snake-rail fence, Virginia fence', 'n01755581': 'diamondback, diamondback rattlesnake, Crotalus adamanteus', 'n03459775': 'grille, radiator grille', 'n04239074': 'sliding door', 'n04501370': 'turnstile', 'n03792972': 'mountain tent', 'n04149813': 'scoreboard', 'n03530642': 'honeycomb', 'n03961711': 'plate rack', 'n03903868': 'pedestal, plinth, footstall', 'n02814860': 'beacon, lighthouse, beacon light, pharos', 'n01665541': 'leatherback turtle, leatherback, leathery turtle, Dermochelys coriacea', 'n07711569': 'mashed potato', 'n07720875': 'bell pepper', 'n07714571': 'head cabbage', 'n07714990': 'broccoli', 'n07715103': 'cauliflower', 'n07716358': 'zucchini, courgette', 'n07716906': 'spaghetti squash', 'n07717410': 'acorn squash', 'n07717556': 'butternut squash', 'n07718472': 'cucumber, cuke', 'n07718747': 'artichoke, globe artichoke', 'n07730033': 'cardoon', 'n07734744': 'mushroom', 'n04209239': 'shower curtain', 'n03594734': 'jean, blue jean, denim', 'n02971356': 'carton', 'n03485794': 'handkerchief, hankie, hanky, hankey', 'n04133789': 'sandal', 'n02747177': 'ashcan, trash can, garbage can, wastebin, ash bin, ash-bin, ashbin, dustbin, trash barrel, trash bin', 'n04125021': 'safe', 'n07579787': 'plate', 'n03814906': 'necklace', 'n03134739': 'croquet ball', 'n03404251': 'fur coat', 'n04423845': 'thimble', 'n03877472': \"pajama, pyjama, pj's, jammies\", 'n04120489': 'running shoe', 'n03838899': 'oboe, hautboy, hautbois', 'n03062245': 'cocktail shaker', 'n03014705': 'chest', 'n03717622': 'manhole cover', 'n03777754': 'modem', 'n04493381': 'tub, vat', 'n04476259': 'tray', 'n02777292': 'balance beam, beam', 'n07693725': 'bagel, beigel', 'n04536866': 'violin, fiddle', 'n03998194': 'prayer rug, prayer mat', 'n03617480': 'kimono', 'n07590611': 'hot pot, hotpot', 'n04579145': 'whiskey jug', 'n03623198': 'knee pad', 'n07248320': 'book jacket, dust cover, dust jacket, dust wrapper', 'n04277352': 'spindle', 'n04229816': 'ski mask', 'n02823428': 'beer bottle', 'n03127747': 'crash helmet', 'n02877765': 'bottlecap', 'n04435653': 'tile roof', 'n03724870': 'mask', 'n03710637': 'maillot', 'n03920288': 'Petri dish', 'n03379051': 'football helmet', 'n02807133': 'bathing cap, swimming cap', 'n04399382': 'teddy, teddy bear', 'n03527444': 'holster', 'n03983396': 'pop bottle, soda bottle', 'n03924679': 'photocopier', 'n04532106': 'vestment', 'n06785654': 'crossword puzzle, crossword', 'n03445777': 'golf ball', 'n07613480': 'trifle', 'n04350905': 'suit, suit of clothes', 'n04562935': 'water tower', 'n03325584': 'feather boa, boa', 'n03045698': 'cloak', 'n07892512': 'red wine', 'n03250847': 'drumstick', 'n04192698': 'shield, buckler', 'n03026506': 'Christmas stocking', 'n03534580': 'hoopskirt, crinoline', 'n07565083': 'menu', 'n04296562': 'stage', 'n02869837': 'bonnet, poke bonnet', 'n07871810': 'meat loaf, meatloaf', 'n02799071': 'baseball', 'n03314780': 'face powder', 'n04141327': 'scabbard', 'n04357314': 'sunscreen, sunblock, sun blocker', 'n02823750': 'beer glass', 'n13052670': 'hen-of-the-woods, hen of the woods, Polyporus frondosus, Grifola frondosa', 'n07583066': 'guacamole', 'n04599235': 'wool, woolen, woollen', 'n07802026': 'hay', 'n02883205': 'bow tie, bow-tie, bowtie', 'n03709823': 'mailbag, postbag', 'n04560804': 'water jug', 'n02909870': 'bucket, pail', 'n03207743': 'dishrag, dishcloth', 'n04263257': 'soup bowl', 'n07932039': 'eggnog', 'n03786901': 'mortar', 'n04479046': 'trench coat', 'n03873416': 'paddle, boat paddle', 'n02999410': 'chain', 'n04367480': 'swab, swob, mop', 'n03775546': 'mixing bowl', 'n07875152': 'potpie', 'n04591713': 'wine bottle', 'n04201297': 'shoji', 'n02916936': 'bulletproof vest', 'n03240683': 'drilling platform, offshore rig', 'n02840245': 'binder, ring-binder', 'n02963159': 'cardigan', 'n04370456': 'sweatshirt', 'n03991062': 'pot, flowerpot', 'n02843684': 'birdhouse', 'n03599486': 'jinrikisha, ricksha, rickshaw', 'n03482405': 'hamper', 'n03942813': 'ping-pong ball', 'n03908618': 'pencil box, pencil case', 'n07584110': 'consomme', 'n02730930': 'apron', 'n04023962': 'punching bag, punch bag, punching ball, punchball', 'n02769748': 'backpack, back pack, knapsack, packsack, rucksack, haversack', 'n10148035': 'groom, bridegroom', 'n02817516': 'bearskin, busby, shako', 'n03908714': 'pencil sharpener', 'n02906734': 'broom', 'n02667093': 'abaya', 'n03787032': 'mortarboard', 'n03980874': 'poncho', 'n03141823': 'crutch', 'n03976467': 'Polaroid camera, Polaroid Land camera', 'n04264628': 'space bar', 'n07930864': 'cup', 'n04039381': 'racket, racquet', 'n06874185': 'traffic light, traffic signal, stoplight', 'n04033901': 'quill, quill pen', 'n04041544': 'radio, wireless', 'n02128757': 'snow leopard, ounce, Panthera uncia', 'n07860988': 'dough', 'n03146219': 'cuirass', 'n03763968': 'military uniform', 'n03676483': 'lipstick, lip rouge', 'n04209133': 'shower cap', 'n03782006': 'monitor', 'n03857828': 'oscilloscope, scope, cathode-ray oscilloscope, CRO', 'n03775071': 'mitten', 'n02892767': 'brassiere, bra, bandeau', 'n07684084': 'French loaf', 'n04522168': 'vase', 'n03764736': 'milk can', 'n04118538': 'rugby ball', 'n03887697': 'paper towel', 'n13044778': 'earthstar', 'n03291819': 'envelope', 'n03770439': 'miniskirt, mini', 'n03124170': 'cowboy hat, ten-gallon hat', 'n04487081': 'trolleybus, trolley coach, trackless trolley', 'n03916031': 'perfume, essence', 'n02808440': 'bathtub, bathing tub, bath, tub', 'n07697537': 'hotdog, hot dog, red hot', 'n12985857': 'coral fungus', 'n02917067': 'bullet train, bullet', 'n03938244': 'pillow', 'n15075141': 'toilet tissue, toilet paper, bathroom tissue', 'n02978881': 'cassette', 'n02966687': \"carpenter's kit, tool kit\", 'n03633091': 'ladle', 'n13040303': 'stinkhorn, carrion fungus', 'n03690938': 'lotion', 'n03476991': 'hair spray', 'n02669723': \"academic gown, academic robe, judge's robe\", 'n03220513': 'dome', 'n03127925': 'crate', 'n04584207': 'wig', 'n07880968': 'burrito', 'n03937543': 'pill bottle', 'n03000247': 'chain mail, ring mail, mail, chain armor, chain armour, ring armor, ring armour', 'n04418357': 'theater curtain, theatre curtain', 'n04590129': 'window shade', 'n02795169': 'barrel, cask', 'n04553703': 'washbasin, handbasin, washbowl, lavabo, wash-hand basin', 'n02783161': 'ballpoint, ballpoint pen, ballpen, Biro', 'n02802426': 'basketball', 'n02808304': 'bath towel', 'n03124043': 'cowboy boot', 'n03450230': 'gown', 'n04589890': 'window screen', 'n12998815': 'agaric', 'n02113799': 'standard poodle', 'n02992529': 'cellular telephone, cellular phone, cellphone, cell, mobile phone', 'n03825788': 'nipple', 'n02790996': 'barbell', 'n03710193': 'mailbox, letter box', 'n03630383': 'lab coat, laboratory coat', 'n03347037': 'fire screen, fireguard', 'n03769881': 'minibus', 'n03871628': 'packet', 'n02132136': 'brown bear, bruin, Ursus arctos', 'n03976657': 'pole', 'n03535780': 'horizontal bar, high bar', 'n04259630': 'sombrero', 'n03929855': 'pickelhaube', 'n04049303': 'rain barrel', 'n04548362': 'wallet, billfold, notecase, pocketbook', 'n02979186': 'cassette player', 'n06596364': 'comic book', 'n03935335': 'piggy bank, penny bank', 'n06794110': 'street sign', 'n02825657': 'bell cote, bell cot', 'n03388183': 'fountain pen', 'n04591157': 'Windsor tie', 'n04540053': 'volleyball', 'n03866082': 'overskirt', 'n04136333': 'sarong', 'n04026417': 'purse', 'n02865351': 'bolo tie, bolo, bola tie, bola', 'n02834397': 'bib', 'n03888257': 'parachute, chute', 'n04235860': 'sleeping bag', 'n04404412': 'television, television system', 'n04371430': 'swimming trunks, bathing trunks', 'n03733805': 'measuring cup', 'n07920052': 'espresso', 'n07873807': 'pizza, pizza pie', 'n02895154': 'breastplate, aegis, egis', 'n04204238': 'shopping basket', 'n04597913': 'wooden spoon', 'n04131690': 'saltshaker, salt shaker', 'n07836838': 'chocolate sauce, chocolate syrup', 'n09835506': 'ballplayer, baseball player', 'n03443371': 'goblet', 'n13037406': 'gyromitra', 'n04336792': 'stretcher', 'n04557648': 'water bottle', 'n02445715': 'skunk, polecat, wood pussy', 'n04254120': 'soap dispenser', 'n03595614': 'jersey, T-shirt, tee shirt', 'n04146614': 'school bus', 'n03598930': 'jigsaw puzzle', 'n03958227': 'plastic bag', 'n04069434': 'reflex camera', 'n03188531': 'diaper, nappy, napkin', 'n02786058': 'Band Aid', 'n07615774': 'ice lolly, lolly, lollipop, popsicle', 'n04525038': 'velvet', 'n04409515': 'tennis ball', 'n03424325': 'gasmask, respirator, gas helmet', 'n03223299': 'doormat, welcome mat', 'n03680355': 'Loafer', 'n07614500': 'ice cream, icecream', 'n07695742': 'pretzel', 'n04033995': 'quilt, comforter, comfort, puff', 'n03710721': 'maillot, tank suit', 'n04392985': 'tape player', 'n03047690': 'clog, geta, patten, sabot', 'n03584254': 'iPod', 'n13054560': 'bolete', 'n02138441': 'meerkat, mierkat', 'n10565667': 'scuba diver', 'n03950228': 'pitcher, ewer', 'n03729826': 'matchstick', 'n02837789': 'bikini, two-piece', 'n04254777': 'sock', 'n02988304': 'CD player', 'n03657121': 'lens cap, lens cover', 'n04417672': 'thatch, thatched roof', 'n04523525': 'vault', 'n02815834': 'beaker', 'n09229709': 'bubble', 'n07697313': 'cheeseburger', 'n03888605': 'parallel bars, bars', 'n03355925': 'flagpole, flagstaff', 'n03063599': 'coffee mug', 'n04116512': 'rubber eraser, rubber, pencil eraser', 'n04325704': 'stole', 'n07831146': 'carbonara', 'n03255030': 'dumbbell', 'n02110185': 'Siberian husky', 'n02102040': 'English springer, English springer spaniel', 'n02110063': 'malamute, malemute, Alaskan malamute', 'n02089867': 'Walker hound, Walker foxhound', 'n02102177': 'Welsh springer spaniel', 'n02091134': 'whippet', 'n02092339': 'Weimaraner', 'n02098105': 'soft-coated wheaten terrier', 'n02096437': 'Dandie Dinmont, Dandie Dinmont terrier', 'n02105641': 'Old English sheepdog, bobtail', 'n02091635': 'otterhound, otter hound', 'n02088466': 'bloodhound, sleuthhound', 'n02096051': 'Airedale, Airedale terrier', 'n02097130': 'giant schnauzer', 'n02089078': 'black-and-tan coonhound', 'n02086910': 'papillon', 'n02113978': 'Mexican hairless', 'n02113186': 'Cardigan, Cardigan Welsh corgi', 'n02105162': 'malinois', 'n02098413': 'Lhasa, Lhasa apso', 'n02091467': 'Norwegian elkhound, elkhound', 'n02106550': 'Rottweiler', 'n02091831': 'Saluki, gazelle hound', 'n02104365': 'schipperke', 'n02112706': 'Brabancon griffon', 'n02098286': 'West Highland white terrier', 'n02095889': 'Sealyham terrier, Sealyham', 'n02090721': 'Irish wolfhound', 'n02108000': 'EntleBucher', 'n02108915': 'French bulldog', 'n02107683': 'Bernese mountain dog', 'n02085936': 'Maltese dog, Maltese terrier, Maltese', 'n02094114': 'Norfolk terrier', 'n02087046': 'toy terrier', 'n02096177': 'cairn, cairn terrier', 'n02105056': 'groenendael', 'n02101556': 'clumber, clumber spaniel', 'n02088094': 'Afghan hound, Afghan', 'n02085782': 'Japanese spaniel', 'n02090622': 'borzoi, Russian wolfhound', 'n02113624': 'toy poodle', 'n02093859': 'Kerry blue terrier', 'n02097298': 'Scotch terrier, Scottish terrier, Scottie', 'n02096585': 'Boston bull, Boston terrier', 'n02107574': 'Greater Swiss Mountain dog', 'n02107908': 'Appenzeller', 'n02086240': 'Shih-Tzu', 'n02102973': 'Irish water spaniel', 'n02112018': 'Pomeranian', 'n02093647': 'Bedlington terrier', 'n02097047': 'miniature schnauzer', 'n02106030': 'collie', 'n02093991': 'Irish terrier', 'n02110627': 'affenpinscher, monkey pinscher, monkey dog', 'n02097658': 'silky terrier, Sydney silky', 'n02088364': 'beagle', 'n02111129': 'Leonberg', 'n02100236': 'German short-haired pointer', 'n02115913': 'dhole, Cuon alpinus', 'n02099849': 'Chesapeake Bay retriever', 'n02108422': 'bull mastiff', 'n02104029': 'kuvasz', 'n02110958': 'pug, pug-dog', 'n02099429': 'curly-coated retriever', 'n02094258': 'Norwich terrier', 'n02112350': 'keeshond', 'n02095570': 'Lakeland terrier', 'n02097209': 'standard schnauzer', 'n02097474': 'Tibetan terrier, chrysanthemum dog', 'n02095314': 'wire-haired fox terrier', 'n02088238': 'basset, basset hound', 'n02112137': 'chow, chow chow', 'n02093428': 'American Staffordshire terrier, Staffordshire terrier, American pit bull terrier, pit bull terrier', 'n02105855': 'Shetland sheepdog, Shetland sheep dog, Shetland', 'n02111500': 'Great Pyrenees', 'n02085620': 'Chihuahua', 'n02099712': 'Labrador retriever', 'n02111889': 'Samoyed, Samoyede', 'n02088632': 'bluetick', 'n02105412': 'kelpie', 'n02107312': 'miniature pinscher', 'n02091032': 'Italian greyhound', 'n02102318': 'cocker spaniel, English cocker spaniel, cocker', 'n02102480': 'Sussex spaniel', 'n02113023': 'Pembroke, Pembroke Welsh corgi', 'n02086646': 'Blenheim spaniel', 'n02091244': 'Ibizan hound, Ibizan Podenco', 'n02089973': 'English foxhound', 'n02105251': 'briard', 'n02093754': 'Border terrier'}\ntmp_df = pd.DataFrame({\"img_path\":tf.io.gfile.glob(os.path.join(INPUT_DIR, \"imagenetmini-1000\", \"imagenet-mini\", \"train\", \"**\", \"*.JPEG\"))})\ntmp_df[\"cls\"] = tmp_df[\"img_path\"].apply(lambda x: imagenet_cls_map[x.rsplit(\"/\", 2)[-2]])\ntmp_df[\"cls_cnt\"] = tmp_df.groupby(\"cls\")[\"cls\"].transform(\"count\")\ntmp_df = tmp_df.sort_values(by=\"cls_cnt\", ascending=False)\ntmp_df = tmp_df.head(n_imagenetmini).sample(n_imagenetmini).reset_index(drop=True)\ntmp_df = tmp_df[[\"img_path\", \"cls\"]]\ntmp_df[\"supercls\"] = \"other\"\ntmp_df[\"dataset\"] = \"imagenetmini-1000\"\ntmp_df[\"val_only\"] = False\n\n# Update master dataframe\nmaster_df = pd.concat([master_df, tmp_df], ignore_index=True)\nmaster_df","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:23:57.566982Z","iopub.execute_input":"2023-04-19T02:23:57.567774Z","iopub.status.idle":"2023-04-19T02:24:04.315599Z","shell.execute_reply.started":"2023-04-19T02:23:57.567724Z","shell.execute_reply":"2023-04-19T02:24:04.314184Z"},"trusted":true},"execution_count":15,"outputs":[{"execution_count":15,"output_type":"execute_result","data":{"text/plain":"                                                img_path  \\\n0      ../input/imaterialist-fashion-2020-fgvc7/train...   \n1      ../input/imaterialist-fashion-2020-fgvc7/train...   \n2      ../input/imaterialist-fashion-2020-fgvc7/train...   \n3      ../input/imaterialist-fashion-2020-fgvc7/train...   \n4      ../input/imaterialist-fashion-2020-fgvc7/train...   \n...                                                  ...   \n42495  /kaggle/input/imagenetmini-1000/imagenet-mini/...   \n42496  /kaggle/input/imagenetmini-1000/imagenet-mini/...   \n42497  /kaggle/input/imagenetmini-1000/imagenet-mini/...   \n42498  /kaggle/input/imagenetmini-1000/imagenet-mini/...   \n42499  /kaggle/input/imagenetmini-1000/imagenet-mini/...   \n\n                    supercls                                          cls  \\\n0      apparel & accessories                                       sleeve   \n1      apparel & accessories                                       sleeve   \n2      apparel & accessories                                       sleeve   \n3      apparel & accessories                                         shoe   \n4      apparel & accessories                                       sleeve   \n...                      ...                                          ...   \n42495                  other  hand-held computer, hand-held microcomputer   \n42496                  other                              radio, wireless   \n42497                  other                                  Windsor tie   \n42498                  other                             bulletproof vest   \n42499                  other                         dugong, Dugong dugon   \n\n                               dataset  val_only  \n0      imaterialist-fashion-2020-fgvc7       0.0  \n1      imaterialist-fashion-2020-fgvc7       0.0  \n2      imaterialist-fashion-2020-fgvc7       0.0  \n3      imaterialist-fashion-2020-fgvc7       0.0  \n4      imaterialist-fashion-2020-fgvc7       0.0  \n...                                ...       ...  \n42495                imagenetmini-1000       0.0  \n42496                imagenetmini-1000       0.0  \n42497                imagenetmini-1000       0.0  \n42498                imagenetmini-1000       0.0  \n42499                imagenetmini-1000       0.0  \n\n[42500 rows x 5 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>img_path</th>\n      <th>supercls</th>\n      <th>cls</th>\n      <th>dataset</th>\n      <th>val_only</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>shoe</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>42495</th>\n      <td>/kaggle/input/imagenetmini-1000/imagenet-mini/...</td>\n      <td>other</td>\n      <td>hand-held computer, hand-held microcomputer</td>\n      <td>imagenetmini-1000</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>42496</th>\n      <td>/kaggle/input/imagenetmini-1000/imagenet-mini/...</td>\n      <td>other</td>\n      <td>radio, wireless</td>\n      <td>imagenetmini-1000</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>42497</th>\n      <td>/kaggle/input/imagenetmini-1000/imagenet-mini/...</td>\n      <td>other</td>\n      <td>Windsor tie</td>\n      <td>imagenetmini-1000</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>42498</th>\n      <td>/kaggle/input/imagenetmini-1000/imagenet-mini/...</td>\n      <td>other</td>\n      <td>bulletproof vest</td>\n      <td>imagenetmini-1000</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>42499</th>\n      <td>/kaggle/input/imagenetmini-1000/imagenet-mini/...</td>\n      <td>other</td>\n      <td>dugong, Dugong dugon</td>\n      <td>imagenetmini-1000</td>\n      <td>0.0</td>\n    </tr>\n  </tbody>\n</table>\n<p>42500 rows × 5 columns</p>\n</div>"},"metadata":{}}]},{"cell_type":"markdown","source":"<br>\n\n**ImageNetSketch**\n* Take 5000","metadata":{}},{"cell_type":"code","source":"n_imagenetsketch=5000\ntmp_df = pd.DataFrame({\"img_path\":tf.io.gfile.glob(os.path.join(INPUT_DIR, \"imagenetsketch\", \"sketch\", \"**\", \"*.JPEG\"))})\ntmp_df[\"cls\"] = tmp_df[\"img_path\"].apply(lambda x: imagenet_cls_map[x.rsplit(\"/\", 2)[-2]])\ntmp_df[\"cls_cnt\"] = tmp_df.groupby(\"cls\")[\"cls\"].transform(\"count\")\ntmp_df = tmp_df.sort_values(by=\"cls_cnt\", ascending=False)\ntmp_df = tmp_df.head(n_imagenetsketch).sample(n_imagenetsketch).reset_index(drop=True)\ntmp_df = tmp_df[[\"img_path\", \"cls\"]]\n\ntmp_df[\"supercls\"] = \"illustrations\"\ntmp_df[\"dataset\"] = \"imagenetsketch\"\ntmp_df[\"val_only\"] = False\n\n# Update master dataframe\nmaster_df = pd.concat([master_df, tmp_df], ignore_index=True)\nmaster_df","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:24:04.316918Z","iopub.execute_input":"2023-04-19T02:24:04.317259Z","iopub.status.idle":"2023-04-19T02:24:16.274572Z","shell.execute_reply.started":"2023-04-19T02:24:04.317229Z","shell.execute_reply":"2023-04-19T02:24:16.273339Z"},"trusted":true},"execution_count":16,"outputs":[{"execution_count":16,"output_type":"execute_result","data":{"text/plain":"                                                img_path  \\\n0      ../input/imaterialist-fashion-2020-fgvc7/train...   \n1      ../input/imaterialist-fashion-2020-fgvc7/train...   \n2      ../input/imaterialist-fashion-2020-fgvc7/train...   \n3      ../input/imaterialist-fashion-2020-fgvc7/train...   \n4      ../input/imaterialist-fashion-2020-fgvc7/train...   \n...                                                  ...   \n47495  /kaggle/input/imagenetsketch/sketch/n01580077/...   \n47496  /kaggle/input/imagenetsketch/sketch/n03950228/...   \n47497  /kaggle/input/imagenetsketch/sketch/n04409515/...   \n47498  /kaggle/input/imagenetsketch/sketch/n01629819/...   \n47499  /kaggle/input/imagenetsketch/sketch/n02410509/...   \n\n                    supercls                                              cls  \\\n0      apparel & accessories                                           sleeve   \n1      apparel & accessories                                           sleeve   \n2      apparel & accessories                                           sleeve   \n3      apparel & accessories                                             shoe   \n4      apparel & accessories                                           sleeve   \n...                      ...                                              ...   \n47495          illustrations                                              jay   \n47496          illustrations                                    pitcher, ewer   \n47497          illustrations                                      tennis ball   \n47498          illustrations  European fire salamander, Salamandra salamandra   \n47499          illustrations                                            bison   \n\n                               dataset  val_only  \n0      imaterialist-fashion-2020-fgvc7       0.0  \n1      imaterialist-fashion-2020-fgvc7       0.0  \n2      imaterialist-fashion-2020-fgvc7       0.0  \n3      imaterialist-fashion-2020-fgvc7       0.0  \n4      imaterialist-fashion-2020-fgvc7       0.0  \n...                                ...       ...  \n47495                   imagenetsketch       0.0  \n47496                   imagenetsketch       0.0  \n47497                   imagenetsketch       0.0  \n47498                   imagenetsketch       0.0  \n47499                   imagenetsketch       0.0  \n\n[47500 rows x 5 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>img_path</th>\n      <th>supercls</th>\n      <th>cls</th>\n      <th>dataset</th>\n      <th>val_only</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>shoe</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>47495</th>\n      <td>/kaggle/input/imagenetsketch/sketch/n01580077/...</td>\n      <td>illustrations</td>\n      <td>jay</td>\n      <td>imagenetsketch</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>47496</th>\n      <td>/kaggle/input/imagenetsketch/sketch/n03950228/...</td>\n      <td>illustrations</td>\n      <td>pitcher, ewer</td>\n      <td>imagenetsketch</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>47497</th>\n      <td>/kaggle/input/imagenetsketch/sketch/n04409515/...</td>\n      <td>illustrations</td>\n      <td>tennis ball</td>\n      <td>imagenetsketch</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>47498</th>\n      <td>/kaggle/input/imagenetsketch/sketch/n01629819/...</td>\n      <td>illustrations</td>\n      <td>European fire salamander, Salamandra salamandra</td>\n      <td>imagenetsketch</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>47499</th>\n      <td>/kaggle/input/imagenetsketch/sketch/n02410509/...</td>\n      <td>illustrations</td>\n      <td>bison</td>\n      <td>imagenetsketch</td>\n      <td>0.0</td>\n    </tr>\n  </tbody>\n</table>\n<p>47500 rows × 5 columns</p>\n</div>"},"metadata":{}}]},{"cell_type":"markdown","source":"<br>\n\n**PixivPopularIllustrations**\n* Take 500 (no classes)","metadata":{}},{"cell_type":"code","source":"n_pixiv=500\ntmp_df = pd.DataFrame({\"img_path\":tf.io.gfile.glob(os.path.join(INPUT_DIR, \"pixiv-popular-illustrations\", \"pixiv_og_11062020\", \"*.jpg\"))})\ntmp_df = tmp_df.sample(n_pixiv).reset_index(drop=True)\ntmp_df[\"cls\"] = \"original_illustration\"\ntmp_df[\"supercls\"] = \"illustrations\"\ntmp_df[\"dataset\"] = \"pixiv-popular-illustrations\"\ntmp_df[\"val_only\"] = False\n\n# Update master dataframe\nmaster_df = pd.concat([master_df, tmp_df], ignore_index=True)\nmaster_df","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:24:16.275954Z","iopub.execute_input":"2023-04-19T02:24:16.276315Z","iopub.status.idle":"2023-04-19T02:24:17.357635Z","shell.execute_reply.started":"2023-04-19T02:24:16.276275Z","shell.execute_reply":"2023-04-19T02:24:17.356443Z"},"trusted":true},"execution_count":17,"outputs":[{"execution_count":17,"output_type":"execute_result","data":{"text/plain":"                                                img_path  \\\n0      ../input/imaterialist-fashion-2020-fgvc7/train...   \n1      ../input/imaterialist-fashion-2020-fgvc7/train...   \n2      ../input/imaterialist-fashion-2020-fgvc7/train...   \n3      ../input/imaterialist-fashion-2020-fgvc7/train...   \n4      ../input/imaterialist-fashion-2020-fgvc7/train...   \n...                                                  ...   \n47995  /kaggle/input/pixiv-popular-illustrations/pixi...   \n47996  /kaggle/input/pixiv-popular-illustrations/pixi...   \n47997  /kaggle/input/pixiv-popular-illustrations/pixi...   \n47998  /kaggle/input/pixiv-popular-illustrations/pixi...   \n47999  /kaggle/input/pixiv-popular-illustrations/pixi...   \n\n                    supercls                    cls  \\\n0      apparel & accessories                 sleeve   \n1      apparel & accessories                 sleeve   \n2      apparel & accessories                 sleeve   \n3      apparel & accessories                   shoe   \n4      apparel & accessories                 sleeve   \n...                      ...                    ...   \n47995          illustrations  original_illustration   \n47996          illustrations  original_illustration   \n47997          illustrations  original_illustration   \n47998          illustrations  original_illustration   \n47999          illustrations  original_illustration   \n\n                               dataset  val_only  \n0      imaterialist-fashion-2020-fgvc7       0.0  \n1      imaterialist-fashion-2020-fgvc7       0.0  \n2      imaterialist-fashion-2020-fgvc7       0.0  \n3      imaterialist-fashion-2020-fgvc7       0.0  \n4      imaterialist-fashion-2020-fgvc7       0.0  \n...                                ...       ...  \n47995      pixiv-popular-illustrations       0.0  \n47996      pixiv-popular-illustrations       0.0  \n47997      pixiv-popular-illustrations       0.0  \n47998      pixiv-popular-illustrations       0.0  \n47999      pixiv-popular-illustrations       0.0  \n\n[48000 rows x 5 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>img_path</th>\n      <th>supercls</th>\n      <th>cls</th>\n      <th>dataset</th>\n      <th>val_only</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>shoe</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>47995</th>\n      <td>/kaggle/input/pixiv-popular-illustrations/pixi...</td>\n      <td>illustrations</td>\n      <td>original_illustration</td>\n      <td>pixiv-popular-illustrations</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>47996</th>\n      <td>/kaggle/input/pixiv-popular-illustrations/pixi...</td>\n      <td>illustrations</td>\n      <td>original_illustration</td>\n      <td>pixiv-popular-illustrations</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>47997</th>\n      <td>/kaggle/input/pixiv-popular-illustrations/pixi...</td>\n      <td>illustrations</td>\n      <td>original_illustration</td>\n      <td>pixiv-popular-illustrations</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>47998</th>\n      <td>/kaggle/input/pixiv-popular-illustrations/pixi...</td>\n      <td>illustrations</td>\n      <td>original_illustration</td>\n      <td>pixiv-popular-illustrations</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>47999</th>\n      <td>/kaggle/input/pixiv-popular-illustrations/pixi...</td>\n      <td>illustrations</td>\n      <td>original_illustration</td>\n      <td>pixiv-popular-illustrations</td>\n      <td>0.0</td>\n    </tr>\n  </tbody>\n</table>\n<p>48000 rows × 5 columns</p>\n</div>"},"metadata":{}}]},{"cell_type":"markdown","source":"<br>\n\n**Memotion Dataset**\n* Take 2500","metadata":{}},{"cell_type":"code","source":"n_meme = 2500\ntmp_df = pd.read_csv(os.path.join(INPUT_DIR, \"memotion-dataset-7k/memotion_dataset_7k\", \"labels.csv\"))\ntmp_df[\"cls\"] = \"meme_\"+tmp_df[\"humour\"]+\"_\"+tmp_df[\"sarcasm\"]+\"_\"+tmp_df[\"offensive\"]+\"_\"+tmp_df[\"motivational\"]\ntmp_df[\"img_path\"] = os.path.join(INPUT_DIR, \"memotion-dataset-7k/memotion_dataset_7k\")+\"/images/\"+tmp_df[\"image_name\"]\ntmp_df[\"cls_cnt\"] = tmp_df.groupby(\"cls\")[\"cls\"].transform(\"count\")\ntmp_df = tmp_df.sort_values(by=\"cls_cnt\", ascending=False)\ntmp_df = tmp_df.head(n_meme).sample(n_meme).reset_index(drop=True)\ntmp_df = tmp_df[[\"img_path\", \"cls\"]]\ntmp_df[\"supercls\"] = \"memes\"\ntmp_df[\"dataset\"] = \"memotion-dataset-7k\"\ntmp_df[\"val_only\"] = False\n\n# Update master dataframe\nmaster_df = pd.concat([master_df, tmp_df], ignore_index=True)\nmaster_df","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:24:17.359298Z","iopub.execute_input":"2023-04-19T02:24:17.363223Z","iopub.status.idle":"2023-04-19T02:24:17.470661Z","shell.execute_reply.started":"2023-04-19T02:24:17.363181Z","shell.execute_reply":"2023-04-19T02:24:17.469308Z"},"trusted":true},"execution_count":18,"outputs":[{"execution_count":18,"output_type":"execute_result","data":{"text/plain":"                                                img_path  \\\n0      ../input/imaterialist-fashion-2020-fgvc7/train...   \n1      ../input/imaterialist-fashion-2020-fgvc7/train...   \n2      ../input/imaterialist-fashion-2020-fgvc7/train...   \n3      ../input/imaterialist-fashion-2020-fgvc7/train...   \n4      ../input/imaterialist-fashion-2020-fgvc7/train...   \n...                                                  ...   \n50495  /kaggle/input/memotion-dataset-7k/memotion_dat...   \n50496  /kaggle/input/memotion-dataset-7k/memotion_dat...   \n50497  /kaggle/input/memotion-dataset-7k/memotion_dat...   \n50498  /kaggle/input/memotion-dataset-7k/memotion_dat...   \n50499  /kaggle/input/memotion-dataset-7k/memotion_dat...   \n\n                    supercls  \\\n0      apparel & accessories   \n1      apparel & accessories   \n2      apparel & accessories   \n3      apparel & accessories   \n4      apparel & accessories   \n...                      ...   \n50495                  memes   \n50496                  memes   \n50497                  memes   \n50498                  memes   \n50499                  memes   \n\n                                                     cls  \\\n0                                                 sleeve   \n1                                                 sleeve   \n2                                                 sleeve   \n3                                                   shoe   \n4                                                 sleeve   \n...                                                  ...   \n50495    meme_very_funny_general_slight_not_motivational   \n50496  meme_not_funny_not_sarcastic_not_offensive_not...   \n50497  meme_not_funny_not_sarcastic_not_offensive_not...   \n50498  meme_funny_not_sarcastic_not_offensive_not_mot...   \n50499  meme_not_funny_not_sarcastic_not_offensive_not...   \n\n                               dataset  val_only  \n0      imaterialist-fashion-2020-fgvc7       0.0  \n1      imaterialist-fashion-2020-fgvc7       0.0  \n2      imaterialist-fashion-2020-fgvc7       0.0  \n3      imaterialist-fashion-2020-fgvc7       0.0  \n4      imaterialist-fashion-2020-fgvc7       0.0  \n...                                ...       ...  \n50495              memotion-dataset-7k       0.0  \n50496              memotion-dataset-7k       0.0  \n50497              memotion-dataset-7k       0.0  \n50498              memotion-dataset-7k       0.0  \n50499              memotion-dataset-7k       0.0  \n\n[50500 rows x 5 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>img_path</th>\n      <th>supercls</th>\n      <th>cls</th>\n      <th>dataset</th>\n      <th>val_only</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>shoe</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>50495</th>\n      <td>/kaggle/input/memotion-dataset-7k/memotion_dat...</td>\n      <td>memes</td>\n      <td>meme_very_funny_general_slight_not_motivational</td>\n      <td>memotion-dataset-7k</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>50496</th>\n      <td>/kaggle/input/memotion-dataset-7k/memotion_dat...</td>\n      <td>memes</td>\n      <td>meme_not_funny_not_sarcastic_not_offensive_not...</td>\n      <td>memotion-dataset-7k</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>50497</th>\n      <td>/kaggle/input/memotion-dataset-7k/memotion_dat...</td>\n      <td>memes</td>\n      <td>meme_not_funny_not_sarcastic_not_offensive_not...</td>\n      <td>memotion-dataset-7k</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>50498</th>\n      <td>/kaggle/input/memotion-dataset-7k/memotion_dat...</td>\n      <td>memes</td>\n      <td>meme_funny_not_sarcastic_not_offensive_not_mot...</td>\n      <td>memotion-dataset-7k</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>50499</th>\n      <td>/kaggle/input/memotion-dataset-7k/memotion_dat...</td>\n      <td>memes</td>\n      <td>meme_not_funny_not_sarcastic_not_offensive_not...</td>\n      <td>memotion-dataset-7k</td>\n      <td>0.0</td>\n    </tr>\n  </tbody>\n</table>\n<p>50500 rows × 5 columns</p>\n</div>"},"metadata":{}}]},{"cell_type":"markdown","source":"<br>\n\n**THE MET ART DATASET**\n* 500 artworks","metadata":{}},{"cell_type":"code","source":"n_met=500\n\ntmp_df=pd.DataFrame(load_json_to_dict(\"../input/the-met-dataset/ground_truth/mini_MET_database.json\"))\ntmp_df[\"img_path\"] = os.path.join(INPUT_DIR, \"the-met-dataset\", \"small_MET\")+\"/\"+tmp_df[\"path\"]\ntmp_df[\"cls\"] = \"met_art\"\ntmp_df = tmp_df[[\"img_path\", \"cls\"]].sample(n_met).reset_index(drop=True)\ntmp_df[\"supercls\"] = \"artworks\"\ntmp_df[\"dataset\"] = \"the-met-dataset\"\ntmp_df[\"val_only\"] = False\n\n# Update master dataframe\nmaster_df = pd.concat([master_df, tmp_df], ignore_index=True)\nmaster_df","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:24:17.472222Z","iopub.execute_input":"2023-04-19T02:24:17.472575Z","iopub.status.idle":"2023-04-19T02:24:17.593138Z","shell.execute_reply.started":"2023-04-19T02:24:17.472541Z","shell.execute_reply":"2023-04-19T02:24:17.591615Z"},"trusted":true},"execution_count":19,"outputs":[{"execution_count":19,"output_type":"execute_result","data":{"text/plain":"                                                img_path  \\\n0      ../input/imaterialist-fashion-2020-fgvc7/train...   \n1      ../input/imaterialist-fashion-2020-fgvc7/train...   \n2      ../input/imaterialist-fashion-2020-fgvc7/train...   \n3      ../input/imaterialist-fashion-2020-fgvc7/train...   \n4      ../input/imaterialist-fashion-2020-fgvc7/train...   \n...                                                  ...   \n50995  /kaggle/input/the-met-dataset/small_MET/MET/20...   \n50996  /kaggle/input/the-met-dataset/small_MET/MET/46...   \n50997  /kaggle/input/the-met-dataset/small_MET/MET/70...   \n50998  /kaggle/input/the-met-dataset/small_MET/MET/56...   \n50999  /kaggle/input/the-met-dataset/small_MET/MET/20...   \n\n                    supercls      cls                          dataset  \\\n0      apparel & accessories   sleeve  imaterialist-fashion-2020-fgvc7   \n1      apparel & accessories   sleeve  imaterialist-fashion-2020-fgvc7   \n2      apparel & accessories   sleeve  imaterialist-fashion-2020-fgvc7   \n3      apparel & accessories     shoe  imaterialist-fashion-2020-fgvc7   \n4      apparel & accessories   sleeve  imaterialist-fashion-2020-fgvc7   \n...                      ...      ...                              ...   \n50995               artworks  met_art                  the-met-dataset   \n50996               artworks  met_art                  the-met-dataset   \n50997               artworks  met_art                  the-met-dataset   \n50998               artworks  met_art                  the-met-dataset   \n50999               artworks  met_art                  the-met-dataset   \n\n       val_only  \n0           0.0  \n1           0.0  \n2           0.0  \n3           0.0  \n4           0.0  \n...         ...  \n50995       0.0  \n50996       0.0  \n50997       0.0  \n50998       0.0  \n50999       0.0  \n\n[51000 rows x 5 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>img_path</th>\n      <th>supercls</th>\n      <th>cls</th>\n      <th>dataset</th>\n      <th>val_only</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>shoe</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>50995</th>\n      <td>/kaggle/input/the-met-dataset/small_MET/MET/20...</td>\n      <td>artworks</td>\n      <td>met_art</td>\n      <td>the-met-dataset</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>50996</th>\n      <td>/kaggle/input/the-met-dataset/small_MET/MET/46...</td>\n      <td>artworks</td>\n      <td>met_art</td>\n      <td>the-met-dataset</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>50997</th>\n      <td>/kaggle/input/the-met-dataset/small_MET/MET/70...</td>\n      <td>artworks</td>\n      <td>met_art</td>\n      <td>the-met-dataset</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>50998</th>\n      <td>/kaggle/input/the-met-dataset/small_MET/MET/56...</td>\n      <td>artworks</td>\n      <td>met_art</td>\n      <td>the-met-dataset</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>50999</th>\n      <td>/kaggle/input/the-met-dataset/small_MET/MET/20...</td>\n      <td>artworks</td>\n      <td>met_art</td>\n      <td>the-met-dataset</td>\n      <td>0.0</td>\n    </tr>\n  </tbody>\n</table>\n<p>51000 rows × 5 columns</p>\n</div>"},"metadata":{}}]},{"cell_type":"markdown","source":"<br>\n\n**ARTWORK - PAINTING BY ARTIST**","metadata":{}},{"cell_type":"code","source":"n_art = 2500\n\ntmp_df = pd.DataFrame({\"img_path\":tf.io.gfile.glob(os.path.join(INPUT_DIR, \"best-artworks-of-all-time\", \"images\", \"images\", \"**\", \"*.jpg\"))})\ntmp_df[\"cls\"] = tmp_df.img_path.apply(lambda x: x.rsplit(\"/\", 2)[-2])\ntmp_df[\"cls_cnt\"] = tmp_df.groupby(\"cls\")[\"cls\"].transform(\"count\")\ntmp_df = tmp_df.sort_values(by=\"cls_cnt\", ascending=False)\ntmp_df = tmp_df.head(n_art).sample(n_art).reset_index(drop=True)\ntmp_df = tmp_df[[\"img_path\", \"cls\"]]\ntmp_df[\"supercls\"] = \"artworks\"\ntmp_df[\"dataset\"] = \"best-artworks-of-all-time\"\ntmp_df[\"val_only\"] = False\n\n# Update master dataframe\nmaster_df = pd.concat([master_df, tmp_df], ignore_index=True)\nmaster_df","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:24:17.594673Z","iopub.execute_input":"2023-04-19T02:24:17.595002Z","iopub.status.idle":"2023-04-19T02:24:19.841425Z","shell.execute_reply.started":"2023-04-19T02:24:17.594972Z","shell.execute_reply":"2023-04-19T02:24:19.83999Z"},"trusted":true},"execution_count":20,"outputs":[{"execution_count":20,"output_type":"execute_result","data":{"text/plain":"                                                img_path  \\\n0      ../input/imaterialist-fashion-2020-fgvc7/train...   \n1      ../input/imaterialist-fashion-2020-fgvc7/train...   \n2      ../input/imaterialist-fashion-2020-fgvc7/train...   \n3      ../input/imaterialist-fashion-2020-fgvc7/train...   \n4      ../input/imaterialist-fashion-2020-fgvc7/train...   \n...                                                  ...   \n53495  /kaggle/input/best-artworks-of-all-time/images...   \n53496  /kaggle/input/best-artworks-of-all-time/images...   \n53497  /kaggle/input/best-artworks-of-all-time/images...   \n53498  /kaggle/input/best-artworks-of-all-time/images...   \n53499  /kaggle/input/best-artworks-of-all-time/images...   \n\n                    supercls                    cls  \\\n0      apparel & accessories                 sleeve   \n1      apparel & accessories                 sleeve   \n2      apparel & accessories                 sleeve   \n3      apparel & accessories                   shoe   \n4      apparel & accessories                 sleeve   \n...                      ...                    ...   \n53495               artworks          Pablo_Picasso   \n53496               artworks            Edgar_Degas   \n53497               artworks            Edgar_Degas   \n53498               artworks            Edgar_Degas   \n53499               artworks  Pierre-Auguste_Renoir   \n\n                               dataset  val_only  \n0      imaterialist-fashion-2020-fgvc7       0.0  \n1      imaterialist-fashion-2020-fgvc7       0.0  \n2      imaterialist-fashion-2020-fgvc7       0.0  \n3      imaterialist-fashion-2020-fgvc7       0.0  \n4      imaterialist-fashion-2020-fgvc7       0.0  \n...                                ...       ...  \n53495        best-artworks-of-all-time       0.0  \n53496        best-artworks-of-all-time       0.0  \n53497        best-artworks-of-all-time       0.0  \n53498        best-artworks-of-all-time       0.0  \n53499        best-artworks-of-all-time       0.0  \n\n[53500 rows x 5 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>img_path</th>\n      <th>supercls</th>\n      <th>cls</th>\n      <th>dataset</th>\n      <th>val_only</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>shoe</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>53495</th>\n      <td>/kaggle/input/best-artworks-of-all-time/images...</td>\n      <td>artworks</td>\n      <td>Pablo_Picasso</td>\n      <td>best-artworks-of-all-time</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>53496</th>\n      <td>/kaggle/input/best-artworks-of-all-time/images...</td>\n      <td>artworks</td>\n      <td>Edgar_Degas</td>\n      <td>best-artworks-of-all-time</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>53497</th>\n      <td>/kaggle/input/best-artworks-of-all-time/images...</td>\n      <td>artworks</td>\n      <td>Edgar_Degas</td>\n      <td>best-artworks-of-all-time</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>53498</th>\n      <td>/kaggle/input/best-artworks-of-all-time/images...</td>\n      <td>artworks</td>\n      <td>Edgar_Degas</td>\n      <td>best-artworks-of-all-time</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>53499</th>\n      <td>/kaggle/input/best-artworks-of-all-time/images...</td>\n      <td>artworks</td>\n      <td>Pierre-Auguste_Renoir</td>\n      <td>best-artworks-of-all-time</td>\n      <td>0.0</td>\n    </tr>\n  </tbody>\n</table>\n<p>53500 rows × 5 columns</p>\n</div>"},"metadata":{}}]},{"cell_type":"markdown","source":"<br>\n\n**TOYS**\n\n* 500","metadata":{}},{"cell_type":"code","source":"tmp_df = pd.read_csv(os.path.join(INPUT_DIR, \"guie-toys-dataset\", \"toys.csv\"))\ntmp_df[\"img_path\"] = \"/kaggle/input/guie-toys-dataset/toys/\"+tmp_df[\"toy_name\"]+\".jpg\"\ntmp_df[\"cls\"] = \"misc_toy\"\ntmp_df = tmp_df[[\"img_path\", \"cls\"]].sample(500).reset_index(drop=True)\ntmp_df[\"supercls\"] = \"toys\"\ntmp_df[\"dataset\"] = \"guie-toys-dataset\"\ntmp_df[\"val_only\"] = False\n\n# Update master dataframe\nmaster_df = pd.concat([master_df, tmp_df], ignore_index=True)\nmaster_df","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:24:19.843202Z","iopub.execute_input":"2023-04-19T02:24:19.844414Z","iopub.status.idle":"2023-04-19T02:24:19.884579Z","shell.execute_reply.started":"2023-04-19T02:24:19.844355Z","shell.execute_reply":"2023-04-19T02:24:19.88321Z"},"trusted":true},"execution_count":21,"outputs":[{"execution_count":21,"output_type":"execute_result","data":{"text/plain":"                                                img_path  \\\n0      ../input/imaterialist-fashion-2020-fgvc7/train...   \n1      ../input/imaterialist-fashion-2020-fgvc7/train...   \n2      ../input/imaterialist-fashion-2020-fgvc7/train...   \n3      ../input/imaterialist-fashion-2020-fgvc7/train...   \n4      ../input/imaterialist-fashion-2020-fgvc7/train...   \n...                                                  ...   \n53995  /kaggle/input/guie-toys-dataset/toys/GI Joe Ma...   \n53996  /kaggle/input/guie-toys-dataset/toys/Fistful O...   \n53997  /kaggle/input/guie-toys-dataset/toys/Doodle Be...   \n53998  /kaggle/input/guie-toys-dataset/toys/Inchworm ...   \n53999  /kaggle/input/guie-toys-dataset/toys/Tamagotch...   \n\n                    supercls       cls                          dataset  \\\n0      apparel & accessories    sleeve  imaterialist-fashion-2020-fgvc7   \n1      apparel & accessories    sleeve  imaterialist-fashion-2020-fgvc7   \n2      apparel & accessories    sleeve  imaterialist-fashion-2020-fgvc7   \n3      apparel & accessories      shoe  imaterialist-fashion-2020-fgvc7   \n4      apparel & accessories    sleeve  imaterialist-fashion-2020-fgvc7   \n...                      ...       ...                              ...   \n53995                   toys  misc_toy                guie-toys-dataset   \n53996                   toys  misc_toy                guie-toys-dataset   \n53997                   toys  misc_toy                guie-toys-dataset   \n53998                   toys  misc_toy                guie-toys-dataset   \n53999                   toys  misc_toy                guie-toys-dataset   \n\n       val_only  \n0           0.0  \n1           0.0  \n2           0.0  \n3           0.0  \n4           0.0  \n...         ...  \n53995       0.0  \n53996       0.0  \n53997       0.0  \n53998       0.0  \n53999       0.0  \n\n[54000 rows x 5 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>img_path</th>\n      <th>supercls</th>\n      <th>cls</th>\n      <th>dataset</th>\n      <th>val_only</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>shoe</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>53995</th>\n      <td>/kaggle/input/guie-toys-dataset/toys/GI Joe Ma...</td>\n      <td>toys</td>\n      <td>misc_toy</td>\n      <td>guie-toys-dataset</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>53996</th>\n      <td>/kaggle/input/guie-toys-dataset/toys/Fistful O...</td>\n      <td>toys</td>\n      <td>misc_toy</td>\n      <td>guie-toys-dataset</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>53997</th>\n      <td>/kaggle/input/guie-toys-dataset/toys/Doodle Be...</td>\n      <td>toys</td>\n      <td>misc_toy</td>\n      <td>guie-toys-dataset</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>53998</th>\n      <td>/kaggle/input/guie-toys-dataset/toys/Inchworm ...</td>\n      <td>toys</td>\n      <td>misc_toy</td>\n      <td>guie-toys-dataset</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>53999</th>\n      <td>/kaggle/input/guie-toys-dataset/toys/Tamagotch...</td>\n      <td>toys</td>\n      <td>misc_toy</td>\n      <td>guie-toys-dataset</td>\n      <td>0.0</td>\n    </tr>\n  </tbody>\n</table>\n<p>54000 rows × 5 columns</p>\n</div>"},"metadata":{}}]},{"cell_type":"code","source":"n_toy_cars = 150\n\ntmp_df = pd.DataFrame({\"img_path\":tf.io.gfile.glob(os.path.join(INPUT_DIR, \"toy-car-dataset-lear\", \"toy_car_lear\", \"imstdsize\", \"*.png\"))})\ntmp_df = tmp_df.sample(n_toy_cars).reset_index(drop=True)\ntmp_df[\"cls\"] = \"toy_car\"\ntmp_df[\"supercls\"] = \"toys\"\ntmp_df[\"dataset\"] = \"toy-car-dataset-lear\"\ntmp_df[\"val_only\"] = False\n\n# Update master dataframe\nmaster_df = pd.concat([master_df, tmp_df], ignore_index=True)\nmaster_df","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:24:19.886013Z","iopub.execute_input":"2023-04-19T02:24:19.886391Z","iopub.status.idle":"2023-04-19T02:24:19.9777Z","shell.execute_reply.started":"2023-04-19T02:24:19.886357Z","shell.execute_reply":"2023-04-19T02:24:19.976238Z"},"trusted":true},"execution_count":22,"outputs":[{"execution_count":22,"output_type":"execute_result","data":{"text/plain":"                                                img_path  \\\n0      ../input/imaterialist-fashion-2020-fgvc7/train...   \n1      ../input/imaterialist-fashion-2020-fgvc7/train...   \n2      ../input/imaterialist-fashion-2020-fgvc7/train...   \n3      ../input/imaterialist-fashion-2020-fgvc7/train...   \n4      ../input/imaterialist-fashion-2020-fgvc7/train...   \n...                                                  ...   \n54145  /kaggle/input/toy-car-dataset-lear/toy_car_lea...   \n54146  /kaggle/input/toy-car-dataset-lear/toy_car_lea...   \n54147  /kaggle/input/toy-car-dataset-lear/toy_car_lea...   \n54148  /kaggle/input/toy-car-dataset-lear/toy_car_lea...   \n54149  /kaggle/input/toy-car-dataset-lear/toy_car_lea...   \n\n                    supercls      cls                          dataset  \\\n0      apparel & accessories   sleeve  imaterialist-fashion-2020-fgvc7   \n1      apparel & accessories   sleeve  imaterialist-fashion-2020-fgvc7   \n2      apparel & accessories   sleeve  imaterialist-fashion-2020-fgvc7   \n3      apparel & accessories     shoe  imaterialist-fashion-2020-fgvc7   \n4      apparel & accessories   sleeve  imaterialist-fashion-2020-fgvc7   \n...                      ...      ...                              ...   \n54145                   toys  toy_car             toy-car-dataset-lear   \n54146                   toys  toy_car             toy-car-dataset-lear   \n54147                   toys  toy_car             toy-car-dataset-lear   \n54148                   toys  toy_car             toy-car-dataset-lear   \n54149                   toys  toy_car             toy-car-dataset-lear   \n\n       val_only  \n0           0.0  \n1           0.0  \n2           0.0  \n3           0.0  \n4           0.0  \n...         ...  \n54145       0.0  \n54146       0.0  \n54147       0.0  \n54148       0.0  \n54149       0.0  \n\n[54150 rows x 5 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>img_path</th>\n      <th>supercls</th>\n      <th>cls</th>\n      <th>dataset</th>\n      <th>val_only</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>shoe</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel &amp; accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>54145</th>\n      <td>/kaggle/input/toy-car-dataset-lear/toy_car_lea...</td>\n      <td>toys</td>\n      <td>toy_car</td>\n      <td>toy-car-dataset-lear</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>54146</th>\n      <td>/kaggle/input/toy-car-dataset-lear/toy_car_lea...</td>\n      <td>toys</td>\n      <td>toy_car</td>\n      <td>toy-car-dataset-lear</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>54147</th>\n      <td>/kaggle/input/toy-car-dataset-lear/toy_car_lea...</td>\n      <td>toys</td>\n      <td>toy_car</td>\n      <td>toy-car-dataset-lear</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>54148</th>\n      <td>/kaggle/input/toy-car-dataset-lear/toy_car_lea...</td>\n      <td>toys</td>\n      <td>toy_car</td>\n      <td>toy-car-dataset-lear</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>54149</th>\n      <td>/kaggle/input/toy-car-dataset-lear/toy_car_lea...</td>\n      <td>toys</td>\n      <td>toy_car</td>\n      <td>toy-car-dataset-lear</td>\n      <td>0.0</td>\n    </tr>\n  </tbody>\n</table>\n<p>54150 rows × 5 columns</p>\n</div>"},"metadata":{}}]},{"cell_type":"code","source":"master_df[\"supercls\"] = master_df[\"supercls\"].str.replace(\" & \", \"_\").str.replace(\" \", \"_\")\nmaster_df = master_df[~master_df.img_path.str.contains(\"DS_Store\")]\nmaster_df[\"img_size\"] = master_df.img_path.progress_apply(lambda x: Image.open(x).size)\nmaster_df[\"img_width\"] = master_df[\"img_size\"].apply(lambda x: x[0])\nmaster_df[\"img_height\"] = master_df[\"img_size\"].apply(lambda x: x[1])\nmaster_df[\"img_area\"] = master_df[\"img_width\"]*master_df[\"img_height\"]\n\n# remove weird class stuff\nmaster_df[\"cls\"] = master_df[\"cls\"].str.replace(\", \", \"_\").str.replace(\" / \", \"_\").str.replace(\" \", \"_\").str.replace(\"-\", \"_\").str.lower()\n\n# limit to 5 underscores\nmaster_df[\"cls\"] = master_df[\"cls\"].astype(str).apply(lambda x: \"_\".join(x.split(\"_\")[:5]))\n\n# Fix shopee\nmaster_df[\"cls\"] = master_df[\"cls\"].apply(lambda x: \"shopee_product\" if x==\"nan\" else x)\n\n# Drop low occurence classes\nmaster_df = master_df[~master_df.cls.isin([k for k,v in master_df.cls.value_counts().items() if v<15])].reset_index(drop=True)\n\n# Drop VERY small images (all from imagenetmini)\nmaster_df = master_df[master_df.img_area>5000].reset_index(drop=True)\n\nmaster_df.to_csv(\"master.csv\", index=False)\nmaster_df","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:24:19.979336Z","iopub.execute_input":"2023-04-19T02:24:19.980137Z","iopub.status.idle":"2023-04-19T02:31:55.274248Z","shell.execute_reply.started":"2023-04-19T02:24:19.980088Z","shell.execute_reply":"2023-04-19T02:31:55.273019Z"},"trusted":true},"execution_count":23,"outputs":[{"output_type":"display_data","data":{"text/plain":"  0%|          | 0/54150 [00:00<?, ?it/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"e7ace1d867704d929cd13e7a7736fae7"}},"metadata":{}},{"execution_count":23,"output_type":"execute_result","data":{"text/plain":"                                                img_path             supercls  \\\n0      ../input/imaterialist-fashion-2020-fgvc7/train...  apparel_accessories   \n1      ../input/imaterialist-fashion-2020-fgvc7/train...  apparel_accessories   \n2      ../input/imaterialist-fashion-2020-fgvc7/train...  apparel_accessories   \n3      ../input/imaterialist-fashion-2020-fgvc7/train...  apparel_accessories   \n4      ../input/imaterialist-fashion-2020-fgvc7/train...  apparel_accessories   \n...                                                  ...                  ...   \n53509  /kaggle/input/toy-car-dataset-lear/toy_car_lea...                 toys   \n53510  /kaggle/input/toy-car-dataset-lear/toy_car_lea...                 toys   \n53511  /kaggle/input/toy-car-dataset-lear/toy_car_lea...                 toys   \n53512  /kaggle/input/toy-car-dataset-lear/toy_car_lea...                 toys   \n53513  /kaggle/input/toy-car-dataset-lear/toy_car_lea...                 toys   \n\n           cls                          dataset  val_only      img_size  \\\n0       sleeve  imaterialist-fashion-2020-fgvc7       0.0  (1000, 1500)   \n1       sleeve  imaterialist-fashion-2020-fgvc7       0.0  (3936, 2624)   \n2       sleeve  imaterialist-fashion-2020-fgvc7       0.0  (5472, 3648)   \n3         shoe  imaterialist-fashion-2020-fgvc7       0.0   (667, 1000)   \n4       sleeve  imaterialist-fashion-2020-fgvc7       0.0  (1941, 3000)   \n...        ...                              ...       ...           ...   \n53509  toy_car             toy-car-dataset-lear       0.0    (323, 150)   \n53510  toy_car             toy-car-dataset-lear       0.0    (443, 150)   \n53511  toy_car             toy-car-dataset-lear       0.0    (378, 150)   \n53512  toy_car             toy-car-dataset-lear       0.0    (355, 150)   \n53513  toy_car             toy-car-dataset-lear       0.0    (341, 150)   \n\n       img_width  img_height  img_area  \n0           1000        1500   1500000  \n1           3936        2624  10328064  \n2           5472        3648  19961856  \n3            667        1000    667000  \n4           1941        3000   5823000  \n...          ...         ...       ...  \n53509        323         150     48450  \n53510        443         150     66450  \n53511        378         150     56700  \n53512        355         150     53250  \n53513        341         150     51150  \n\n[53514 rows x 9 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>img_path</th>\n      <th>supercls</th>\n      <th>cls</th>\n      <th>dataset</th>\n      <th>val_only</th>\n      <th>img_size</th>\n      <th>img_width</th>\n      <th>img_height</th>\n      <th>img_area</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel_accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n      <td>(1000, 1500)</td>\n      <td>1000</td>\n      <td>1500</td>\n      <td>1500000</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel_accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n      <td>(3936, 2624)</td>\n      <td>3936</td>\n      <td>2624</td>\n      <td>10328064</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel_accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n      <td>(5472, 3648)</td>\n      <td>5472</td>\n      <td>3648</td>\n      <td>19961856</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel_accessories</td>\n      <td>shoe</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n      <td>(667, 1000)</td>\n      <td>667</td>\n      <td>1000</td>\n      <td>667000</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>../input/imaterialist-fashion-2020-fgvc7/train...</td>\n      <td>apparel_accessories</td>\n      <td>sleeve</td>\n      <td>imaterialist-fashion-2020-fgvc7</td>\n      <td>0.0</td>\n      <td>(1941, 3000)</td>\n      <td>1941</td>\n      <td>3000</td>\n      <td>5823000</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>53509</th>\n      <td>/kaggle/input/toy-car-dataset-lear/toy_car_lea...</td>\n      <td>toys</td>\n      <td>toy_car</td>\n      <td>toy-car-dataset-lear</td>\n      <td>0.0</td>\n      <td>(323, 150)</td>\n      <td>323</td>\n      <td>150</td>\n      <td>48450</td>\n    </tr>\n    <tr>\n      <th>53510</th>\n      <td>/kaggle/input/toy-car-dataset-lear/toy_car_lea...</td>\n      <td>toys</td>\n      <td>toy_car</td>\n      <td>toy-car-dataset-lear</td>\n      <td>0.0</td>\n      <td>(443, 150)</td>\n      <td>443</td>\n      <td>150</td>\n      <td>66450</td>\n    </tr>\n    <tr>\n      <th>53511</th>\n      <td>/kaggle/input/toy-car-dataset-lear/toy_car_lea...</td>\n      <td>toys</td>\n      <td>toy_car</td>\n      <td>toy-car-dataset-lear</td>\n      <td>0.0</td>\n      <td>(378, 150)</td>\n      <td>378</td>\n      <td>150</td>\n      <td>56700</td>\n    </tr>\n    <tr>\n      <th>53512</th>\n      <td>/kaggle/input/toy-car-dataset-lear/toy_car_lea...</td>\n      <td>toys</td>\n      <td>toy_car</td>\n      <td>toy-car-dataset-lear</td>\n      <td>0.0</td>\n      <td>(355, 150)</td>\n      <td>355</td>\n      <td>150</td>\n      <td>53250</td>\n    </tr>\n    <tr>\n      <th>53513</th>\n      <td>/kaggle/input/toy-car-dataset-lear/toy_car_lea...</td>\n      <td>toys</td>\n      <td>toy_car</td>\n      <td>toy-car-dataset-lear</td>\n      <td>0.0</td>\n      <td>(341, 150)</td>\n      <td>341</td>\n      <td>150</td>\n      <td>51150</td>\n    </tr>\n  </tbody>\n</table>\n<p>53514 rows × 9 columns</p>\n</div>"},"metadata":{}}]},{"cell_type":"markdown","source":"<br>\n\n**FUNCTIONS**","metadata":{}},{"cell_type":"code","source":"resize_layer = tf.keras.layers.Resizing(224,224, crop_to_aspect_ratio=True)\ndef resize_like_during_inference(img_path, _to_h=224, _to_w=224, preserve_ar=True):\n    img = tf.io.decode_image(tf.io.read_file(img_path))\n    return resize_layer(img).numpy().astype(np.uint8)\n\ndef save_row_to_disk(row_kwargs, dataset_dir=\"/kaggle/working/dataset\", image_size=(224,224), preserve_ar=True, **kwargs):\n    try:\n        resized_square_img = resize_like_during_inference(row_kwargs[\"img_path\"], image_size[1], image_size[0], preserve_ar)\n        dst_dir = os.path.join(dataset_dir, row_kwargs[\"supercls\"], row_kwargs[\"cls\"])\n        if not os.path.isdir(dst_dir): os.makedirs(dst_dir, exist_ok=True)\n        dst_path = os.path.join(dst_dir, row_kwargs[\"img_path\"].rsplit(\"/\", 1)[-1].rsplit(\".\", 1)[0]+\".png\")\n        cv2.imwrite(dst_path, resized_square_img[..., ::-1])\n    \n        if row_kwargs.name%250==0:\n            gc.collect(); gc.collect(); tf.keras.backend.clear_session(); gc.collect();      \n    except:\n        print(row_kwargs.name, row_kwargs.img_path)\n        pass","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:31:55.276023Z","iopub.execute_input":"2023-04-19T02:31:55.276494Z","iopub.status.idle":"2023-04-19T02:31:55.297623Z","shell.execute_reply.started":"2023-04-19T02:31:55.276448Z","shell.execute_reply":"2023-04-19T02:31:55.296384Z"},"trusted":true},"execution_count":24,"outputs":[]},{"cell_type":"markdown","source":"<br>\n\n**TEST**","metadata":{}},{"cell_type":"code","source":"_ = master_df.progress_apply(save_row_to_disk, axis=1)","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:31:55.299538Z","iopub.execute_input":"2023-04-19T02:31:55.300207Z","iopub.status.idle":"2023-04-19T02:57:07.940675Z","shell.execute_reply.started":"2023-04-19T02:31:55.300164Z","shell.execute_reply":"2023-04-19T02:57:07.939291Z"},"trusted":true},"execution_count":25,"outputs":[{"output_type":"display_data","data":{"text/plain":"  0%|          | 0/53514 [00:00<?, ?it/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"33e097391eaf4252a488e7f88464e8e9"}},"metadata":{}},{"name":"stderr","text":"libpng warning: Image width exceeds user limit in IHDR\nlibpng warning: Image height exceeds user limit in IHDR\nlibpng warning: Invalid image width in IHDR\nlibpng warning: Invalid image height in IHDR\nlibpng warning: Width is too large for libpng to process pixels\nlibpng error: Invalid IHDR data\nlibpng warning: Image width exceeds user limit in IHDR\nlibpng warning: Image height exceeds user limit in IHDR\nlibpng warning: Invalid image width in IHDR\nlibpng warning: Invalid image height in IHDR\nlibpng warning: Width is too large for libpng to process pixels\nlibpng error: Invalid IHDR data\nCorrupt JPEG data: 10 extraneous bytes before marker 0xd9\n","output_type":"stream"},{"name":"stdout","text":"52912 /kaggle/input/guie-toys-dataset/toys/Magical Emi the Magic Star.jpg\n52974 /kaggle/input/guie-toys-dataset/toys/Munchman tabletop electronic game.jpg\n","output_type":"stream"}]},{"cell_type":"code","source":"!du -sh ./*\n!ls ./dataset/*","metadata":{"execution":{"iopub.status.busy":"2023-04-19T02:57:07.943092Z","iopub.execute_input":"2023-04-19T02:57:07.943613Z","iopub.status.idle":"2023-04-19T02:57:10.515371Z","shell.execute_reply.started":"2023-04-19T02:57:07.94356Z","shell.execute_reply":"2023-04-19T02:57:10.513884Z"},"trusted":true},"execution_count":26,"outputs":[{"name":"stdout","text":"4.0K\t./__notebook_source__.ipynb\n4.0G\t./dataset\n8.5M\t./master.csv\n./dataset/apparel_accessories:\nshoe  sleeve\n\n./dataset/artworks:\nalbrecht_du╠êrer  met_art\t pierre_auguste_renoir\nedgar_degas\t  pablo_picasso  vincent_van_gogh\n\n./dataset/cars:\nbmw_3_series\t    fiat_500\t gmc_sierra_1500  porsche_911\nbmw_6_series\t    ford_f_150\t honda_civic\t  ram_1500\nchevrolet_colorado  ford_ranger  mini_cooper\n\n./dataset/dishes:\napple\t     butter\t coffee_with_caffeine  salad_leaf_salad_green  water\nbread_white  carrot_raw  jam\t\t       tomato_raw\t       wine_red\n\n./dataset/furniture:\nbed_bedroom_item  table_chair\n\n./dataset/illustrations:\n\"academic_gown_academic_robe_judge's\"\n affenpinscher_monkey_pinscher_monkey_dog\n american_coot_marsh_hen_mud\n banded_gecko\n bannister_banister_balustrade_balusters_handrail\n barbershop\n barometer\n bedlington_terrier\n bee\n bell_pepper\n bison\n black_and_tan_coonhound\n bonnet_poke_bonnet\n borzoi_russian_wolfhound\n bow_tie_bow_tie_bowtie\n brabancon_griffon\n breastplate_aegis_egis\n bulletproof_vest\n bustard\n canoe\n capuchin_ringtail_cebus_capucinus\n carton\n cellular_telephone_cellular_phone_cellphone\n chest\n collie\n coucal\n cougar_puma_catamount_mountain_lion\n crane\n crate\n cricket\n drilling_platform_offshore_rig\n dungeness_crab_cancer_magister\n entertainment_center\n european_fire_salamander_salamandra_salamandra\n fiddler_crab\n forklift\n french_loaf\n geyser\n golfcart_golf_cart\n grasshopper_hopper\n groom_bridegroom\n hair_spray\n hammer\n hamper\n home_theater_home_theatre\n jay\n jersey_t_shirt_tee_shirt\n kit_fox_vulpes_macrotis\n leaf_beetle_chrysomelid\n leonberg\n lesser_panda_red_panda_panda\n marimba_xylophone\n orangutan_orang_orangutang_pongo_pygmaeus\n original_illustration\n palace\n persian_cat\n picket_fence_paling\n pitcher_ewer\n plate\n platypus_duckbill_duckbilled_platypus_duck\n proboscis_monkey_nasalis_larvatus\n projectile_missile\n quail\n red_backed_sandpiper_dunlin_erolia\n reel\n rhinoceros_beetle\n ringlet_ringlet_butterfly\n rubber_eraser_rubber_pencil_eraser\n sandal\n sarong\n shoe_shop_shoe_shop_shoe\n ski\n skunk_polecat_wood_pussy\n snowmobile\n snowplow_snowplough\n sorrel\n soup_bowl\n spaghetti_squash\n starfish_sea_star\n steam_locomotive\n stole\n sturgeon\n suspension_bridge\n tennis_ball\n tiger_beetle\n toilet_tissue_toilet_paper_bathroom\n toy_poodle\n traffic_light_traffic_signal_stoplight\n trimaran\n valley_vale\n vine_snake\n walker_hound_walker_foxhound\n wallaby_brush_kangaroo\n wallet_billfold_notecase_pocketbook\n weevil\n whiptail_whiptail_lizard\n white_stork_ciconia_ciconia\n white_wolf_arctic_wolf_canis\n wig\n\"yellow_lady's_slipper_yellow_lady\"\n\n./dataset/landmarks:\nlandmark_100631  landmark_152708  landmark_194406  landmark_45428\nlandmark_101399  landmark_15445   landmark_194914  landmark_46705\nlandmark_102904  landmark_158818  landmark_195412  landmark_47133\nlandmark_103899  landmark_158844  landmark_19605   landmark_47378\nlandmark_10419\t landmark_160944  landmark_199450  landmark_48753\nlandmark_105496  landmark_161902  landmark_199506  landmark_51272\nlandmark_107164  landmark_162833  landmark_199507  landmark_51856\nlandmark_107323  landmark_163604  landmark_20064   landmark_55219\nlandmark_107801  landmark_164191  landmark_20102   landmark_55350\nlandmark_109169  landmark_164862  landmark_20120   landmark_57015\nlandmark_110153  landmark_165596  landmark_201840  landmark_57505\nlandmark_113209  landmark_165900  landmark_20409   landmark_6138\nlandmark_113838  landmark_168098  landmark_21635   landmark_6208\nlandmark_114289  landmark_168106  landmark_21703   landmark_64792\nlandmark_115821  landmark_169053  landmark_21843   landmark_65068\nlandmark_120734  landmark_171150  landmark_25093   landmark_65658\nlandmark_120885  landmark_171683  landmark_25457   landmark_65818\nlandmark_122418  landmark_173511  landmark_27\t   landmark_67406\nlandmark_124675  landmark_174181  landmark_27190   landmark_67929\nlandmark_125786  landmark_176018  landmark_27364   landmark_70088\nlandmark_126100  landmark_176528  landmark_28139   landmark_70644\nlandmark_126637  landmark_177409  landmark_28641   landmark_73211\nlandmark_127516  landmark_177870  landmark_29794   landmark_73300\nlandmark_132969  landmark_179626  landmark_31361   landmark_73304\nlandmark_133454  landmark_179959  landmark_31531   landmark_75005\nlandmark_13471\t landmark_180901  landmark_31837   landmark_76303\nlandmark_136093  landmark_183531  landmark_31898   landmark_80147\nlandmark_136302  landmark_18392   landmark_32338   landmark_80177\nlandmark_137203  landmark_184907  landmark_33992   landmark_80272\nlandmark_13866\t landmark_187779  landmark_36748   landmark_83144\nlandmark_138982  landmark_188999  landmark_38482   landmark_85633\nlandmark_139706  landmark_189811  landmark_38494   landmark_86869\nlandmark_139894  landmark_189907  landmark_39209   landmark_88483\nlandmark_143710  landmark_190216  landmark_39865   landmark_90021\nlandmark_144036  landmark_190822  landmark_40088   landmark_90396\nlandmark_144201  landmark_190956  landmark_41037   landmark_9070\nlandmark_145015  landmark_191292  landmark_41648   landmark_91274\nlandmark_147897  landmark_1924\t  landmark_41808   landmark_96663\nlandmark_14915\t landmark_192931  landmark_42016   landmark_98993\nlandmark_149980  landmark_193550  landmark_43845\n\n./dataset/memes:\nmeme_funny_general_not_offensive\tmeme_not_funny_not_sarcastic\nmeme_funny_general_slight_motivational\tmeme_very_funny_general_not\nmeme_funny_general_slight_not\t\tmeme_very_funny_general_slight\nmeme_funny_not_sarcastic_not\n\n./dataset/other:\n affenpinscher_monkey_pinscher_monkey_dog\n airplanes_101\n airship_dirigible\n assault_rifle_assault_gun\n backpack\n ballpoint_ballpoint_pen_ballpen_biro\n banded_gecko\n barn_spider_araneus_cavaticus\n barometer\n baseball_bat\n baseball_glove\n bathtub\n beaker\n billiards\n binder_ring_binder\n binoculars\n black_and_tan_coonhound\n bloodhound_sleuthhound\n bonsai_101\n boxing_glove\n brassiere_bra_bandeau\n breadmaker\n bulletproof_vest\n can_opener_tin_opener\n carton\n cassette_player\n chambered_nautilus_pearly_nautilus_nautilus\n chiffonier_commode\n clumber_clumber_spaniel\n clutter\n cockroach\n coin\n combination_lock\n comet\n computer_monitor\n corkscrew_bottle_screw\n curly_coated_retriever\n dandie_dinmont_dandie_dinmont_terrier\n digital_clock\n dugong_dugong_dugon\n electric_guitar_101\n elephant_101\n espresso_maker\n face_powder\n faces_easy_101\n fire_screen_fireguard\n golf_ball\n gorilla\n grapes\n grey_whale_gray_whale_devilfish\n hammock\n hand_held_computer_hand_held\n head_phones\n horse\n hot_tub\n hourglass\n japanese_spaniel\n joy_stick\n joystick\n knee_pad\n ladder\n laptop_101\n leopards_101\n letter_opener_paper_knife_paperknife\n light_house\n lightning\n lotion\n\"loupe_jeweler's_loupe\"\n magnetic_compass\n mailbag_postbag\n maltese_dog_maltese_terrier_maltese\n mars\n mattress\n measuring_cup\n minaret\n modem\n motorbikes_101\n mouse_computer_mouse\n mousetrap\n moving_van\n mushroom\n mussels\n neck_brace\n nipple\n overskirt\n panpipe_pandean_pipe_syrinx\n papillon\n pedestal_plinth_footstall\n penguin\n people\n petri_dish\n photocopier\n pick_plectrum_plectron\n piggy_bank_penny_bank\n\"plunger_plumber's_helper\"\n power_drill\n punching_bag_punch_bag_punching\n raccoon\n redbone\n rock_beauty_holocanthus_tricolor\n sealyham_terrier_sealyham\n slide_rule_slipstick\n soap_dispenser\n soccer_ball\n solar_dish_solar_collector_solar\n space_bar\n space_heater\n space_shuttle\n stove\n sunscreen_sunblock_sun_blocker\n sussex_spaniel\n sweatshirt\n switch_electric_switch_electrical_switch\n t_shirt\n table_lamp\n teapot\n teepee\n toy_terrier\n treadmill\n trench_coat\n tweezer\n velvet\n walker_hound_walker_foxhound\n watch_101\n whiskey_jug\n whistle\n windsor_tie\n wire_haired_fox_terrier\n yawl\n\n./dataset/packaged_goods:\nshopee_product\n\n./dataset/toys:\nmisc_toy  toy_car\n","output_type":"stream"}]}]}