{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "view-in-github"
   },
   "source": [
    "<a href=\"https://colab.research.google.com/github/open-mmlab/mmaction2/blob/master/demo/mmaction2_tutorial_zh-CN.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "VcjSRFELVbNk"
   },
   "source": [
    "# MMAction2 Tutorial\n",
    "\n",
    "- 用MMAction2的识别模型做一次推理\n",
    "- 用新数据集训练一个新的识别模型\n",
    "- 用MMAction2的时空检测模型做一次推理"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "7LqHGkGEVqpm"
   },
   "source": [
    "## 安装 MMAction2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "JUFfYElIB3cJ",
    "outputId": "cdf9ef1d-9e85-4a77-9e63-fc6f3ca13ae2"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch                         1.8.1+cu101        \n",
      "torchsummary                  1.5.1              \n",
      "torchtext                     0.9.1              \n",
      "torchvision                   0.9.1+cu101        \n"
     ]
    }
   ],
   "source": [
    "# 检查 nvcc，gcc 版本\n",
    "!nvcc -V\n",
    "!gcc --version"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "thuLEJ7lByQv",
    "outputId": "4035efd5-103e-4122-8107-a65777937ce7"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Looking in links: https://download.openmmlab.com/mmcv/dist/cu101/torch1.8.0/index.html\n",
      "Collecting mmcv-full\n",
      "\u001b[?25l  Downloading https://download.openmmlab.com/mmcv/dist/cu101/torch1.8.0/mmcv_full-1.3.5-cp37-cp37m-manylinux1_x86_64.whl (31.2MB)\n",
      "\u001b[K     |████████████████████████████████| 31.2MB 96kB/s \n",
      "\u001b[?25hRequirement already satisfied: pyyaml in /usr/local/lib/python3.7/dist-packages (from mmcv-full) (3.13)\n",
      "Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from mmcv-full) (1.19.5)\n",
      "Collecting addict\n",
      "  Downloading https://files.pythonhosted.org/packages/6a/00/b08f23b7d7e1e14ce01419a467b583edbb93c6cdb8654e54a9cc579cd61f/addict-2.4.0-py3-none-any.whl\n",
      "Requirement already satisfied: Pillow in /usr/local/lib/python3.7/dist-packages (from mmcv-full) (7.1.2)\n",
      "Requirement already satisfied: opencv-python>=3 in /usr/local/lib/python3.7/dist-packages (from mmcv-full) (4.1.2.30)\n",
      "Collecting yapf\n",
      "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/5f/0d/8814e79eb865eab42d95023b58b650d01dec6f8ea87fc9260978b1bf2167/yapf-0.31.0-py2.py3-none-any.whl (185kB)\n",
      "\u001b[K     |████████████████████████████████| 194kB 7.7MB/s \n",
      "\u001b[?25hInstalling collected packages: addict, yapf, mmcv-full\n",
      "Successfully installed addict-2.4.0 mmcv-full-1.3.5 yapf-0.31.0\n"
     ]
    }
   ],
   "source": [
    "# 安装 torch 及 torchvision\n",
    "!pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html\n",
    "\n",
    "# 安装 mmcv-full\n",
    "!pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.9.0/index.html\n",
    "\n",
    "# 安装 mmaction2\n",
    "!rm -rf mmaction2\n",
    "!git clone https://github.com/open-mmlab/mmaction2.git\n",
    "%cd mmaction2\n",
    "\n",
    "!pip install -e .\n",
    "\n",
    "# 安装其他可选依赖库\n",
    "!pip install -r requirements/optional.txt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 1000
    },
    "id": "qKiI1qelB6BT",
    "outputId": "1d269eaa-814a-48f5-dfe9-f6952cf5e851"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cloning into 'mmaction2'...\n",
      "remote: Enumerating objects: 11360, done.\u001b[K\n",
      "remote: Counting objects: 100% (1029/1029), done.\u001b[K\n",
      "remote: Compressing objects: 100% (587/587), done.\u001b[K\n",
      "remote: Total 11360 (delta 603), reused 721 (delta 436), pack-reused 10331\u001b[K\n",
      "Receiving objects: 100% (11360/11360), 37.17 MiB | 14.99 MiB/s, done.\n",
      "Resolving deltas: 100% (7930/7930), done.\n",
      "/content/mmaction2\n",
      "Branch 'fix_nms_config' set up to track remote branch 'fix_nms_config' from 'origin'.\n",
      "Switched to a new branch 'fix_nms_config'\n",
      "Obtaining file:///content/mmaction2\n",
      "Requirement already satisfied: matplotlib in /usr/local/lib/python3.7/dist-packages (from mmaction2==0.15.0) (3.2.2)\n",
      "Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from mmaction2==0.15.0) (1.19.5)\n",
      "Requirement already satisfied: opencv-contrib-python in /usr/local/lib/python3.7/dist-packages (from mmaction2==0.15.0) (4.1.2.30)\n",
      "Requirement already satisfied: Pillow in /usr/local/lib/python3.7/dist-packages (from mmaction2==0.15.0) (7.1.2)\n",
      "Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->mmaction2==0.15.0) (1.3.1)\n",
      "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.7/dist-packages (from matplotlib->mmaction2==0.15.0) (0.10.0)\n",
      "Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->mmaction2==0.15.0) (2.8.1)\n",
      "Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->mmaction2==0.15.0) (2.4.7)\n",
      "Requirement already satisfied: six in /usr/local/lib/python3.7/dist-packages (from cycler>=0.10->matplotlib->mmaction2==0.15.0) (1.15.0)\n",
      "Installing collected packages: mmaction2\n",
      "  Running setup.py develop for mmaction2\n",
      "Successfully installed mmaction2\n",
      "Collecting av\n",
      "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/66/ff/bacde7314c646a2bd2f240034809a10cc3f8b096751284d0828640fff3dd/av-8.0.3-cp37-cp37m-manylinux2010_x86_64.whl (37.2MB)\n",
      "\u001b[K     |████████████████████████████████| 37.2MB 81kB/s \n",
      "\u001b[?25hCollecting decord>=0.4.1\n",
      "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/64/5e/e2be6a3a3a46275059574d9c6a1d422aa6c7c3cbf6614939b8a3c3f8f2d5/decord-0.5.2-py3-none-manylinux2010_x86_64.whl (14.1MB)\n",
      "\u001b[K     |████████████████████████████████| 14.1MB 225kB/s \n",
      "\u001b[?25hRequirement already satisfied: imgaug in /usr/local/lib/python3.7/dist-packages (from -r requirements/optional.txt (line 3)) (0.2.9)\n",
      "Requirement already satisfied: librosa in /usr/local/lib/python3.7/dist-packages (from -r requirements/optional.txt (line 4)) (0.8.0)\n",
      "Requirement already satisfied: lmdb in /usr/local/lib/python3.7/dist-packages (from -r requirements/optional.txt (line 5)) (0.99)\n",
      "Requirement already satisfied: moviepy in /usr/local/lib/python3.7/dist-packages (from -r requirements/optional.txt (line 6)) (0.2.3.5)\n",
      "Collecting onnx\n",
      "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/3f/9b/54c950d3256e27f970a83cd0504efb183a24312702deed0179453316dbd0/onnx-1.9.0-cp37-cp37m-manylinux2010_x86_64.whl (12.2MB)\n",
      "\u001b[K     |████████████████████████████████| 12.2MB 26.1MB/s \n",
      "\u001b[?25hCollecting onnxruntime\n",
      "\u001b[?25l  Downloading https://files.pythonhosted.org/packages/f9/76/3d0f8bb2776961c7335693df06eccf8d099e48fa6fb552c7546867192603/onnxruntime-1.8.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.5MB)\n",
      "\u001b[K     |████████████████████████████████| 4.5MB 35.9MB/s \n",
      "\u001b[?25hCollecting PyTurboJPEG\n",
      "  Downloading https://files.pythonhosted.org/packages/07/70/8397de6c39476d2cc0fcee6082ade0225b3e67bc4466a0cf07486b0d0de4/PyTurboJPEG-1.5.0.tar.gz\n",
      "Requirement already satisfied: numpy>=1.14.0 in /usr/local/lib/python3.7/dist-packages (from decord>=0.4.1->-r requirements/optional.txt (line 2)) (1.19.5)\n",
      "Requirement already satisfied: matplotlib in /usr/local/lib/python3.7/dist-packages (from imgaug->-r requirements/optional.txt (line 3)) (3.2.2)\n",
      "Requirement already satisfied: imageio in /usr/local/lib/python3.7/dist-packages (from imgaug->-r requirements/optional.txt (line 3)) (2.4.1)\n",
      "Requirement already satisfied: scikit-image>=0.11.0 in /usr/local/lib/python3.7/dist-packages (from imgaug->-r requirements/optional.txt (line 3)) (0.16.2)\n",
      "Requirement already satisfied: Shapely in /usr/local/lib/python3.7/dist-packages (from imgaug->-r requirements/optional.txt (line 3)) (1.7.1)\n",
      "Requirement already satisfied: six in /usr/local/lib/python3.7/dist-packages (from imgaug->-r requirements/optional.txt (line 3)) (1.15.0)\n",
      "Requirement already satisfied: Pillow in /usr/local/lib/python3.7/dist-packages (from imgaug->-r requirements/optional.txt (line 3)) (7.1.2)\n",
      "Requirement already satisfied: opencv-python in /usr/local/lib/python3.7/dist-packages (from imgaug->-r requirements/optional.txt (line 3)) (4.1.2.30)\n",
      "Requirement already satisfied: scipy in /usr/local/lib/python3.7/dist-packages (from imgaug->-r requirements/optional.txt (line 3)) (1.4.1)\n",
      "Requirement already satisfied: audioread>=2.0.0 in /usr/local/lib/python3.7/dist-packages (from librosa->-r requirements/optional.txt (line 4)) (2.1.9)\n",
      "Requirement already satisfied: numba>=0.43.0 in /usr/local/lib/python3.7/dist-packages (from librosa->-r requirements/optional.txt (line 4)) (0.51.2)\n",
      "Requirement already satisfied: resampy>=0.2.2 in /usr/local/lib/python3.7/dist-packages (from librosa->-r requirements/optional.txt (line 4)) (0.2.2)\n",
      "Requirement already satisfied: pooch>=1.0 in /usr/local/lib/python3.7/dist-packages (from librosa->-r requirements/optional.txt (line 4)) (1.3.0)\n",
      "Requirement already satisfied: joblib>=0.14 in /usr/local/lib/python3.7/dist-packages (from librosa->-r requirements/optional.txt (line 4)) (1.0.1)\n",
      "Requirement already satisfied: decorator>=3.0.0 in /usr/local/lib/python3.7/dist-packages (from librosa->-r requirements/optional.txt (line 4)) (4.4.2)\n",
      "Requirement already satisfied: soundfile>=0.9.0 in /usr/local/lib/python3.7/dist-packages (from librosa->-r requirements/optional.txt (line 4)) (0.10.3.post1)\n",
      "Requirement already satisfied: scikit-learn!=0.19.0,>=0.14.0 in /usr/local/lib/python3.7/dist-packages (from librosa->-r requirements/optional.txt (line 4)) (0.22.2.post1)\n",
      "Requirement already satisfied: tqdm<5.0,>=4.11.2 in /usr/local/lib/python3.7/dist-packages (from moviepy->-r requirements/optional.txt (line 6)) (4.41.1)\n",
      "Requirement already satisfied: protobuf in /usr/local/lib/python3.7/dist-packages (from onnx->-r requirements/optional.txt (line 7)) (3.12.4)\n",
      "Requirement already satisfied: typing-extensions>=3.6.2.1 in /usr/local/lib/python3.7/dist-packages (from onnx->-r requirements/optional.txt (line 7)) (3.7.4.3)\n",
      "Requirement already satisfied: flatbuffers in /usr/local/lib/python3.7/dist-packages (from onnxruntime->-r requirements/optional.txt (line 8)) (1.12)\n",
      "Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->imgaug->-r requirements/optional.txt (line 3)) (2.8.1)\n",
      "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.7/dist-packages (from matplotlib->imgaug->-r requirements/optional.txt (line 3)) (0.10.0)\n",
      "Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->imgaug->-r requirements/optional.txt (line 3)) (1.3.1)\n",
      "Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->imgaug->-r requirements/optional.txt (line 3)) (2.4.7)\n",
      "Requirement already satisfied: networkx>=2.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image>=0.11.0->imgaug->-r requirements/optional.txt (line 3)) (2.5.1)\n",
      "Requirement already satisfied: PyWavelets>=0.4.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image>=0.11.0->imgaug->-r requirements/optional.txt (line 3)) (1.1.1)\n",
      "Requirement already satisfied: setuptools in /usr/local/lib/python3.7/dist-packages (from numba>=0.43.0->librosa->-r requirements/optional.txt (line 4)) (57.0.0)\n",
      "Requirement already satisfied: llvmlite<0.35,>=0.34.0.dev0 in /usr/local/lib/python3.7/dist-packages (from numba>=0.43.0->librosa->-r requirements/optional.txt (line 4)) (0.34.0)\n",
      "Requirement already satisfied: packaging in /usr/local/lib/python3.7/dist-packages (from pooch>=1.0->librosa->-r requirements/optional.txt (line 4)) (20.9)\n",
      "Requirement already satisfied: requests in /usr/local/lib/python3.7/dist-packages (from pooch>=1.0->librosa->-r requirements/optional.txt (line 4)) (2.23.0)\n",
      "Requirement already satisfied: appdirs in /usr/local/lib/python3.7/dist-packages (from pooch>=1.0->librosa->-r requirements/optional.txt (line 4)) (1.4.4)\n",
      "Requirement already satisfied: cffi>=1.0 in /usr/local/lib/python3.7/dist-packages (from soundfile>=0.9.0->librosa->-r requirements/optional.txt (line 4)) (1.14.5)\n",
      "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests->pooch>=1.0->librosa->-r requirements/optional.txt (line 4)) (1.24.3)\n",
      "Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests->pooch>=1.0->librosa->-r requirements/optional.txt (line 4)) (3.0.4)\n",
      "Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests->pooch>=1.0->librosa->-r requirements/optional.txt (line 4)) (2.10)\n",
      "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests->pooch>=1.0->librosa->-r requirements/optional.txt (line 4)) (2020.12.5)\n",
      "Requirement already satisfied: pycparser in /usr/local/lib/python3.7/dist-packages (from cffi>=1.0->soundfile>=0.9.0->librosa->-r requirements/optional.txt (line 4)) (2.20)\n",
      "Building wheels for collected packages: PyTurboJPEG\n",
      "  Building wheel for PyTurboJPEG (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
      "  Created wheel for PyTurboJPEG: filename=PyTurboJPEG-1.5.0-cp37-none-any.whl size=7478 sha256=ea928a968966ea04f37722e3866c986be613835f0598c242df7e44e6e9d6749b\n",
      "  Stored in directory: /root/.cache/pip/wheels/87/62/6a/834c085b372ce84e5f95addd832a860edd356711b9c7918424\n",
      "Successfully built PyTurboJPEG\n",
      "Installing collected packages: av, decord, onnx, onnxruntime, PyTurboJPEG\n",
      "Successfully installed PyTurboJPEG-1.5.0 av-8.0.3 decord-0.5.2 onnx-1.9.0 onnxruntime-1.8.0\n"
     ]
    },
    {
     "data": {
      "application/vnd.colab-display-data+json": {
       "pip_warning": {
        "packages": [
         "numpy"
        ]
       }
      }
     },
     "metadata": {
      "tags": []
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 克隆mmaction2项目\n",
    "# %cd /content/\n",
    "# !rm -rf mmaction2\n",
    "# !git clone https://github.com/open-mmlab/mmaction2.git\n",
    "!git clone https://github.com/wangruohui/mmaction2.git\n",
    "%cd /content/mmaction2\n",
    "!git checkout fix_nms_config\n",
    "\n",
    "# 以可编辑的模式安装mmaction\n",
    "!pip install -e .\n",
    "\n",
    "# 安装一些额外的依赖\n",
    "!pip install -r requirements/optional.txt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "No_zZAFpWC-a",
    "outputId": "ff4558ab-30ca-42b3-bf4b-27116d0629f7"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.8.1+cu101 True\n",
      "0.15.0\n",
      "10.1\n",
      "GCC 7.3\n"
     ]
    }
   ],
   "source": [
    "# 检查torch的安装以及gpu的使用\n",
    "import torch, torchvision\n",
    "print(torch.__version__, torch.cuda.is_available())\n",
    "\n",
    "# 检查MMAction2的安装\n",
    "import mmaction\n",
    "print(mmaction.__version__)\n",
    "\n",
    "# 检查mmcv的安装\n",
    "from mmcv.ops import get_compiling_cuda_version, get_compiler_version\n",
    "print(get_compiling_cuda_version())\n",
    "print(get_compiler_version())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "pXf7oV5DWdab"
   },
   "source": [
    "## MMAction2识别模型的推理"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "64CW6d_AaT-Q",
    "outputId": "8b1b0465-62a9-4a8b-b1a4-278a5f81945d"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--2021-06-03 15:01:35--  https://download.openmmlab.com/mmaction/recognition/tsn/tsn_r50_1x1x3_100e_kinetics400_rgb/tsn_r50_1x1x3_100e_kinetics400_rgb_20200614-e508be42.pth\n",
      "Resolving download.openmmlab.com (download.openmmlab.com)... 47.88.36.78\n",
      "Connecting to download.openmmlab.com (download.openmmlab.com)|47.88.36.78|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 97579339 (93M) [application/octet-stream]\n",
      "Saving to: ‘checkpoints/tsn_r50_1x1x3_100e_kinetics400_rgb_20200614-e508be42.pth’\n",
      "\n",
      "checkpoints/tsn_r50 100%[===================>]  93.06M  11.1MB/s    in 8.2s    \n",
      "\n",
      "2021-06-03 15:01:44 (11.4 MB/s) - ‘checkpoints/tsn_r50_1x1x3_100e_kinetics400_rgb_20200614-e508be42.pth’ saved [97579339/97579339]\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# 创建checkpoints文件夹并下载tsn模型\n",
    "!mkdir checkpoints\n",
    "!wget -c https://download.openmmlab.com/mmaction/recognition/tsn/tsn_r50_1x1x3_100e_kinetics400_rgb/tsn_r50_1x1x3_100e_kinetics400_rgb_20200614-e508be42.pth \\\n",
    "      -O checkpoints/tsn_r50_1x1x3_100e_kinetics400_rgb_20200614-e508be42.pth"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "HNZB7NoSabzj"
   },
   "outputs": [],
   "source": [
    "from mmaction.apis import inference_recognizer, init_recognizer\n",
    "\n",
    "# 选择tsn对应的配置文件\n",
    "config = 'configs/recognition/tsn/tsn_r50_video_inference_1x1x3_100e_kinetics400_rgb.py'\n",
    "# 加载上面下载的checkpoint文件\n",
    "checkpoint = 'checkpoints/tsn_r50_1x1x3_100e_kinetics400_rgb_20200614-e508be42.pth'\n",
    "# 初始化模型\n",
    "model = init_recognizer(config, checkpoint, device='cuda:0')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "rEMsBnpHapAn"
   },
   "outputs": [],
   "source": [
    "# 选择视频进行推理\n",
    "video = 'demo/demo.mp4'\n",
    "label = 'tools/data/kinetics/label_map_k400.txt'\n",
    "results = inference_recognizer(model, video)\n",
    "\n",
    "labels = open(label).readlines()\n",
    "labels = [x.strip() for x in labels]\n",
    "results = [(labels[k[0]], k[1]) for k in results]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "YqtUNVTQyLMJ"
   },
   "outputs": [],
   "source": [
    "# 查看视频\n",
    "from IPython.display import HTML\n",
    "from base64 import b64encode\n",
    "mp4 = open(video,'rb').read()\n",
    "data_url = \"data:video/mp4;base64,\" + b64encode(mp4).decode()\n",
    "HTML(\"\"\"\n",
    "<video width=400 controls>\n",
    "      <source src=\"%s\" type=\"video/mp4\">\n",
    "</video>\n",
    "\"\"\" % data_url)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "NIyJXqfWathq"
   },
   "outputs": [],
   "source": [
    "# 查看推理Top-5结果\n",
    "for result in results:\n",
    "    print(f'{result[0]}: ', result[1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "QuZG8kZ2fJ5d"
   },
   "source": [
    "## 在自定义数据集上训练模型\n",
    "训练新模型通常有三个步骤:\n",
    "- 支持新数据集\n",
    "- 修改配置文件\n",
    "- 训练模型\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "kbVu0-D-1JT2"
   },
   "source": [
    "### 支持新数据集\n",
    "\n",
    "这里我们给出将数据转换为已有数据集格式的示例。其他方法可以参考[doc]\(/docs/en/tutorials/new_dataset.md)\n",
    "\n",
    "用到的是一个从[Kinetics-400](https://deepmind.com/research/open-source/open-source-datasets/kinetics/)中获取的tiny数据集。包含30个训练视频，10个测试视频。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "gjsUj9JzgUlJ",
    "outputId": "7aa8f278-95c2-4073-8c93-2e197e12c6c2"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "rm: cannot remove 'kinetics400_tiny.zip*': No such file or directory\n",
      "--2021-06-03 14:55:03--  https://download.openmmlab.com/mmaction/kinetics400_tiny.zip\n",
      "Resolving download.openmmlab.com (download.openmmlab.com)... 47.88.36.78\n",
      "Connecting to download.openmmlab.com (download.openmmlab.com)|47.88.36.78|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 18308682 (17M) [application/zip]\n",
      "Saving to: ‘kinetics400_tiny.zip’\n",
      "\n",
      "kinetics400_tiny.zi 100%[===================>]  17.46M  10.5MB/s    in 1.7s    \n",
      "\n",
      "2021-06-03 14:55:07 (10.5 MB/s) - ‘kinetics400_tiny.zip’ saved [18308682/18308682]\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# 下载并解压数据集kinetics400_tiny\n",
    "!rm kinetics400_tiny.zip*\n",
    "!rm -rf kinetics400_tiny\n",
    "!wget https://download.openmmlab.com/mmaction/kinetics400_tiny.zip\n",
    "!unzip kinetics400_tiny.zip > /dev/null"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "AbZ-o7V6hNw4"
   },
   "outputs": [],
   "source": [
    "# 安装tree工具并检查数据集目录结构\n",
    "!apt-get -q install tree\n",
    "!tree kinetics400_tiny"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "fTdi6dI0hY3g"
   },
   "outputs": [],
   "source": [
    "# 查看标注文件格式\n",
    "!cat kinetics400_tiny/kinetics_tiny_train_video.txt"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "0bq0mxmEi29H"
   },
   "source": [
    "根据[`VideoDataset`](./datasets/video_dataset.py)中定义的格式，每一行表示样本视频的文件名和标签，用空格符分隔。\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "Ht_DGJA9jQar"
   },
   "source": [
    "### 修改配置文件\n",
    "\n",
    "我们需要修改配置文件，同时会用到之前下载的checkpoint作为pre-trained模型。\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "LjCcmCKOjktc"
   },
   "outputs": [],
   "source": [
    "# 获得tsn对应的配置文件cfg\n",
    "from mmcv import Config\n",
    "cfg = Config.fromfile('./configs/recognition/tsn/tsn_r50_video_1x1x8_100e_kinetics400_rgb.py')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "tc8YhFFGjp3e"
   },
   "source": [
    "我们在原本用于kinetics400-full数据集训练的tsn模型配置上进行修改，让模型可以在Kinetics400-tiny数据集上进行训练。\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "tlhu9byjjt-K",
    "outputId": "a1c04b76-9305-497d-9a97-cef55491a7ab"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Config:\n",
      "model = dict(\n",
      "    type='Recognizer2D',\n",
      "    backbone=dict(\n",
      "        type='ResNet',\n",
      "        pretrained='torchvision://resnet50',\n",
      "        depth=50,\n",
      "        norm_eval=False),\n",
      "    cls_head=dict(\n",
      "        type='TSNHead',\n",
      "        num_classes=2,\n",
      "        in_channels=2048,\n",
      "        spatial_type='avg',\n",
      "        consensus=dict(type='AvgConsensus', dim=1),\n",
      "        dropout_ratio=0.4,\n",
      "        init_std=0.01),\n",
      "    train_cfg=None,\n",
      "    test_cfg=dict(average_clips=None))\n",
      "optimizer = dict(type='SGD', lr=7.8125e-05, momentum=0.9, weight_decay=0.0001)\n",
      "optimizer_config = dict(grad_clip=dict(max_norm=40, norm_type=2))\n",
      "lr_config = dict(policy='step', step=[40, 80])\n",
      "total_epochs = 30\n",
      "checkpoint_config = dict(interval=10)\n",
      "log_config = dict(interval=5, hooks=[dict(type='TextLoggerHook')])\n",
      "dist_params = dict(backend='nccl')\n",
      "log_level = 'INFO'\n",
      "load_from = './checkpoints/tsn_r50_1x1x3_100e_kinetics400_rgb_20200614-e508be42.pth'\n",
      "resume_from = None\n",
      "workflow = [('train', 1)]\n",
      "dataset_type = 'VideoDataset'\n",
      "data_root = 'kinetics400_tiny/train/'\n",
      "data_root_val = 'kinetics400_tiny/val/'\n",
      "ann_file_train = 'kinetics400_tiny/kinetics_tiny_train_video.txt'\n",
      "ann_file_val = 'kinetics400_tiny/kinetics_tiny_val_video.txt'\n",
      "ann_file_test = 'kinetics400_tiny/kinetics_tiny_val_video.txt'\n",
      "img_norm_cfg = dict(\n",
      "    mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_bgr=False)\n",
      "train_pipeline = [\n",
      "    dict(type='DecordInit'),\n",
      "    dict(type='SampleFrames', clip_len=1, frame_interval=1, num_clips=8),\n",
      "    dict(type='DecordDecode'),\n",
      "    dict(\n",
      "        type='MultiScaleCrop',\n",
      "        input_size=224,\n",
      "        scales=(1, 0.875, 0.75, 0.66),\n",
      "        random_crop=False,\n",
      "        max_wh_scale_gap=1),\n",
      "    dict(type='Resize', scale=(224, 224), keep_ratio=False),\n",
      "    dict(type='Flip', flip_ratio=0.5),\n",
      "    dict(\n",
      "        type='Normalize',\n",
      "        mean=[123.675, 116.28, 103.53],\n",
      "        std=[58.395, 57.12, 57.375],\n",
      "        to_bgr=False),\n",
      "    dict(type='FormatShape', input_format='NCHW'),\n",
      "    dict(type='Collect', keys=['imgs', 'label'], meta_keys=[]),\n",
      "    dict(type='ToTensor', keys=['imgs', 'label'])\n",
      "]\n",
      "val_pipeline = [\n",
      "    dict(type='DecordInit'),\n",
      "    dict(\n",
      "        type='SampleFrames',\n",
      "        clip_len=1,\n",
      "        frame_interval=1,\n",
      "        num_clips=8,\n",
      "        test_mode=True),\n",
      "    dict(type='DecordDecode'),\n",
      "    dict(type='Resize', scale=(-1, 256)),\n",
      "    dict(type='CenterCrop', crop_size=224),\n",
      "    dict(type='Flip', flip_ratio=0),\n",
      "    dict(\n",
      "        type='Normalize',\n",
      "        mean=[123.675, 116.28, 103.53],\n",
      "        std=[58.395, 57.12, 57.375],\n",
      "        to_bgr=False),\n",
      "    dict(type='FormatShape', input_format='NCHW'),\n",
      "    dict(type='Collect', keys=['imgs', 'label'], meta_keys=[]),\n",
      "    dict(type='ToTensor', keys=['imgs'])\n",
      "]\n",
      "test_pipeline = [\n",
      "    dict(type='DecordInit'),\n",
      "    dict(\n",
      "        type='SampleFrames',\n",
      "        clip_len=1,\n",
      "        frame_interval=1,\n",
      "        num_clips=25,\n",
      "        test_mode=True),\n",
      "    dict(type='DecordDecode'),\n",
      "    dict(type='Resize', scale=(-1, 256)),\n",
      "    dict(type='ThreeCrop', crop_size=256),\n",
      "    dict(type='Flip', flip_ratio=0),\n",
      "    dict(\n",
      "        type='Normalize',\n",
      "        mean=[123.675, 116.28, 103.53],\n",
      "        std=[58.395, 57.12, 57.375],\n",
      "        to_bgr=False),\n",
      "    dict(type='FormatShape', input_format='NCHW'),\n",
      "    dict(type='Collect', keys=['imgs', 'label'], meta_keys=[]),\n",
      "    dict(type='ToTensor', keys=['imgs'])\n",
      "]\n",
      "data = dict(\n",
      "    videos_per_gpu=2,\n",
      "    workers_per_gpu=2,\n",
      "    train=dict(\n",
      "        type='VideoDataset',\n",
      "        ann_file='kinetics400_tiny/kinetics_tiny_train_video.txt',\n",
      "        data_prefix='kinetics400_tiny/train/',\n",
      "        pipeline=[\n",
      "            dict(type='DecordInit'),\n",
      "            dict(\n",
      "                type='SampleFrames', clip_len=1, frame_interval=1,\n",
      "                num_clips=8),\n",
      "            dict(type='DecordDecode'),\n",
      "            dict(\n",
      "                type='MultiScaleCrop',\n",
      "                input_size=224,\n",
      "                scales=(1, 0.875, 0.75, 0.66),\n",
      "                random_crop=False,\n",
      "                max_wh_scale_gap=1),\n",
      "            dict(type='Resize', scale=(224, 224), keep_ratio=False),\n",
      "            dict(type='Flip', flip_ratio=0.5),\n",
      "            dict(\n",
      "                type='Normalize',\n",
      "                mean=[123.675, 116.28, 103.53],\n",
      "                std=[58.395, 57.12, 57.375],\n",
      "                to_bgr=False),\n",
      "            dict(type='FormatShape', input_format='NCHW'),\n",
      "            dict(type='Collect', keys=['imgs', 'label'], meta_keys=[]),\n",
      "            dict(type='ToTensor', keys=['imgs', 'label'])\n",
      "        ]),\n",
      "    val=dict(\n",
      "        type='VideoDataset',\n",
      "        ann_file='kinetics400_tiny/kinetics_tiny_val_video.txt',\n",
      "        data_prefix='kinetics400_tiny/val/',\n",
      "        pipeline=[\n",
      "            dict(type='DecordInit'),\n",
      "            dict(\n",
      "                type='SampleFrames',\n",
      "                clip_len=1,\n",
      "                frame_interval=1,\n",
      "                num_clips=8,\n",
      "                test_mode=True),\n",
      "            dict(type='DecordDecode'),\n",
      "            dict(type='Resize', scale=(-1, 256)),\n",
      "            dict(type='CenterCrop', crop_size=224),\n",
      "            dict(type='Flip', flip_ratio=0),\n",
      "            dict(\n",
      "                type='Normalize',\n",
      "                mean=[123.675, 116.28, 103.53],\n",
      "                std=[58.395, 57.12, 57.375],\n",
      "                to_bgr=False),\n",
      "            dict(type='FormatShape', input_format='NCHW'),\n",
      "            dict(type='Collect', keys=['imgs', 'label'], meta_keys=[]),\n",
      "            dict(type='ToTensor', keys=['imgs'])\n",
      "        ]),\n",
      "    test=dict(\n",
      "        type='VideoDataset',\n",
      "        ann_file='kinetics400_tiny/kinetics_tiny_val_video.txt',\n",
      "        data_prefix='kinetics400_tiny/val/',\n",
      "        pipeline=[\n",
      "            dict(type='DecordInit'),\n",
      "            dict(\n",
      "                type='SampleFrames',\n",
      "                clip_len=1,\n",
      "                frame_interval=1,\n",
      "                num_clips=25,\n",
      "                test_mode=True),\n",
      "            dict(type='DecordDecode'),\n",
      "            dict(type='Resize', scale=(-1, 256)),\n",
      "            dict(type='ThreeCrop', crop_size=256),\n",
      "            dict(type='Flip', flip_ratio=0),\n",
      "            dict(\n",
      "                type='Normalize',\n",
      "                mean=[123.675, 116.28, 103.53],\n",
      "                std=[58.395, 57.12, 57.375],\n",
      "                to_bgr=False),\n",
      "            dict(type='FormatShape', input_format='NCHW'),\n",
      "            dict(type='Collect', keys=['imgs', 'label'], meta_keys=[]),\n",
      "            dict(type='ToTensor', keys=['imgs'])\n",
      "        ]))\n",
      "evaluation = dict(\n",
      "    interval=5, metrics=['top_k_accuracy', 'mean_class_accuracy'])\n",
      "work_dir = './tutorial_exps'\n",
      "omnisource = False\n",
      "seed = 0\n",
      "gpu_ids = range(0, 1)\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from mmcv.runner import set_random_seed\n",
    "\n",
    "# 修改数据集类型和各个文件路径\n",
    "cfg.dataset_type = 'VideoDataset'\n",
    "cfg.data_root = 'kinetics400_tiny/train/'\n",
    "cfg.data_root_val = 'kinetics400_tiny/val/'\n",
    "cfg.ann_file_train = 'kinetics400_tiny/kinetics_tiny_train_video.txt'\n",
    "cfg.ann_file_val = 'kinetics400_tiny/kinetics_tiny_val_video.txt'\n",
    "cfg.ann_file_test = 'kinetics400_tiny/kinetics_tiny_val_video.txt'\n",
    "\n",
    "cfg.data.test.type = 'VideoDataset'\n",
    "cfg.data.test.ann_file = 'kinetics400_tiny/kinetics_tiny_val_video.txt'\n",
    "cfg.data.test.data_prefix = 'kinetics400_tiny/val/'\n",
    "\n",
    "cfg.data.train.type = 'VideoDataset'\n",
    "cfg.data.train.ann_file = 'kinetics400_tiny/kinetics_tiny_train_video.txt'\n",
    "cfg.data.train.data_prefix = 'kinetics400_tiny/train/'\n",
    "\n",
    "cfg.data.val.type = 'VideoDataset'\n",
    "cfg.data.val.ann_file = 'kinetics400_tiny/kinetics_tiny_val_video.txt'\n",
    "cfg.data.val.data_prefix = 'kinetics400_tiny/val/'\n",
    "\n",
    "# 这里用于确认是否使用到omnisource训练\n",
    "cfg.setdefault('omnisource', False)\n",
    "# 修改cls_head中类别数为2\n",
    "cfg.model.cls_head.num_classes = 2\n",
    "# 使用预训练好的tsn模型\n",
    "cfg.load_from = './checkpoints/tsn_r50_1x1x3_100e_kinetics400_rgb_20200614-e508be42.pth'\n",
    "\n",
    "# 设置工作目录\n",
    "cfg.work_dir = './tutorial_exps'\n",
    "\n",
    "# 由于是单卡训练，修改对应的lr\n",
    "cfg.data.videos_per_gpu = cfg.data.videos_per_gpu // 16\n",
    "cfg.optimizer.lr = cfg.optimizer.lr / 8 / 16\n",
    "cfg.total_epochs = 30\n",
    "\n",
    "# 设置存档点间隔减少存储空间的消耗\n",
    "cfg.checkpoint_config.interval = 10\n",
    "# 设置日志打印间隔减少打印时间\n",
    "cfg.log_config.interval = 5\n",
    "\n",
    "# 固定随机种子使得结果可复现\n",
    "cfg.seed = 0\n",
    "set_random_seed(0, deterministic=False)\n",
    "cfg.gpu_ids = range(1)\n",
    "\n",
    "# 打印所有的配置参数\n",
    "print(f'Config:\\n{cfg.pretty_text}')\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "tES-qnZ3k38Z"
   },
   "source": [
    "### 训练识别模型\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 1000,
     "referenced_widgets": [
      "81bfbdf1ec55451b8be8a68fd1b0cf18",
      "4a9a4d1a6a554315a7d4362fd9ef0290",
      "c992b295041a4908a6a0d4f62a542cca",
      "57f2df1708fa455ea8a305b9100ad171",
      "8c947d1afee142e4b6cd2e0e26f46d6f",
      "adf3a16cdae740cf882999a25d53e8f7",
      "e6b45b124776452a85136fc3e18502f6",
      "974f4fceb03748f1b346b498df9828a3"
     ]
    },
    "id": "dDBWkdDRk6oz",
    "outputId": "574904cc-29fb-4b0a-ae2f-1dcba0248455"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Use load_from_torchvision loader\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Downloading: \"https://download.pytorch.org/models/resnet50-19c8e357.pth\" to /root/.cache/torch/hub/checkpoints/resnet50-19c8e357.pth\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "81bfbdf1ec55451b8be8a68fd1b0cf18",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "HBox(children=(FloatProgress(value=0.0, max=102502400.0), HTML(value='')))"
      ]
     },
     "metadata": {
      "tags": []
     },
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-06-03 15:02:48,410 - mmaction - INFO - These parameters in pretrained checkpoint are not loaded: {'fc.bias', 'fc.weight'}\n",
      "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py:477: UserWarning: This DataLoader will create 4 worker processes in total. Our suggested max number of worker in current system is 2, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary.\n",
      "  cpuset_checked))\n",
      "2021-06-03 15:02:59,146 - mmaction - INFO - load checkpoint from ./checkpoints/tsn_r50_1x1x3_100e_kinetics400_rgb_20200614-e508be42.pth\n",
      "2021-06-03 15:02:59,147 - mmaction - INFO - Use load_from_local loader\n",
      "2021-06-03 15:02:59,233 - mmaction - WARNING - The model and loaded state dict do not match exactly\n",
      "\n",
      "size mismatch for cls_head.fc_cls.weight: copying a param with shape torch.Size([400, 2048]) from checkpoint, the shape in current model is torch.Size([2, 2048]).\n",
      "size mismatch for cls_head.fc_cls.bias: copying a param with shape torch.Size([400]) from checkpoint, the shape in current model is torch.Size([2]).\n",
      "2021-06-03 15:02:59,235 - mmaction - INFO - Start running, host: root@dd065c1a509c, work_dir: /content/mmaction2/tutorial_exps\n",
      "2021-06-03 15:02:59,240 - mmaction - INFO - workflow: [('train', 1)], max: 30 epochs\n",
      "/usr/local/lib/python3.7/dist-packages/mmcv/runner/hooks/evaluation.py:144: UserWarning: runner.meta is None. Creating an empty one.\n",
      "  warnings.warn('runner.meta is None. Creating an empty one.')\n",
      "2021-06-03 15:03:03,913 - mmaction - INFO - Epoch [1][5/15]\tlr: 7.813e-05, eta: 0:06:55, time: 0.933, data_time: 0.701, memory: 1654, top1_acc: 0.4000, top5_acc: 1.0000, loss_cls: 0.7604, loss: 0.7604, grad_norm: 14.8813\n",
      "2021-06-03 15:03:04,822 - mmaction - INFO - Epoch [1][10/15]\tlr: 7.813e-05, eta: 0:04:05, time: 0.183, data_time: 0.006, memory: 1654, top1_acc: 0.7000, top5_acc: 1.0000, loss_cls: 0.6282, loss: 0.6282, grad_norm: 10.1833\n",
      "2021-06-03 15:03:05,630 - mmaction - INFO - Epoch [1][15/15]\tlr: 7.813e-05, eta: 0:03:05, time: 0.162, data_time: 0.002, memory: 1654, top1_acc: 0.4000, top5_acc: 1.0000, loss_cls: 0.7165, loss: 0.7165, grad_norm: 10.8552\n",
      "2021-06-03 15:03:09,840 - mmaction - INFO - Epoch [2][5/15]\tlr: 7.813e-05, eta: 0:03:45, time: 0.824, data_time: 0.620, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.6444, loss: 0.6444, grad_norm: 11.3933\n",
      "2021-06-03 15:03:11,318 - mmaction - INFO - Epoch [2][10/15]\tlr: 7.813e-05, eta: 0:03:23, time: 0.296, data_time: 0.109, memory: 1654, top1_acc: 0.5000, top5_acc: 1.0000, loss_cls: 0.7155, loss: 0.7155, grad_norm: 12.3879\n",
      "2021-06-03 15:03:12,109 - mmaction - INFO - Epoch [2][15/15]\tlr: 7.813e-05, eta: 0:02:58, time: 0.158, data_time: 0.001, memory: 1654, top1_acc: 0.5000, top5_acc: 1.0000, loss_cls: 0.6797, loss: 0.6797, grad_norm: 10.9274\n",
      "2021-06-03 15:03:16,265 - mmaction - INFO - Epoch [3][5/15]\tlr: 7.813e-05, eta: 0:03:19, time: 0.812, data_time: 0.613, memory: 1654, top1_acc: 0.4000, top5_acc: 1.0000, loss_cls: 0.7126, loss: 0.7126, grad_norm: 11.1647\n",
      "2021-06-03 15:03:17,416 - mmaction - INFO - Epoch [3][10/15]\tlr: 7.813e-05, eta: 0:03:04, time: 0.229, data_time: 0.049, memory: 1654, top1_acc: 0.4000, top5_acc: 1.0000, loss_cls: 0.6635, loss: 0.6635, grad_norm: 12.1194\n",
      "2021-06-03 15:03:18,283 - mmaction - INFO - Epoch [3][15/15]\tlr: 7.813e-05, eta: 0:02:49, time: 0.176, data_time: 0.014, memory: 1654, top1_acc: 0.5000, top5_acc: 1.0000, loss_cls: 0.6978, loss: 0.6978, grad_norm: 10.3157\n",
      "2021-06-03 15:03:22,394 - mmaction - INFO - Epoch [4][5/15]\tlr: 7.813e-05, eta: 0:03:03, time: 0.803, data_time: 0.595, memory: 1654, top1_acc: 0.5000, top5_acc: 1.0000, loss_cls: 0.6795, loss: 0.6795, grad_norm: 12.0900\n",
      "2021-06-03 15:03:23,662 - mmaction - INFO - Epoch [4][10/15]\tlr: 7.813e-05, eta: 0:02:53, time: 0.253, data_time: 0.067, memory: 1654, top1_acc: 0.4000, top5_acc: 1.0000, loss_cls: 0.7414, loss: 0.7414, grad_norm: 12.6038\n",
      "2021-06-03 15:03:24,541 - mmaction - INFO - Epoch [4][15/15]\tlr: 7.813e-05, eta: 0:02:42, time: 0.177, data_time: 0.010, memory: 1654, top1_acc: 0.5000, top5_acc: 1.0000, loss_cls: 0.6761, loss: 0.6761, grad_norm: 11.2109\n",
      "2021-06-03 15:03:28,677 - mmaction - INFO - Epoch [5][5/15]\tlr: 7.813e-05, eta: 0:02:52, time: 0.809, data_time: 0.594, memory: 1654, top1_acc: 0.4000, top5_acc: 1.0000, loss_cls: 0.6899, loss: 0.6899, grad_norm: 12.3528\n",
      "2021-06-03 15:03:29,778 - mmaction - INFO - Epoch [5][10/15]\tlr: 7.813e-05, eta: 0:02:43, time: 0.220, data_time: 0.026, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.6337, loss: 0.6337, grad_norm: 12.3525\n",
      "2021-06-03 15:03:30,887 - mmaction - INFO - Epoch [5][15/15]\tlr: 7.813e-05, eta: 0:02:36, time: 0.222, data_time: 0.058, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.6425, loss: 0.6425, grad_norm: 9.7286\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 10/10, 5.7 task/s, elapsed: 2s, ETA:     0s"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-06-03 15:03:32,826 - mmaction - INFO - Evaluating top_k_accuracy ...\n",
      "2021-06-03 15:03:32,828 - mmaction - INFO - \n",
      "top1_acc\t0.8000\n",
      "top5_acc\t1.0000\n",
      "2021-06-03 15:03:32,831 - mmaction - INFO - Evaluating mean_class_accuracy ...\n",
      "2021-06-03 15:03:32,836 - mmaction - INFO - \n",
      "mean_acc\t0.8000\n",
      "2021-06-03 15:03:33,250 - mmaction - INFO - Now best checkpoint is saved as best_top1_acc_epoch_5.pth.\n",
      "2021-06-03 15:03:33,251 - mmaction - INFO - Best top1_acc is 0.8000 at 5 epoch.\n",
      "2021-06-03 15:03:33,255 - mmaction - INFO - Epoch(val) [5][5]\ttop1_acc: 0.8000, top5_acc: 1.0000, mean_class_accuracy: 0.8000\n",
      "2021-06-03 15:03:37,510 - mmaction - INFO - Epoch [6][5/15]\tlr: 7.813e-05, eta: 0:02:44, time: 0.848, data_time: 0.638, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.5897, loss: 0.5897, grad_norm: 11.0816\n",
      "2021-06-03 15:03:38,830 - mmaction - INFO - Epoch [6][10/15]\tlr: 7.813e-05, eta: 0:02:38, time: 0.266, data_time: 0.094, memory: 1654, top1_acc: 0.6000, top5_acc: 1.0000, loss_cls: 0.6937, loss: 0.6937, grad_norm: 11.3882\n",
      "2021-06-03 15:03:39,638 - mmaction - INFO - Epoch [6][15/15]\tlr: 7.813e-05, eta: 0:02:30, time: 0.162, data_time: 0.002, memory: 1654, top1_acc: 0.5000, top5_acc: 1.0000, loss_cls: 0.6607, loss: 0.6607, grad_norm: 11.6493\n",
      "2021-06-03 15:03:43,948 - mmaction - INFO - Epoch [7][5/15]\tlr: 7.813e-05, eta: 0:02:36, time: 0.844, data_time: 0.643, memory: 1654, top1_acc: 0.7000, top5_acc: 1.0000, loss_cls: 0.6503, loss: 0.6503, grad_norm: 12.5117\n",
      "2021-06-03 15:03:45,085 - mmaction - INFO - Epoch [7][10/15]\tlr: 7.813e-05, eta: 0:02:30, time: 0.228, data_time: 0.047, memory: 1654, top1_acc: 0.9000, top5_acc: 1.0000, loss_cls: 0.6313, loss: 0.6313, grad_norm: 10.8442\n",
      "2021-06-03 15:03:45,922 - mmaction - INFO - Epoch [7][15/15]\tlr: 7.813e-05, eta: 0:02:24, time: 0.167, data_time: 0.002, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.6310, loss: 0.6310, grad_norm: 10.5798\n",
      "2021-06-03 15:03:50,322 - mmaction - INFO - Epoch [8][5/15]\tlr: 7.813e-05, eta: 0:02:28, time: 0.863, data_time: 0.662, memory: 1654, top1_acc: 0.7000, top5_acc: 1.0000, loss_cls: 0.6283, loss: 0.6283, grad_norm: 11.3411\n",
      "2021-06-03 15:03:51,521 - mmaction - INFO - Epoch [8][10/15]\tlr: 7.813e-05, eta: 0:02:23, time: 0.240, data_time: 0.055, memory: 1654, top1_acc: 0.6000, top5_acc: 1.0000, loss_cls: 0.6765, loss: 0.6765, grad_norm: 11.1512\n",
      "2021-06-03 15:03:52,331 - mmaction - INFO - Epoch [8][15/15]\tlr: 7.813e-05, eta: 0:02:17, time: 0.162, data_time: 0.001, memory: 1654, top1_acc: 0.6000, top5_acc: 1.0000, loss_cls: 0.5961, loss: 0.5961, grad_norm: 11.1990\n",
      "2021-06-03 15:03:56,661 - mmaction - INFO - Epoch [9][5/15]\tlr: 7.813e-05, eta: 0:02:21, time: 0.848, data_time: 0.645, memory: 1654, top1_acc: 0.7000, top5_acc: 1.0000, loss_cls: 0.6524, loss: 0.6524, grad_norm: 11.9008\n",
      "2021-06-03 15:03:57,882 - mmaction - INFO - Epoch [9][10/15]\tlr: 7.813e-05, eta: 0:02:16, time: 0.244, data_time: 0.061, memory: 1654, top1_acc: 0.6000, top5_acc: 1.0000, loss_cls: 0.6937, loss: 0.6937, grad_norm: 13.0136\n",
      "2021-06-03 15:03:58,697 - mmaction - INFO - Epoch [9][15/15]\tlr: 7.813e-05, eta: 0:02:11, time: 0.163, data_time: 0.001, memory: 1654, top1_acc: 0.9000, top5_acc: 1.0000, loss_cls: 0.5511, loss: 0.5511, grad_norm: 9.5135\n",
      "2021-06-03 15:04:02,948 - mmaction - INFO - Epoch [10][5/15]\tlr: 7.813e-05, eta: 0:02:14, time: 0.831, data_time: 0.631, memory: 1654, top1_acc: 0.9000, top5_acc: 1.0000, loss_cls: 0.5565, loss: 0.5565, grad_norm: 9.2178\n",
      "2021-06-03 15:04:03,954 - mmaction - INFO - Epoch [10][10/15]\tlr: 7.813e-05, eta: 0:02:09, time: 0.202, data_time: 0.006, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.6199, loss: 0.6199, grad_norm: 10.8341\n",
      "2021-06-03 15:04:04,855 - mmaction - INFO - Epoch [10][15/15]\tlr: 7.813e-05, eta: 0:02:05, time: 0.180, data_time: 0.011, memory: 1654, top1_acc: 0.7000, top5_acc: 1.0000, loss_cls: 0.5853, loss: 0.5853, grad_norm: 10.9314\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 10/10, 5.8 task/s, elapsed: 2s, ETA:     0s"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-06-03 15:04:06,763 - mmaction - INFO - Evaluating top_k_accuracy ...\n",
      "2021-06-03 15:04:06,765 - mmaction - INFO - \n",
      "top1_acc\t0.8000\n",
      "top5_acc\t1.0000\n",
      "2021-06-03 15:04:06,766 - mmaction - INFO - Evaluating mean_class_accuracy ...\n",
      "2021-06-03 15:04:06,770 - mmaction - INFO - \n",
      "mean_acc\t0.8000\n",
      "2021-06-03 15:04:06,772 - mmaction - INFO - Saving checkpoint at 10 epochs\n",
      "2021-06-03 15:04:07,188 - mmaction - INFO - Epoch(val) [10][5]\ttop1_acc: 0.8000, top5_acc: 1.0000, mean_class_accuracy: 0.8000\n",
      "2021-06-03 15:04:11,319 - mmaction - INFO - Epoch [11][5/15]\tlr: 7.813e-05, eta: 0:02:06, time: 0.825, data_time: 0.620, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.5100, loss: 0.5100, grad_norm: 8.8945\n",
      "2021-06-03 15:04:12,449 - mmaction - INFO - Epoch [11][10/15]\tlr: 7.813e-05, eta: 0:02:02, time: 0.226, data_time: 0.042, memory: 1654, top1_acc: 0.2000, top5_acc: 1.0000, loss_cls: 0.6959, loss: 0.6959, grad_norm: 13.3499\n",
      "2021-06-03 15:04:13,350 - mmaction - INFO - Epoch [11][15/15]\tlr: 7.813e-05, eta: 0:01:58, time: 0.180, data_time: 0.014, memory: 1654, top1_acc: 0.9000, top5_acc: 1.0000, loss_cls: 0.4929, loss: 0.4929, grad_norm: 8.5170\n",
      "2021-06-03 15:04:17,700 - mmaction - INFO - Epoch [12][5/15]\tlr: 7.813e-05, eta: 0:02:00, time: 0.851, data_time: 0.649, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.6076, loss: 0.6076, grad_norm: 11.6095\n",
      "2021-06-03 15:04:18,762 - mmaction - INFO - Epoch [12][10/15]\tlr: 7.813e-05, eta: 0:01:56, time: 0.213, data_time: 0.032, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.5356, loss: 0.5356, grad_norm: 9.7047\n",
      "2021-06-03 15:04:19,608 - mmaction - INFO - Epoch [12][15/15]\tlr: 7.813e-05, eta: 0:01:52, time: 0.169, data_time: 0.002, memory: 1654, top1_acc: 0.5000, top5_acc: 1.0000, loss_cls: 0.6340, loss: 0.6340, grad_norm: 11.7714\n",
      "2021-06-03 15:04:23,829 - mmaction - INFO - Epoch [13][5/15]\tlr: 7.813e-05, eta: 0:01:53, time: 0.825, data_time: 0.611, memory: 1654, top1_acc: 0.9000, top5_acc: 1.0000, loss_cls: 0.5467, loss: 0.5467, grad_norm: 9.3259\n",
      "2021-06-03 15:04:24,969 - mmaction - INFO - Epoch [13][10/15]\tlr: 7.813e-05, eta: 0:01:49, time: 0.230, data_time: 0.042, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.5878, loss: 0.5878, grad_norm: 11.7431\n",
      "2021-06-03 15:04:25,994 - mmaction - INFO - Epoch [13][15/15]\tlr: 7.813e-05, eta: 0:01:46, time: 0.205, data_time: 0.038, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.5018, loss: 0.5018, grad_norm: 8.9612\n",
      "2021-06-03 15:04:30,330 - mmaction - INFO - Epoch [14][5/15]\tlr: 7.813e-05, eta: 0:01:46, time: 0.850, data_time: 0.643, memory: 1654, top1_acc: 0.5000, top5_acc: 1.0000, loss_cls: 0.6634, loss: 0.6634, grad_norm: 12.9608\n",
      "2021-06-03 15:04:31,497 - mmaction - INFO - Epoch [14][10/15]\tlr: 7.813e-05, eta: 0:01:43, time: 0.232, data_time: 0.048, memory: 1654, top1_acc: 0.7000, top5_acc: 1.0000, loss_cls: 0.5646, loss: 0.5646, grad_norm: 10.2523\n",
      "2021-06-03 15:04:32,322 - mmaction - INFO - Epoch [14][15/15]\tlr: 7.813e-05, eta: 0:01:39, time: 0.166, data_time: 0.004, memory: 1654, top1_acc: 0.5000, top5_acc: 1.0000, loss_cls: 0.6504, loss: 0.6504, grad_norm: 12.5382\n",
      "2021-06-03 15:04:36,355 - mmaction - INFO - Epoch [15][5/15]\tlr: 7.813e-05, eta: 0:01:39, time: 0.789, data_time: 0.589, memory: 1654, top1_acc: 0.5000, top5_acc: 1.0000, loss_cls: 0.5893, loss: 0.5893, grad_norm: 11.1704\n",
      "2021-06-03 15:04:37,811 - mmaction - INFO - Epoch [15][10/15]\tlr: 7.813e-05, eta: 0:01:36, time: 0.291, data_time: 0.117, memory: 1654, top1_acc: 0.6000, top5_acc: 1.0000, loss_cls: 0.6413, loss: 0.6413, grad_norm: 12.5114\n",
      "2021-06-03 15:04:38,647 - mmaction - INFO - Epoch [15][15/15]\tlr: 7.813e-05, eta: 0:01:33, time: 0.167, data_time: 0.001, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.4747, loss: 0.4747, grad_norm: 8.3424\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 10/10, 5.7 task/s, elapsed: 2s, ETA:     0s"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-06-03 15:04:40,575 - mmaction - INFO - Evaluating top_k_accuracy ...\n",
      "2021-06-03 15:04:40,576 - mmaction - INFO - \n",
      "top1_acc\t0.8000\n",
      "top5_acc\t1.0000\n",
      "2021-06-03 15:04:40,586 - mmaction - INFO - Evaluating mean_class_accuracy ...\n",
      "2021-06-03 15:04:40,589 - mmaction - INFO - \n",
      "mean_acc\t0.8000\n",
      "2021-06-03 15:04:40,590 - mmaction - INFO - Epoch(val) [15][5]\ttop1_acc: 0.8000, top5_acc: 1.0000, mean_class_accuracy: 0.8000\n",
      "2021-06-03 15:04:44,502 - mmaction - INFO - Epoch [16][5/15]\tlr: 7.813e-05, eta: 0:01:33, time: 0.780, data_time: 0.572, memory: 1654, top1_acc: 0.9000, top5_acc: 1.0000, loss_cls: 0.4760, loss: 0.4760, grad_norm: 8.9694\n",
      "2021-06-03 15:04:45,694 - mmaction - INFO - Epoch [16][10/15]\tlr: 7.813e-05, eta: 0:01:30, time: 0.237, data_time: 0.049, memory: 1654, top1_acc: 0.6000, top5_acc: 1.0000, loss_cls: 0.5583, loss: 0.5583, grad_norm: 11.0941\n",
      "2021-06-03 15:04:46,780 - mmaction - INFO - Epoch [16][15/15]\tlr: 7.813e-05, eta: 0:01:27, time: 0.219, data_time: 0.053, memory: 1654, top1_acc: 0.7000, top5_acc: 1.0000, loss_cls: 0.5707, loss: 0.5707, grad_norm: 11.3002\n",
      "2021-06-03 15:04:51,458 - mmaction - INFO - Epoch [17][5/15]\tlr: 7.813e-05, eta: 0:01:27, time: 0.918, data_time: 0.705, memory: 1654, top1_acc: 0.7000, top5_acc: 1.0000, loss_cls: 0.5781, loss: 0.5781, grad_norm: 11.3368\n",
      "2021-06-03 15:04:52,369 - mmaction - INFO - Epoch [17][10/15]\tlr: 7.813e-05, eta: 0:01:24, time: 0.181, data_time: 0.004, memory: 1654, top1_acc: 0.7000, top5_acc: 1.0000, loss_cls: 0.5642, loss: 0.5642, grad_norm: 10.7471\n",
      "2021-06-03 15:04:53,264 - mmaction - INFO - Epoch [17][15/15]\tlr: 7.813e-05, eta: 0:01:21, time: 0.180, data_time: 0.014, memory: 1654, top1_acc: 0.9000, top5_acc: 1.0000, loss_cls: 0.4448, loss: 0.4448, grad_norm: 7.9083\n",
      "2021-06-03 15:04:57,485 - mmaction - INFO - Epoch [18][5/15]\tlr: 7.813e-05, eta: 0:01:20, time: 0.827, data_time: 0.617, memory: 1654, top1_acc: 1.0000, top5_acc: 1.0000, loss_cls: 0.4346, loss: 0.4346, grad_norm: 8.5470\n",
      "2021-06-03 15:04:58,807 - mmaction - INFO - Epoch [18][10/15]\tlr: 7.813e-05, eta: 0:01:17, time: 0.265, data_time: 0.077, memory: 1654, top1_acc: 0.9000, top5_acc: 1.0000, loss_cls: 0.4648, loss: 0.4648, grad_norm: 8.6081\n",
      "2021-06-03 15:04:59,651 - mmaction - INFO - Epoch [18][15/15]\tlr: 7.813e-05, eta: 0:01:14, time: 0.169, data_time: 0.002, memory: 1654, top1_acc: 0.6000, top5_acc: 1.0000, loss_cls: 0.6353, loss: 0.6353, grad_norm: 12.7139\n",
      "2021-06-03 15:05:04,048 - mmaction - INFO - Epoch [19][5/15]\tlr: 7.813e-05, eta: 0:01:14, time: 0.860, data_time: 0.654, memory: 1654, top1_acc: 0.9000, top5_acc: 1.0000, loss_cls: 0.5173, loss: 0.5173, grad_norm: 10.0505\n",
      "2021-06-03 15:05:05,140 - mmaction - INFO - Epoch [19][10/15]\tlr: 7.813e-05, eta: 0:01:11, time: 0.220, data_time: 0.032, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.4610, loss: 0.4610, grad_norm: 9.0271\n",
      "2021-06-03 15:05:05,992 - mmaction - INFO - Epoch [19][15/15]\tlr: 7.813e-05, eta: 0:01:08, time: 0.170, data_time: 0.003, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.4900, loss: 0.4900, grad_norm: 9.4134\n",
      "2021-06-03 15:05:10,251 - mmaction - INFO - Epoch [20][5/15]\tlr: 7.813e-05, eta: 0:01:07, time: 0.832, data_time: 0.633, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.4717, loss: 0.4717, grad_norm: 9.3263\n",
      "2021-06-03 15:05:11,296 - mmaction - INFO - Epoch [20][10/15]\tlr: 7.813e-05, eta: 0:01:05, time: 0.210, data_time: 0.010, memory: 1654, top1_acc: 0.7000, top5_acc: 1.0000, loss_cls: 0.6269, loss: 0.6269, grad_norm: 12.3093\n",
      "2021-06-03 15:05:12,249 - mmaction - INFO - Epoch [20][15/15]\tlr: 7.813e-05, eta: 0:01:02, time: 0.191, data_time: 0.022, memory: 1654, top1_acc: 0.7000, top5_acc: 1.0000, loss_cls: 0.6329, loss: 0.6329, grad_norm: 11.7156\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 10/10, 5.8 task/s, elapsed: 2s, ETA:     0s"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-06-03 15:05:14,159 - mmaction - INFO - Evaluating top_k_accuracy ...\n",
      "2021-06-03 15:05:14,161 - mmaction - INFO - \n",
      "top1_acc\t1.0000\n",
      "top5_acc\t1.0000\n",
      "2021-06-03 15:05:14,166 - mmaction - INFO - Evaluating mean_class_accuracy ...\n",
      "2021-06-03 15:05:14,168 - mmaction - INFO - \n",
      "mean_acc\t1.0000\n",
      "2021-06-03 15:05:14,599 - mmaction - INFO - Now best checkpoint is saved as best_top1_acc_epoch_20.pth.\n",
      "2021-06-03 15:05:14,603 - mmaction - INFO - Best top1_acc is 1.0000 at 20 epoch.\n",
      "2021-06-03 15:05:14,606 - mmaction - INFO - Saving checkpoint at 20 epochs\n",
      "2021-06-03 15:05:15,008 - mmaction - INFO - Epoch(val) [20][5]\ttop1_acc: 1.0000, top5_acc: 1.0000, mean_class_accuracy: 1.0000\n",
      "2021-06-03 15:05:19,127 - mmaction - INFO - Epoch [21][5/15]\tlr: 7.813e-05, eta: 0:01:01, time: 0.823, data_time: 0.618, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.3904, loss: 0.3904, grad_norm: 7.6698\n",
      "2021-06-03 15:05:20,196 - mmaction - INFO - Epoch [21][10/15]\tlr: 7.813e-05, eta: 0:00:58, time: 0.214, data_time: 0.024, memory: 1654, top1_acc: 0.6000, top5_acc: 1.0000, loss_cls: 0.5884, loss: 0.5884, grad_norm: 11.4530\n",
      "2021-06-03 15:05:21,218 - mmaction - INFO - Epoch [21][15/15]\tlr: 7.813e-05, eta: 0:00:56, time: 0.204, data_time: 0.032, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.5800, loss: 0.5800, grad_norm: 12.1364\n",
      "2021-06-03 15:05:25,640 - mmaction - INFO - Epoch [22][5/15]\tlr: 7.813e-05, eta: 0:00:55, time: 0.864, data_time: 0.656, memory: 1654, top1_acc: 1.0000, top5_acc: 1.0000, loss_cls: 0.3669, loss: 0.3669, grad_norm: 7.3256\n",
      "2021-06-03 15:05:26,903 - mmaction - INFO - Epoch [22][10/15]\tlr: 7.813e-05, eta: 0:00:52, time: 0.255, data_time: 0.063, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.5618, loss: 0.5618, grad_norm: 11.0834\n",
      "2021-06-03 15:05:27,740 - mmaction - INFO - Epoch [22][15/15]\tlr: 7.813e-05, eta: 0:00:50, time: 0.167, data_time: 0.001, memory: 1654, top1_acc: 0.6000, top5_acc: 1.0000, loss_cls: 0.6190, loss: 0.6190, grad_norm: 12.5605\n",
      "2021-06-03 15:05:32,036 - mmaction - INFO - Epoch [23][5/15]\tlr: 7.813e-05, eta: 0:00:48, time: 0.839, data_time: 0.631, memory: 1654, top1_acc: 0.7000, top5_acc: 1.0000, loss_cls: 0.5490, loss: 0.5490, grad_norm: 11.1925\n",
      "2021-06-03 15:05:33,384 - mmaction - INFO - Epoch [23][10/15]\tlr: 7.813e-05, eta: 0:00:46, time: 0.272, data_time: 0.081, memory: 1654, top1_acc: 0.6000, top5_acc: 1.0000, loss_cls: 0.5988, loss: 0.5988, grad_norm: 12.0808\n",
      "2021-06-03 15:05:34,222 - mmaction - INFO - Epoch [23][15/15]\tlr: 7.813e-05, eta: 0:00:43, time: 0.167, data_time: 0.001, memory: 1654, top1_acc: 0.7000, top5_acc: 1.0000, loss_cls: 0.6084, loss: 0.6084, grad_norm: 11.4491\n",
      "2021-06-03 15:05:38,546 - mmaction - INFO - Epoch [24][5/15]\tlr: 7.813e-05, eta: 0:00:42, time: 0.845, data_time: 0.637, memory: 1654, top1_acc: 0.7000, top5_acc: 1.0000, loss_cls: 0.5125, loss: 0.5125, grad_norm: 10.9388\n",
      "2021-06-03 15:05:39,792 - mmaction - INFO - Epoch [24][10/15]\tlr: 7.813e-05, eta: 0:00:39, time: 0.251, data_time: 0.059, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.6036, loss: 0.6036, grad_norm: 12.3427\n",
      "2021-06-03 15:05:40,640 - mmaction - INFO - Epoch [24][15/15]\tlr: 7.813e-05, eta: 0:00:37, time: 0.169, data_time: 0.001, memory: 1654, top1_acc: 0.7000, top5_acc: 1.0000, loss_cls: 0.5052, loss: 0.5052, grad_norm: 10.0184\n",
      "2021-06-03 15:05:44,885 - mmaction - INFO - Epoch [25][5/15]\tlr: 7.813e-05, eta: 0:00:35, time: 0.831, data_time: 0.623, memory: 1654, top1_acc: 0.7000, top5_acc: 1.0000, loss_cls: 0.5324, loss: 0.5324, grad_norm: 10.9933\n",
      "2021-06-03 15:05:46,302 - mmaction - INFO - Epoch [25][10/15]\tlr: 7.813e-05, eta: 0:00:33, time: 0.283, data_time: 0.097, memory: 1654, top1_acc: 0.7000, top5_acc: 1.0000, loss_cls: 0.6386, loss: 0.6386, grad_norm: 12.9881\n",
      "2021-06-03 15:05:47,135 - mmaction - INFO - Epoch [25][15/15]\tlr: 7.813e-05, eta: 0:00:31, time: 0.166, data_time: 0.001, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.4406, loss: 0.4406, grad_norm: 9.0257\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 10/10, 5.8 task/s, elapsed: 2s, ETA:     0s"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-06-03 15:05:49,031 - mmaction - INFO - Evaluating top_k_accuracy ...\n",
      "2021-06-03 15:05:49,033 - mmaction - INFO - \n",
      "top1_acc\t0.8000\n",
      "top5_acc\t1.0000\n",
      "2021-06-03 15:05:49,039 - mmaction - INFO - Evaluating mean_class_accuracy ...\n",
      "2021-06-03 15:05:49,040 - mmaction - INFO - \n",
      "mean_acc\t0.8000\n",
      "2021-06-03 15:05:49,042 - mmaction - INFO - Epoch(val) [25][5]\ttop1_acc: 0.8000, top5_acc: 1.0000, mean_class_accuracy: 0.8000\n",
      "2021-06-03 15:05:53,064 - mmaction - INFO - Epoch [26][5/15]\tlr: 7.813e-05, eta: 0:00:29, time: 0.801, data_time: 0.590, memory: 1654, top1_acc: 0.9000, top5_acc: 1.0000, loss_cls: 0.3512, loss: 0.3512, grad_norm: 7.0619\n",
      "2021-06-03 15:05:54,188 - mmaction - INFO - Epoch [26][10/15]\tlr: 7.813e-05, eta: 0:00:27, time: 0.225, data_time: 0.030, memory: 1654, top1_acc: 0.9000, top5_acc: 1.0000, loss_cls: 0.3328, loss: 0.3328, grad_norm: 7.1553\n",
      "2021-06-03 15:05:55,139 - mmaction - INFO - Epoch [26][15/15]\tlr: 7.813e-05, eta: 0:00:25, time: 0.192, data_time: 0.018, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.4698, loss: 0.4698, grad_norm: 9.4666\n",
      "2021-06-03 15:05:59,226 - mmaction - INFO - Epoch [27][5/15]\tlr: 7.813e-05, eta: 0:00:23, time: 0.799, data_time: 0.593, memory: 1654, top1_acc: 0.6000, top5_acc: 1.0000, loss_cls: 0.5434, loss: 0.5434, grad_norm: 10.9087\n",
      "2021-06-03 15:06:00,493 - mmaction - INFO - Epoch [27][10/15]\tlr: 7.813e-05, eta: 0:00:21, time: 0.254, data_time: 0.067, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.3672, loss: 0.3672, grad_norm: 7.5920\n",
      "2021-06-03 15:06:01,451 - mmaction - INFO - Epoch [27][15/15]\tlr: 7.813e-05, eta: 0:00:18, time: 0.191, data_time: 0.014, memory: 1654, top1_acc: 0.9000, top5_acc: 1.0000, loss_cls: 0.3633, loss: 0.3633, grad_norm: 7.8609\n",
      "2021-06-03 15:06:05,792 - mmaction - INFO - Epoch [28][5/15]\tlr: 7.813e-05, eta: 0:00:16, time: 0.850, data_time: 0.645, memory: 1654, top1_acc: 0.6000, top5_acc: 1.0000, loss_cls: 0.6003, loss: 0.6003, grad_norm: 12.0149\n",
      "2021-06-03 15:06:07,078 - mmaction - INFO - Epoch [28][10/15]\tlr: 7.813e-05, eta: 0:00:14, time: 0.257, data_time: 0.068, memory: 1654, top1_acc: 0.6000, top5_acc: 1.0000, loss_cls: 0.6538, loss: 0.6538, grad_norm: 13.2297\n",
      "2021-06-03 15:06:07,941 - mmaction - INFO - Epoch [28][15/15]\tlr: 7.813e-05, eta: 0:00:12, time: 0.172, data_time: 0.003, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.4151, loss: 0.4151, grad_norm: 8.6073\n",
      "2021-06-03 15:06:12,212 - mmaction - INFO - Epoch [29][5/15]\tlr: 7.813e-05, eta: 0:00:10, time: 0.836, data_time: 0.629, memory: 1654, top1_acc: 0.9000, top5_acc: 1.0000, loss_cls: 0.3997, loss: 0.3997, grad_norm: 8.2630\n",
      "2021-06-03 15:06:13,414 - mmaction - INFO - Epoch [29][10/15]\tlr: 7.813e-05, eta: 0:00:08, time: 0.240, data_time: 0.050, memory: 1654, top1_acc: 0.9000, top5_acc: 1.0000, loss_cls: 0.3257, loss: 0.3257, grad_norm: 6.8715\n",
      "2021-06-03 15:06:14,279 - mmaction - INFO - Epoch [29][15/15]\tlr: 7.813e-05, eta: 0:00:06, time: 0.173, data_time: 0.002, memory: 1654, top1_acc: 0.8000, top5_acc: 1.0000, loss_cls: 0.5843, loss: 0.5843, grad_norm: 12.2261\n",
      "2021-06-03 15:06:18,611 - mmaction - INFO - Epoch [30][5/15]\tlr: 7.813e-05, eta: 0:00:04, time: 0.849, data_time: 0.645, memory: 1654, top1_acc: 0.6000, top5_acc: 1.0000, loss_cls: 0.4302, loss: 0.4302, grad_norm: 8.8877\n",
      "2021-06-03 15:06:20,008 - mmaction - INFO - Epoch [30][10/15]\tlr: 7.813e-05, eta: 0:00:02, time: 0.280, data_time: 0.091, memory: 1654, top1_acc: 1.0000, top5_acc: 1.0000, loss_cls: 0.2355, loss: 0.2355, grad_norm: 5.3905\n",
      "2021-06-03 15:06:20,850 - mmaction - INFO - Epoch [30][15/15]\tlr: 7.813e-05, eta: 0:00:00, time: 0.168, data_time: 0.001, memory: 1654, top1_acc: 0.7000, top5_acc: 1.0000, loss_cls: 0.4508, loss: 0.4508, grad_norm: 9.6814\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 10/10, 5.8 task/s, elapsed: 2s, ETA:     0s"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-06-03 15:06:22,740 - mmaction - INFO - Evaluating top_k_accuracy ...\n",
      "2021-06-03 15:06:22,742 - mmaction - INFO - \n",
      "top1_acc\t1.0000\n",
      "top5_acc\t1.0000\n",
      "2021-06-03 15:06:22,746 - mmaction - INFO - Evaluating mean_class_accuracy ...\n",
      "2021-06-03 15:06:22,747 - mmaction - INFO - \n",
      "mean_acc\t1.0000\n",
      "2021-06-03 15:06:22,756 - mmaction - INFO - Saving checkpoint at 30 epochs\n",
      "2021-06-03 15:06:23,168 - mmaction - INFO - Epoch(val) [30][5]\ttop1_acc: 1.0000, top5_acc: 1.0000, mean_class_accuracy: 1.0000\n"
     ]
    }
   ],
   "source": [
    "import os.path as osp\n",
    "\n",
    "from mmaction.datasets import build_dataset\n",
    "from mmaction.models import build_model\n",
    "from mmaction.apis import train_model\n",
    "\n",
    "import mmcv\n",
    "\n",
    "# 构建数据集\n",
    "datasets = [build_dataset(cfg.data.train)]\n",
    "\n",
    "# 构建动作识别模型\n",
    "model = build_model(cfg.model, train_cfg=cfg.get('train_cfg'), test_cfg=cfg.get('test_cfg'))\n",
    "\n",
    "# 创建工作目录并训练模型\n",
    "mmcv.mkdir_or_exist(osp.abspath(cfg.work_dir))\n",
    "train_model(model, datasets, cfg, distributed=False, validate=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "ryVoSfZVmogw"
   },
   "source": [
    "## 评价模型\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "eyY3hCMwyTct",
    "outputId": "54c2d6ce-3f3e-45ed-b3d4-f628ba4263b0"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[                                                  ] 0/10, elapsed: 0s, ETA:"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py:477: UserWarning: This DataLoader will create 4 worker processes in total. Our suggested max number of worker in current system is 2, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary.\n",
      "  cpuset_checked))\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 10/10, 2.2 task/s, elapsed: 4s, ETA:     0s\n",
      "Evaluating top_k_accuracy ...\n",
      "\n",
      "top1_acc\t0.9000\n",
      "top5_acc\t1.0000\n",
      "\n",
      "Evaluating mean_class_accuracy ...\n",
      "\n",
      "mean_acc\t0.9000\n",
      "top1_acc: 0.9000\n",
      "top5_acc: 1.0000\n",
      "mean_class_accuracy: 0.9000\n"
     ]
    }
   ],
   "source": [
    "from mmaction.apis import single_gpu_test\n",
    "from mmaction.datasets import build_dataloader\n",
    "from mmcv.parallel import MMDataParallel\n",
    "\n",
    "# 构建测试数据集\n",
    "dataset = build_dataset(cfg.data.test, dict(test_mode=True))\n",
    "data_loader = build_dataloader(\n",
    "        dataset,\n",
    "        videos_per_gpu=1,\n",
    "        workers_per_gpu=cfg.data.workers_per_gpu,\n",
    "        dist=False,\n",
    "        shuffle=False)\n",
    "model = MMDataParallel(model, device_ids=[0])\n",
    "outputs = single_gpu_test(model, data_loader)\n",
    "\n",
    "# 在测试集上评价训练完成的识别模型\n",
    "eval_config = cfg.evaluation\n",
    "eval_config.pop('interval')\n",
    "eval_res = dataset.evaluate(outputs, **eval_config)\n",
    "for name, val in eval_res.items():\n",
    "    print(f'{name}: {val:.04f}')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "8EbJVEEmrv0S"
   },
   "source": [
    "## 时空动作识别\n",
    "\n",
    "这里我们用到mmdet来辅助完成时空动作识别的任务，首先要在主目录下进行安装。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "Yq5e5l-zEMpf",
    "outputId": "178b2d61-d00c-4b93-847c-efc4b249ceaa"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/content\n",
      "Cloning into 'mmdetection'...\n",
      "remote: Enumerating objects: 18118, done.\u001b[K\n",
      "remote: Counting objects: 100% (207/207), done.\u001b[K\n",
      "remote: Compressing objects: 100% (163/163), done.\u001b[K\n",
      "remote: Total 18118 (delta 87), reused 113 (delta 44), pack-reused 17911\u001b[K\n",
      "Receiving objects: 100% (18118/18118), 21.50 MiB | 33.66 MiB/s, done.\n",
      "Resolving deltas: 100% (12576/12576), done.\n",
      "/content/mmdetection\n",
      "Obtaining file:///content/mmdetection\n",
      "Requirement already satisfied: matplotlib in /usr/local/lib/python3.7/dist-packages (from mmdet==2.13.0) (3.2.2)\n",
      "Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from mmdet==2.13.0) (1.19.5)\n",
      "Requirement already satisfied: six in /usr/local/lib/python3.7/dist-packages (from mmdet==2.13.0) (1.15.0)\n",
      "Collecting terminaltables\n",
      "  Downloading https://files.pythonhosted.org/packages/9b/c4/4a21174f32f8a7e1104798c445dacdc1d4df86f2f26722767034e4de4bff/terminaltables-3.1.0.tar.gz\n",
      "Requirement already satisfied: pycocotools in /usr/local/lib/python3.7/dist-packages (from mmdet==2.13.0) (2.0.2)\n",
      "Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->mmdet==2.13.0) (2.4.7)\n",
      "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.7/dist-packages (from matplotlib->mmdet==2.13.0) (0.10.0)\n",
      "Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->mmdet==2.13.0) (1.3.1)\n",
      "Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->mmdet==2.13.0) (2.8.1)\n",
      "Requirement already satisfied: cython>=0.27.3 in /usr/local/lib/python3.7/dist-packages (from pycocotools->mmdet==2.13.0) (0.29.23)\n",
      "Requirement already satisfied: setuptools>=18.0 in /usr/local/lib/python3.7/dist-packages (from pycocotools->mmdet==2.13.0) (57.0.0)\n",
      "Building wheels for collected packages: terminaltables\n",
      "  Building wheel for terminaltables (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
      "  Created wheel for terminaltables: filename=terminaltables-3.1.0-cp37-none-any.whl size=15356 sha256=37a2b87aceff6ca4b32508fac67142e960106f99a33a0a1d2127aaaecd9fae0b\n",
      "  Stored in directory: /root/.cache/pip/wheels/30/6b/50/6c75775b681fb36cdfac7f19799888ef9d8813aff9e379663e\n",
      "Successfully built terminaltables\n",
      "Installing collected packages: terminaltables, mmdet\n",
      "  Running setup.py develop for mmdet\n",
      "Successfully installed mmdet terminaltables-3.1.0\n",
      "/content/mmaction2\n"
     ]
    }
   ],
   "source": [
    "# 克隆mmdetection项目\n",
    "%cd ..\n",
    "!git clone https://github.com/open-mmlab/mmdetection.git\n",
    "%cd mmdetection\n",
    "\n",
    "# 以可编辑的模式安装mmdet\n",
    "!pip install -e .\n",
    "%cd ../mmaction2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "dWLxybK6INRI"
   },
   "source": [
    "同时我们需要上传视频至目录mmaction2下"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "'wget' is not recognized as an internal or external command,\n",
      "operable program or batch file.\n"
     ]
    }
   ],
   "source": [
    "!wget https://download.openmmlab.com/mmaction/dataset/sample/1j20qq1JyX4.mp4 -O demo/1j20qq1JyX4.mp4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/"
    },
    "id": "AUw6xa1YrvZb",
    "outputId": "566e2683-9158-4173-b821-b9d9a34cf893"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Imageio: 'ffmpeg-linux64-v3.3.1' was not found on your computer; downloading it now.\n",
      "Try 1. Download from https://github.com/imageio/imageio-binaries/raw/master/ffmpeg/ffmpeg-linux64-v3.3.1 (43.8 MB)\n",
      "Downloading: 8192/45929032 bytes (0.02826240/45929032 bytes (6.2%6922240/45929032 bytes (15.110977280/45929032 bytes (23.9%14925824/45929032 bytes (32.5%19046400/45929032 bytes (41.5%23068672/45929032 bytes (50.2%26279936/45929032 bytes (57.2%30392320/45929032 bytes (66.2%34471936/45929032 bytes (75.1%38543360/45929032 bytes (83.9%42688512/45929032 bytes (92.9%45929032/45929032 bytes (100.0%)\n",
      "  Done\n",
      "File saved as /root/.imageio/ffmpeg/ffmpeg-linux64-v3.3.1.\n",
      "Use load_from_http loader\n",
      "Downloading: \"http://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_2x_coco/faster_rcnn_r50_fpn_2x_coco_bbox_mAP-0.384_20200504_210434-a5d8aa15.pth\" to /root/.cache/torch/hub/checkpoints/faster_rcnn_r50_fpn_2x_coco_bbox_mAP-0.384_20200504_210434-a5d8aa15.pth\n",
      "100% 160M/160M [00:17<00:00, 9.30MB/s]\n",
      "Performing Human Detection for each frame\n",
      "100% 217/217 [00:26<00:00,  8.24it/s]\n",
      "Use load_from_http loader\n",
      "Downloading: \"https://download.openmmlab.com/mmaction/detection/ava/slowonly_omnisource_pretrained_r101_8x8x1_20e_ava_rgb/slowonly_omnisource_pretrained_r101_8x8x1_20e_ava_rgb_20201217-16378594.pth\" to /root/.cache/torch/hub/checkpoints/slowonly_omnisource_pretrained_r101_8x8x1_20e_ava_rgb_20201217-16378594.pth\n",
      "100% 228M/228M [00:24<00:00, 9.79MB/s]\n",
      "Performing SpatioTemporal Action Detection for each clip\n",
      "217it [00:23,  9.19it/s]\n",
      "Performing visualization\n",
      "[MoviePy] >>>> Building video demo/stdet_demo.mp4\n",
      "[MoviePy] Writing video demo/stdet_demo.mp4\n",
      "100% 434/434 [00:10<00:00, 39.93it/s]\n",
      "[MoviePy] Done.\n",
      "[MoviePy] >>>> Video ready: demo/stdet_demo.mp4 \n",
      "\n"
     ]
    }
   ],
   "source": [
    "# 完成时空检测\n",
    "!python demo/demo_spatiotemporal_det.py --video demo/1j20qq1JyX4.mp4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 341
    },
    "id": "oRabUF1TsE-v",
    "outputId": "ff8cee1a-6715-4368-edf2-ce796fd946db"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<video width=400 controls>\n",
       "      <source src=\"data:video/mp4;base64,[encoded data, 5373996 characters]\" type=\"video/mp4\">\n",
       "</video>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "execution_count": 15,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 查看视频\n",
    "from IPython.display import HTML\n",
    "from base64 import b64encode\n",
    "mp4 = open('demo/stdet_demo.mp4','rb').read()\n",
    "data_url = \"data:video/mp4;base64,\" + b64encode(mp4).decode()\n",
    "HTML(\"\"\"\n",
    "<video width=400 controls>\n",
    "      <source src=\"%s\" type=\"video/mp4\">\n",
    "</video>\n",
    "\"\"\" % data_url)"
   ]
  }
 ],
 "metadata": {
  "accelerator": "GPU",
  "colab": {
   "collapsed_sections": [],
   "include_colab_link": true,
   "name": "MMAction2 new.ipynb",
   "provenance": [],
   "toc_visible": true
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  },
  "widgets": {
   "application/vnd.jupyter.widget-state+json": {
    "4a9a4d1a6a554315a7d4362fd9ef0290": {
     "model_module": "@jupyter-widgets/base",
     "model_name": "LayoutModel",
     "state": {
      "_model_module": "@jupyter-widgets/base",
      "_model_module_version": "1.2.0",
      "_model_name": "LayoutModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/base",
      "_view_module_version": "1.2.0",
      "_view_name": "LayoutView",
      "align_content": null,
      "align_items": null,
      "align_self": null,
      "border": null,
      "bottom": null,
      "display": null,
      "flex": null,
      "flex_flow": null,
      "grid_area": null,
      "grid_auto_columns": null,
      "grid_auto_flow": null,
      "grid_auto_rows": null,
      "grid_column": null,
      "grid_gap": null,
      "grid_row": null,
      "grid_template_areas": null,
      "grid_template_columns": null,
      "grid_template_rows": null,
      "height": null,
      "justify_content": null,
      "justify_items": null,
      "left": null,
      "margin": null,
      "max_height": null,
      "max_width": null,
      "min_height": null,
      "min_width": null,
      "object_fit": null,
      "object_position": null,
      "order": null,
      "overflow": null,
      "overflow_x": null,
      "overflow_y": null,
      "padding": null,
      "right": null,
      "top": null,
      "visibility": null,
      "width": null
     }
    },
    "57f2df1708fa455ea8a305b9100ad171": {
     "model_module": "@jupyter-widgets/controls",
     "model_name": "HTMLModel",
     "state": {
      "_dom_classes": [],
      "_model_module": "@jupyter-widgets/controls",
      "_model_module_version": "1.5.0",
      "_model_name": "HTMLModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/controls",
      "_view_module_version": "1.5.0",
      "_view_name": "HTMLView",
      "description": "",
      "description_tooltip": null,
      "layout": "IPY_MODEL_974f4fceb03748f1b346b498df9828a3",
      "placeholder": "​",
      "style": "IPY_MODEL_e6b45b124776452a85136fc3e18502f6",
      "value": " 97.8M/97.8M [00:45&lt;00:00, 2.26MB/s]"
     }
    },
    "81bfbdf1ec55451b8be8a68fd1b0cf18": {
     "model_module": "@jupyter-widgets/controls",
     "model_name": "HBoxModel",
     "state": {
      "_dom_classes": [],
      "_model_module": "@jupyter-widgets/controls",
      "_model_module_version": "1.5.0",
      "_model_name": "HBoxModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/controls",
      "_view_module_version": "1.5.0",
      "_view_name": "HBoxView",
      "box_style": "",
      "children": [
       "IPY_MODEL_c992b295041a4908a6a0d4f62a542cca",
       "IPY_MODEL_57f2df1708fa455ea8a305b9100ad171"
      ],
      "layout": "IPY_MODEL_4a9a4d1a6a554315a7d4362fd9ef0290"
     }
    },
    "8c947d1afee142e4b6cd2e0e26f46d6f": {
     "model_module": "@jupyter-widgets/controls",
     "model_name": "ProgressStyleModel",
     "state": {
      "_model_module": "@jupyter-widgets/controls",
      "_model_module_version": "1.5.0",
      "_model_name": "ProgressStyleModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/base",
      "_view_module_version": "1.2.0",
      "_view_name": "StyleView",
      "bar_color": null,
      "description_width": "initial"
     }
    },
    "974f4fceb03748f1b346b498df9828a3": {
     "model_module": "@jupyter-widgets/base",
     "model_name": "LayoutModel",
     "state": {
      "_model_module": "@jupyter-widgets/base",
      "_model_module_version": "1.2.0",
      "_model_name": "LayoutModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/base",
      "_view_module_version": "1.2.0",
      "_view_name": "LayoutView",
      "align_content": null,
      "align_items": null,
      "align_self": null,
      "border": null,
      "bottom": null,
      "display": null,
      "flex": null,
      "flex_flow": null,
      "grid_area": null,
      "grid_auto_columns": null,
      "grid_auto_flow": null,
      "grid_auto_rows": null,
      "grid_column": null,
      "grid_gap": null,
      "grid_row": null,
      "grid_template_areas": null,
      "grid_template_columns": null,
      "grid_template_rows": null,
      "height": null,
      "justify_content": null,
      "justify_items": null,
      "left": null,
      "margin": null,
      "max_height": null,
      "max_width": null,
      "min_height": null,
      "min_width": null,
      "object_fit": null,
      "object_position": null,
      "order": null,
      "overflow": null,
      "overflow_x": null,
      "overflow_y": null,
      "padding": null,
      "right": null,
      "top": null,
      "visibility": null,
      "width": null
     }
    },
    "adf3a16cdae740cf882999a25d53e8f7": {
     "model_module": "@jupyter-widgets/base",
     "model_name": "LayoutModel",
     "state": {
      "_model_module": "@jupyter-widgets/base",
      "_model_module_version": "1.2.0",
      "_model_name": "LayoutModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/base",
      "_view_module_version": "1.2.0",
      "_view_name": "LayoutView",
      "align_content": null,
      "align_items": null,
      "align_self": null,
      "border": null,
      "bottom": null,
      "display": null,
      "flex": null,
      "flex_flow": null,
      "grid_area": null,
      "grid_auto_columns": null,
      "grid_auto_flow": null,
      "grid_auto_rows": null,
      "grid_column": null,
      "grid_gap": null,
      "grid_row": null,
      "grid_template_areas": null,
      "grid_template_columns": null,
      "grid_template_rows": null,
      "height": null,
      "justify_content": null,
      "justify_items": null,
      "left": null,
      "margin": null,
      "max_height": null,
      "max_width": null,
      "min_height": null,
      "min_width": null,
      "object_fit": null,
      "object_position": null,
      "order": null,
      "overflow": null,
      "overflow_x": null,
      "overflow_y": null,
      "padding": null,
      "right": null,
      "top": null,
      "visibility": null,
      "width": null
     }
    },
    "c992b295041a4908a6a0d4f62a542cca": {
     "model_module": "@jupyter-widgets/controls",
     "model_name": "FloatProgressModel",
     "state": {
      "_dom_classes": [],
      "_model_module": "@jupyter-widgets/controls",
      "_model_module_version": "1.5.0",
      "_model_name": "FloatProgressModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/controls",
      "_view_module_version": "1.5.0",
      "_view_name": "ProgressView",
      "bar_style": "success",
      "description": "100%",
      "description_tooltip": null,
      "layout": "IPY_MODEL_adf3a16cdae740cf882999a25d53e8f7",
      "max": 102502400,
      "min": 0,
      "orientation": "horizontal",
      "style": "IPY_MODEL_8c947d1afee142e4b6cd2e0e26f46d6f",
      "value": 102502400
     }
    },
    "e6b45b124776452a85136fc3e18502f6": {
     "model_module": "@jupyter-widgets/controls",
     "model_name": "DescriptionStyleModel",
     "state": {
      "_model_module": "@jupyter-widgets/controls",
      "_model_module_version": "1.5.0",
      "_model_name": "DescriptionStyleModel",
      "_view_count": null,
      "_view_module": "@jupyter-widgets/base",
      "_view_module_version": "1.2.0",
      "_view_name": "StyleView",
      "description_width": ""
     }
    }
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
