From 810720bca1f18cba71ef03635dbf92e957ed96e3 Mon Sep 17 00:00:00 2001 From: Priyatham-sai-chand Date: Sun, 10 May 2020 22:25:15 +0530 Subject: [PATCH] Created using Colaboratory --- hivemind1.ipynb | 826 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 811 insertions(+), 15 deletions(-) diff --git a/hivemind1.ipynb b/hivemind1.ipynb index 357509a..fd3ed3b 100644 --- a/hivemind1.ipynb +++ b/hivemind1.ipynb @@ -6,12 +6,507 @@ "name": "hivemind1.ipynb", "provenance": [], "collapsed_sections": [], - "authorship_tag": "ABX9TyO9zwGIup9TCIcwyViG8gle", + "toc_visible": true, + "authorship_tag": "ABX9TyPDIxFOaQ6ugsOYXbj0e6It", "include_colab_link": true }, "kernelspec": { "name": "python3", "display_name": "Python 3" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "f24a2c9e820b4249ab63654b9ef56604": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HBoxModel", + "state": { + "_view_name": "HBoxView", + "_dom_classes": [], + "_model_name": "HBoxModel", + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.5.0", + "box_style": "", + "layout": "IPY_MODEL_e4dc73cf71714fd38dd09fd06a8608c7", + "_model_module": "@jupyter-widgets/controls", + "children": [ + "IPY_MODEL_652720149f1843cd964a3fae5a32b6d7", + "IPY_MODEL_a5b643a5d4db43769c04ded49d2ba09e" + ] + } + }, + "e4dc73cf71714fd38dd09fd06a8608c7": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "652720149f1843cd964a3fae5a32b6d7": { + "model_module": "@jupyter-widgets/controls", + "model_name": "FloatProgressModel", + "state": { + "_view_name": "ProgressView", + "style": "IPY_MODEL_2859a8220b6340fcba1862b35fbe5b91", + "_dom_classes": [], + "description": "UCF101TrainTestSplits-RecognitionTask.zip: 100%", + "_model_name": "FloatProgressModel", + "bar_style": "success", + "max": 113943, + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "value": 113943, + "_view_count": null, + "_view_module_version": "1.5.0", + "orientation": "horizontal", + "min": 0, + "description_tooltip": null, + "_model_module": "@jupyter-widgets/controls", + "layout": "IPY_MODEL_cfa563330e4b45cd9a4197bdf9ec6757" + } + }, + "a5b643a5d4db43769c04ded49d2ba09e": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "state": { + "_view_name": "HTMLView", + "style": "IPY_MODEL_838f5f7533314ade8fa3859ef7f46bf1", + "_dom_classes": [], + "description": "", + "_model_name": "HTMLModel", + "placeholder": "​", + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "value": " 111k/111k [00:00<00:00, 1.49MB/s]", + "_view_count": null, + "_view_module_version": "1.5.0", + "description_tooltip": null, + "_model_module": "@jupyter-widgets/controls", + "layout": "IPY_MODEL_6a30b268827f42e78da55a27979ddf47" + } + }, + "2859a8220b6340fcba1862b35fbe5b91": { + "model_module": "@jupyter-widgets/controls", + "model_name": "ProgressStyleModel", + "state": { + "_view_name": "StyleView", + "_model_name": "ProgressStyleModel", + "description_width": "initial", + "_view_module": "@jupyter-widgets/base", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.2.0", + "bar_color": null, + "_model_module": "@jupyter-widgets/controls" + } + }, + "cfa563330e4b45cd9a4197bdf9ec6757": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "838f5f7533314ade8fa3859ef7f46bf1": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "state": { + "_view_name": "StyleView", + "_model_name": "DescriptionStyleModel", + "description_width": "", + "_view_module": "@jupyter-widgets/base", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.2.0", + "_model_module": "@jupyter-widgets/controls" + } + }, + "6a30b268827f42e78da55a27979ddf47": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "d15b4d02e1d84ce9b218dde279f11c59": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HBoxModel", + "state": { + "_view_name": "HBoxView", + "_dom_classes": [], + "_model_name": "HBoxModel", + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.5.0", + "box_style": "", + "layout": "IPY_MODEL_446c92b5b92845249477c60af3f63faf", + "_model_module": "@jupyter-widgets/controls", + "children": [ + "IPY_MODEL_d63d7a10beab42179bcd6b4f5a433a49", + "IPY_MODEL_771d95358ad64e9c8742e416e61261da" + ] + } + }, + "446c92b5b92845249477c60af3f63faf": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "d63d7a10beab42179bcd6b4f5a433a49": { + "model_module": "@jupyter-widgets/controls", + "model_name": "FloatProgressModel", + "state": { + "_view_name": "ProgressView", + "style": "IPY_MODEL_767d69f1b35e4df8bb4e718772c02b20", + "_dom_classes": [], + "description": "UCF101.rar: 100%", + "_model_name": "FloatProgressModel", + "bar_style": "success", + "max": 6932971618, + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "value": 6932971618, + "_view_count": null, + "_view_module_version": "1.5.0", + "orientation": "horizontal", + "min": 0, + "description_tooltip": null, + "_model_module": "@jupyter-widgets/controls", + "layout": "IPY_MODEL_8741b1c90f514abc950d3cdf4d63b5bf" + } + }, + "771d95358ad64e9c8742e416e61261da": { + "model_module": "@jupyter-widgets/controls", + "model_name": "HTMLModel", + "state": { + "_view_name": "HTMLView", + "style": "IPY_MODEL_52f2278bb6f04526a08a75db50680708", + "_dom_classes": [], + "description": "", + "_model_name": "HTMLModel", + "placeholder": "​", + "_view_module": "@jupyter-widgets/controls", + "_model_module_version": "1.5.0", + "value": " 6.46G/6.46G [01:59<00:00, 57.8MB/s]", + "_view_count": null, + "_view_module_version": "1.5.0", + "description_tooltip": null, + "_model_module": "@jupyter-widgets/controls", + "layout": "IPY_MODEL_15696888463a4d668d7ff7e4f5c93ee3" + } + }, + "767d69f1b35e4df8bb4e718772c02b20": { + "model_module": "@jupyter-widgets/controls", + "model_name": "ProgressStyleModel", + "state": { + "_view_name": "StyleView", + "_model_name": "ProgressStyleModel", + "description_width": "initial", + "_view_module": "@jupyter-widgets/base", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.2.0", + "bar_color": null, + "_model_module": "@jupyter-widgets/controls" + } + }, + "8741b1c90f514abc950d3cdf4d63b5bf": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + }, + "52f2278bb6f04526a08a75db50680708": { + "model_module": "@jupyter-widgets/controls", + "model_name": "DescriptionStyleModel", + "state": { + "_view_name": "StyleView", + "_model_name": "DescriptionStyleModel", + "description_width": "", + "_view_module": "@jupyter-widgets/base", + "_model_module_version": "1.5.0", + "_view_count": null, + "_view_module_version": "1.2.0", + "_model_module": "@jupyter-widgets/controls" + } + }, + "15696888463a4d668d7ff7e4f5c93ee3": { + "model_module": "@jupyter-widgets/base", + "model_name": "LayoutModel", + "state": { + "_view_name": "LayoutView", + "grid_template_rows": null, + "right": null, + "justify_content": null, + "_view_module": "@jupyter-widgets/base", + "overflow": null, + "_model_module_version": "1.2.0", + "_view_count": null, + "flex_flow": null, + "width": null, + "min_width": null, + "border": null, + "align_items": null, + "bottom": null, + "_model_module": "@jupyter-widgets/base", + "top": null, + "grid_column": null, + "overflow_y": null, + "overflow_x": null, + "grid_auto_flow": null, + "grid_area": null, + "grid_template_columns": null, + "flex": null, + "_model_name": "LayoutModel", + "justify_items": null, + "grid_row": null, + "max_height": null, + "align_content": null, + "visibility": null, + "align_self": null, + "height": null, + "min_height": null, + "padding": null, + "grid_auto_rows": null, + "grid_gap": null, + "max_width": null, + "order": null, + "_view_module_version": "1.2.0", + "grid_template_areas": null, + "object_position": null, + "object_fit": null, + "grid_auto_columns": null, + "margin": null, + "display": null, + "left": null + } + } + } } }, "cells": [ @@ -49,7 +544,7 @@ "metadata": { "id": "VP1EHLddnnsE", "colab_type": "code", - "outputId": "376224f1-3c94-4a33-f67c-365cf9b253cd", + "outputId": "50c9d266-0e96-439d-d9d4-26140bf49299", "colab": { "base_uri": "https://localhost:8080/", "height": 34 @@ -62,7 +557,7 @@ "import matplotlib.pyplot as plt\n", "%matplotlib" ], - "execution_count": 0, + "execution_count": 1, "outputs": [ { "output_type": "stream", @@ -144,7 +639,7 @@ "metadata": { "id": "WoMb20oCvxY4", "colab_type": "code", - "outputId": "27dec63b-cc82-4947-8bec-7a46e508fc8d", + "outputId": "15265a3f-127a-4a30-855c-b16d25d7b1ab", "colab": { "base_uri": "https://localhost:8080/", "height": 173 @@ -165,7 +660,7 @@ "print(\"In Year 2017: \")\n", "print(result.tolist()) #pprint(result.tolist())" ], - "execution_count": 0, + "execution_count": 4, "outputs": [ { "output_type": "stream", @@ -248,7 +743,7 @@ "metadata": { "id": "Nhg53virJyIg", "colab_type": "code", - "outputId": "7a6fa3d4-5375-4dbd-829e-b8a188720b93", + "outputId": "50a6e85c-7c9e-431a-b062-07a457a12390", "colab": { "base_uri": "https://localhost:8080/", "height": 153 @@ -269,7 +764,7 @@ "print(\"In Year 2017: \")\n", "print(result['Country'].tolist()) " ], - "execution_count": 0, + "execution_count": 6, "outputs": [ { "output_type": "stream", @@ -340,7 +835,7 @@ "metadata": { "id": "APYCHnWqoSN4", "colab_type": "code", - "outputId": "bd9e0052-c93a-4d43-a7e2-9e1c0a4a0ca0", + "outputId": "6ebc9569-259d-4b41-83eb-c16cfd936ccc", "colab": { "base_uri": "https://localhost:8080/", "height": 1000 @@ -377,7 +872,7 @@ " result1 = happiest_in_region(df_2017,region)\n", " display(result1.append(result))\n" ], - "execution_count": 0, + "execution_count": 8, "outputs": [ { "output_type": "stream", @@ -3203,6 +3698,19 @@ "execution_count": 0, "outputs": [] }, + { + "cell_type": "code", + "metadata": { + "id": "2hOy7fcHBpPo", + "colab_type": "code", + "colab": {} + }, + "source": [ + "" + ], + "execution_count": 0, + "outputs": [] + }, { "cell_type": "markdown", "metadata": { @@ -3218,7 +3726,7 @@ "metadata": { "id": "HlJs38zPEfwS", "colab_type": "code", - "outputId": "f4769ee7-cece-46b4-80b8-3202974ca850", + "outputId": "073448a3-8891-41ad-bcfa-c8e4124ff325", "colab": { "base_uri": "https://localhost:8080/", "height": 80 @@ -3232,7 +3740,7 @@ "\n", "display(df_unhappy[df_unhappy['Country'].isin(df_happy['Country'])])\n" ], - "execution_count": 0, + "execution_count": 10, "outputs": [ { "output_type": "display_data", @@ -3306,13 +3814,13 @@ { "cell_type": "code", "metadata": { - "id": "IFEbl5VURGal", + "id": "EtqKYWLrBqcu", "colab_type": "code", - "outputId": "a83746a6-6999-4272-c5a7-bbba3d618278", "colab": { "base_uri": "https://localhost:8080/", "height": 80 - } + }, + "outputId": "e68e404b-d36b-49db-ce1f-75a0777920e9" }, "source": [ "## Run this cell ##\n", @@ -3323,7 +3831,7 @@ "df_merge['difference'] = df_merge['Happiness.Score'] - df_merge['Happiness Score']\n", "display(df_merge[df_merge['difference'] == df_merge['difference'].min()])" ], - "execution_count": 0, + "execution_count": 11, "outputs": [ { "output_type": "display_data", @@ -3375,6 +3883,294 @@ } } ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "mDHQGyPGL4DQ", + "colab_type": "text" + }, + "source": [ + "#Task 2\n", + "\n", + "In the same notebook write the script to download ​UDF101​ and\n", + "bring the training dataset in this format: (Labels can be downloaded\n", + "from ​here​)" + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "IFEbl5VURGal", + "colab_type": "code", + "outputId": "fa004cf9-4ef5-4d0f-b52f-f20ec76b384b", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 136 + } + }, + "source": [ + "!pip install pyunpack\n", + "!pip install patool\n", + "!pip install clint" + ], + "execution_count": 12, + "outputs": [ + { + "output_type": "stream", + "text": [ + "Requirement already satisfied: pyunpack in /usr/local/lib/python3.6/dist-packages (0.2.1)\n", + "Requirement already satisfied: easyprocess in /usr/local/lib/python3.6/dist-packages (from pyunpack) (0.3)\n", + "Requirement already satisfied: entrypoint2 in /usr/local/lib/python3.6/dist-packages (from pyunpack) (0.2.1)\n", + "Requirement already satisfied: argparse in /usr/local/lib/python3.6/dist-packages (from entrypoint2->pyunpack) (1.4.0)\n", + "Requirement already satisfied: patool in /usr/local/lib/python3.6/dist-packages (1.12)\n", + "Requirement already satisfied: clint in /usr/local/lib/python3.6/dist-packages (0.5.1)\n", + "Requirement already satisfied: args in /usr/local/lib/python3.6/dist-packages (from clint) (0.1.0)\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "y8iOvPEUQpkl", + "colab_type": "text" + }, + "source": [ + "Importing and Downloading the files" + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "uVWw1hiQB8dT", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 115, + "referenced_widgets": [ + "f24a2c9e820b4249ab63654b9ef56604", + "e4dc73cf71714fd38dd09fd06a8608c7", + "652720149f1843cd964a3fae5a32b6d7", + "a5b643a5d4db43769c04ded49d2ba09e", + "2859a8220b6340fcba1862b35fbe5b91", + "cfa563330e4b45cd9a4197bdf9ec6757", + "838f5f7533314ade8fa3859ef7f46bf1", + "6a30b268827f42e78da55a27979ddf47", + "d15b4d02e1d84ce9b218dde279f11c59", + "446c92b5b92845249477c60af3f63faf", + "d63d7a10beab42179bcd6b4f5a433a49", + "771d95358ad64e9c8742e416e61261da", + "767d69f1b35e4df8bb4e718772c02b20", + "8741b1c90f514abc950d3cdf4d63b5bf", + "52f2278bb6f04526a08a75db50680708", + "15696888463a4d668d7ff7e4f5c93ee3" + ] + }, + "outputId": "4429783e-b475-4c92-f131-36186ff751f2" + }, + "source": [ + "import os\n", + "import requests\n", + "from tqdm.auto import tqdm\n", + "from pyunpack import Archive\n", + "from clint.textui import progress\n", + "import shutil\n", + "\n", + "labels_url = \"https://www.crcv.ucf.edu/data/UCF101/UCF101TrainTestSplits-RecognitionTask.zip\"\n", + "data_url = \"https://www.crcv.ucf.edu/data/UCF101/UCF101.rar\"\n", + "\n", + "\n", + "os.chdir('/content')\n", + "\n", + "# labels file zip download\n", + "r = requests.get(labels_url, stream=True)\n", + "file_name = labels_url.split('/')[-1]\n", + "with tqdm.wrapattr(open(file_name, \"wb\"), \"write\", miniters=1,\n", + " total=int(r.headers.get('content-length', 0)),\n", + " desc=file_name) as fout:\n", + " for chunk in r.iter_content(chunk_size=4096):\n", + " fout.write(chunk)\n", + "\n", + "os.chdir('/content')\n", + "\n", + "# data file zip download\n", + "r = requests.get(data_url, stream=True)\n", + "file_name = data_url.split('/')[-1]\n", + "with tqdm.wrapattr(open(file_name, \"wb\"), \"write\", miniters=1,\n", + " total=int(r.headers.get('content-length', 0)),\n", + " desc=file_name) as fout:\n", + " for chunk in r.iter_content(chunk_size=4096):\n", + " fout.write(chunk)\n", + "\n", + " " + ], + "execution_count": 13, + "outputs": [ + { + "output_type": "display_data", + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "f24a2c9e820b4249ab63654b9ef56604", + "version_minor": 0, + "version_major": 2 + }, + "text/plain": [ + "HBox(children=(FloatProgress(value=0.0, description='UCF101TrainTestSplits-RecognitionTask.zip', max=113943.0,…" + ] + }, + "metadata": { + "tags": [] + } + }, + { + "output_type": "stream", + "text": [ + "\n" + ], + "name": "stdout" + }, + { + "output_type": "display_data", + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "d15b4d02e1d84ce9b218dde279f11c59", + "version_minor": 0, + "version_major": 2 + }, + "text/plain": [ + "HBox(children=(FloatProgress(value=0.0, description='UCF101.rar', max=6932971618.0, style=ProgressStyle(descri…" + ] + }, + "metadata": { + "tags": [] + } + }, + { + "output_type": "stream", + "text": [ + "\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "I44l5JdWB82u", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "outputId": "98b60e3a-d51f-4873-86f2-249705942754" + }, + "source": [ + "try:\n", + " Archive('UCF101.rar').extractall('/content')\n", + "except Exception:\n", + " print('The error is due to inconsistency in the rar to patool extractor The contents are safely extracted.')" + ], + "execution_count": 14, + "outputs": [ + { + "output_type": "stream", + "text": [ + "The error is due to inconsistency in the rar to patool extractor The contents are safely extracted.\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "xEM2TjFNMwpR", + "colab_type": "code", + "colab": {} + }, + "source": [ + "try:\n", + " Archive('UCF101TrainTestSplits-RecognitionTask.zip').extractall('/content')\n", + "except Exception:\n", + " print('The error is due to inconsistency in the rar to patool extractor The contents are safely extracted.')" + ], + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "dapsXkoAMyZ0", + "colab_type": "code", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 51 + }, + "outputId": "f879a905-7cd4-452c-a0f7-07b0f8a32e0b" + }, + "source": [ + "\n", + "os.chdir('/content/ucfTrainTestlist')\n", + "ucf_file_list = os.listdir()\n", + "ucf_temp = ucf_file_list[0:-1]\n", + "\n", + "#Finding the names of the actions \n", + "with open(ucf_file_list[-1],'r') as f:\n", + " names = []\n", + " for file in f:\n", + " res = \"\".join(filter(lambda x: not x.isdigit(), file))\n", + " names.append(res.strip().replace('\\n',''))\n", + "#Root directory in content folder of the notebook\n", + "os.chdir('/content')\n", + "os.mkdir('ucf101_result')\n", + "\n", + "#Creating the subfolders of train and test \n", + "os.chdir('/content/ucf101_result')\n", + "for subroot in ucf_temp:\n", + " subrootname,subrootextension = os.path.splitext(subroot)\n", + " os.mkdir(subrootname)\n", + "\n", + "#Creating names of actions in every train and test folders\n", + "os.chdir('/content/ucf101_result')\n", + "for subroot in ucf_temp:\n", + " subrootname,subrootextension = os.path.splitext(subroot)\n", + " os.chdir('/content/ucf101_result/'+subrootname)\n", + " for name in names:\n", + " os.mkdir(name)\n", + "\n", + "print(\"File manipulation started... \")\n", + "#Loopoing through the videos of UCF-101 to compare with video in the Labels\n", + "for name in names:\n", + " os.chdir('/content/UCF-101/' + name)\n", + " videos = os.listdir()\n", + " for video in videos: # video in the UCF-101\n", + " for subroot in ucf_temp:\n", + " os.chdir('/content/ucfTrainTestlist')\n", + " subrootname,subrootextension = os.path.splitext(subroot)\n", + " with open(subroot,'r') as f:\n", + " for filepath in f:\n", + " filename = filepath.split('/')[-1].strip()\n", + " if( filename == video): # Comparison \n", + " shutil.move('/content/UCF-101/'+name+'/'+video,'/content/ucf101_result/'+subrootname+'/'+name)\n", + "\n", + "\n", + "\n", + "print(\"File manipulation complete.\")" + ], + "execution_count": 16, + "outputs": [ + { + "output_type": "stream", + "text": [ + "File manipulation started... \n", + "File manipulation complete.\n" + ], + "name": "stdout" + } + ] } ] } \ No newline at end of file