From a73aad2fe1479bf3c9cf7e3ef34219a54b5c0efd Mon Sep 17 00:00:00 2001 From: rfeinleib3 Date: Sun, 18 Jul 2021 16:33:03 -0400 Subject: [PATCH 1/4] rick add .ipynb, class --- CS7643Sum21ProjTeam59.ipynb | 368 ++++++++++++++++++++++++++++++++++++ train_model_class.py | 199 +++++++++++++++++++ 2 files changed, 567 insertions(+) create mode 100644 CS7643Sum21ProjTeam59.ipynb create mode 100644 train_model_class.py diff --git a/CS7643Sum21ProjTeam59.ipynb b/CS7643Sum21ProjTeam59.ipynb new file mode 100644 index 0000000..6d65e0f --- /dev/null +++ b/CS7643Sum21ProjTeam59.ipynb @@ -0,0 +1,368 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "executionInfo": { + "elapsed": 38921, + "status": "ok", + "timestamp": 1626215545604, + "user": { + "displayName": "Rick Feinleib", + "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14GjoqYHQlggzOnw7kbmibkVT3DL6W7pv4Ot4VJKd=s64", + "userId": "17023243058419009217" + }, + "user_tz": 240 + }, + "id": "7OmNlqc1n2Jv", + "outputId": "c1b92d56-ed3f-414d-b116-e2ccb39568be" + }, + "outputs": [], + "source": [ + "from google.colab import drive\n", + "drive.mount('/content/drive')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "executionInfo": { + "elapsed": 595, + "status": "ok", + "timestamp": 1626216249718, + "user": { + "displayName": "Rick Feinleib", + "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14GjoqYHQlggzOnw7kbmibkVT3DL6W7pv4Ot4VJKd=s64", + "userId": "17023243058419009217" + }, + "user_tz": 240 + }, + "id": "ZnX1aeNg_kOw", + "outputId": "f415d6af-8a4b-4f8a-f313-763cba8eb438" + }, + "outputs": [], + "source": [ + "%cd '/content/drive/MyDrive'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "executionInfo": { + "elapsed": 186, + "status": "ok", + "timestamp": 1626221994006, + "user": { + "displayName": "Rick Feinleib", + "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14GjoqYHQlggzOnw7kbmibkVT3DL6W7pv4Ot4VJKd=s64", + "userId": "17023243058419009217" + }, + "user_tz": 240 + }, + "id": "Uc6C2Mz7WXd1" + }, + "outputs": [], + "source": [ + "usr = 'rfeinleib3'\n", + "p = 'xxxxx'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "executionInfo": { + "elapsed": 7911, + "status": "ok", + "timestamp": 1626222035230, + "user": { + "displayName": "Rick Feinleib", + "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14GjoqYHQlggzOnw7kbmibkVT3DL6W7pv4Ot4VJKd=s64", + "userId": "17023243058419009217" + }, + "user_tz": 240 + }, + "id": "RHepLguDAQL_", + "outputId": "601b3fb9-c003-49cc-85fd-a2e366977ab1" + }, + "outputs": [], + "source": [ + "!git clone https://{usr}:{p}@github.com/GaTechTeam59/representation-flow-cvpr19.git" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "/home/rick/dl-7643/GaTechTeam59/representation-flow-cvpr19\r\n" + ] + } + ], + "source": [ + "!pwd" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "id": "p38K8YZOfqf8" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "/home/rick/dl-7643/GaTechTeam59/representation-flow-cvpr19\n" + ] + } + ], + "source": [ + "%cd 'representation-flow-cvpr19'" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "phla7FIdbC4C" + }, + "source": [ + "## Start code here" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "id": "OIjY-l7KbI4e" + }, + "outputs": [], + "source": [ + "import torch\n", + "from train_model_class import Model\n", + "\n", + "# for auto-reloading external modules\n", + "# see http://stackoverflow.com/questions/1907993/autoreload-of-modules-in-ipython\n", + "%load_ext autoreload\n", + "%autoreload 2" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "executionInfo": { + "elapsed": 261, + "status": "ok", + "timestamp": 1626054158450, + "user": { + "displayName": "Rick Feinleib", + "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14GjoqYHQlggzOnw7kbmibkVT3DL6W7pv4Ot4VJKd=s64", + "userId": "17023243058419009217" + }, + "user_tz": 240 + }, + "id": "eiV_KQz7nsL3", + "outputId": "2afd568a-890f-47fe-8b30-dbe24eb1fc81", + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "You are using device: cpu\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/rick/anaconda3/lib/python3.8/site-packages/torch/cuda/__init__.py:52: UserWarning: CUDA initialization: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx (Triggered internally at /pytorch/c10/cuda/CUDAFunctions.cpp:100.)\n", + " return torch._C._cuda_getDeviceCount() > 0\n" + ] + } + ], + "source": [ + "# Check device availability\n", + "device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\n", + "print(\"You are using device: %s\" % device)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "id": "JbDFZI6GjZFc" + }, + "outputs": [], + "source": [ + "class Args:\n", + " def __init__(self, mode: str='rgb', exp_name: str=\"hmdb-test\", batch_size: int=32, length: int=32, \n", + " learnable: str=\"[0,1,1,1,1]\", niter: int=20, system: str=\"hmdb\", model: str=\"3d\"):\n", + " self.mode = mode\n", + " self.exp_name = exp_name\n", + " self.batch_size = batch_size\n", + " self.length = length\n", + " self.learnable = learnable\n", + " self.niter = niter\n", + " self.system = system\n", + " self.model = model" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "id": "q1NuorLJiGNf" + }, + "outputs": [], + "source": [ + "# args = Args(mode=\"rgb\", exp_name=\"hmdb-test\", batch_size=32, length=32, learnable=\"[0,1,1,1,1]\", niter=20, system=\"hmdb\", model=\"3d\")\n", + "args = Args()\n", + "model = Model(device)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "193\n", + "179 22\n" + ] + }, + { + "ename": "FileNotFoundError", + "evalue": "Caught FileNotFoundError in DataLoader worker process 0.\nOriginal Traceback (most recent call last):\n File \"/home/rick/anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py\", line 198, in _worker_loop\n data = fetcher.fetch(index)\n File \"/home/rick/anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py\", line 44, in fetch\n data = [self.dataset[idx] for idx in possibly_batched_index]\n File \"/home/rick/anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py\", line 44, in \n data = [self.dataset[idx] for idx in possibly_batched_index]\n File \"/home/rick/dl-7643/GaTechTeam59/representation-flow-cvpr19/hmdb_dataset.py\", line 59, in __getitem__\n with open(vid, 'rb') as f:\nFileNotFoundError: [Errno 2] No such file or directory: '/ssd/hmdb/rgb_BIG_FISH_eat_h_nm_np1_ri_goo_30.mp4'\n", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtrain\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m~/dl-7643/GaTechTeam59/representation-flow-cvpr19/train_model_class.py\u001b[0m in \u001b[0;36mtrain\u001b[0;34m(self, args)\u001b[0m\n\u001b[1;32m 154\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 155\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mtorch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mset_grad_enabled\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtrain\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 156\u001b[0;31m \u001b[0;32mfor\u001b[0m \u001b[0mvid\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcls\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mdataloader\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mphase\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 157\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mc\u001b[0m\u001b[0;34m%\u001b[0m\u001b[0;36m200\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 158\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'epoch'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mepoch\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m'iter'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mc\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/anaconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py\u001b[0m in \u001b[0;36m__next__\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 433\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_sampler_iter\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 434\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_reset\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 435\u001b[0;31m \u001b[0mdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_next_data\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 436\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_num_yielded\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 437\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_dataset_kind\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0m_DatasetKind\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mIterable\u001b[0m \u001b[0;32mand\u001b[0m\u001b[0;31m \u001b[0m\u001b[0;31m\\\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/anaconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py\u001b[0m in \u001b[0;36m_next_data\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 1083\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1084\u001b[0m \u001b[0;32mdel\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_task_info\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0midx\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1085\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_process_data\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1086\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1087\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_try_put_index\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/anaconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py\u001b[0m in \u001b[0;36m_process_data\u001b[0;34m(self, data)\u001b[0m\n\u001b[1;32m 1109\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_try_put_index\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1110\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mExceptionWrapper\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1111\u001b[0;31m \u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreraise\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1112\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1113\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/anaconda3/lib/python3.8/site-packages/torch/_utils.py\u001b[0m in \u001b[0;36mreraise\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 426\u001b[0m \u001b[0;31m# have message field\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 427\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexc_type\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmessage\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmsg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 428\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexc_type\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmsg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 429\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 430\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mFileNotFoundError\u001b[0m: Caught FileNotFoundError in DataLoader worker process 0.\nOriginal Traceback (most recent call last):\n File \"/home/rick/anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py\", line 198, in _worker_loop\n data = fetcher.fetch(index)\n File \"/home/rick/anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py\", line 44, in fetch\n data = [self.dataset[idx] for idx in possibly_batched_index]\n File \"/home/rick/anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py\", line 44, in \n data = [self.dataset[idx] for idx in possibly_batched_index]\n File \"/home/rick/dl-7643/GaTechTeam59/representation-flow-cvpr19/hmdb_dataset.py\", line 59, in __getitem__\n with open(vid, 'rb') as f:\nFileNotFoundError: [Errno 2] No such file or directory: '/ssd/hmdb/rgb_BIG_FISH_eat_h_nm_np1_ri_goo_30.mp4'\n" + ] + } + ], + "source": [ + "model.train(args)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [], + "source": [ + "import datetime" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'07-17-1937'" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "datetime.datetime.today().strftime('%m-%d-%H%M')" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [], + "source": [ + "!mkdir logs" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "executionInfo": { + "elapsed": 553, + "status": "ok", + "timestamp": 1626219170610, + "user": { + "displayName": "Rick Feinleib", + "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14GjoqYHQlggzOnw7kbmibkVT3DL6W7pv4Ot4VJKd=s64", + "userId": "17023243058419009217" + }, + "user_tz": 240 + }, + "id": "j4e806VECt8D" + }, + "outputs": [], + "source": [ + "#!python train_model.py -mode rgb -exp_name \"hmdb-test\" -batch_size 32 -length 32 -learnable \"[0,1,1,1,1]\" -niter 20 -system hmdb -model \"3d\"" + ] + } + ], + "metadata": { + "colab": { + "authorship_tag": "ABX9TyOsbdZ6pIid2PXEU8d3nNuQ", + "collapsed_sections": [], + "name": "CS7643Sum21ProjTeam59.ipynb", + "provenance": [] + }, + "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.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/train_model_class.py b/train_model_class.py new file mode 100644 index 0000000..7ca4e0c --- /dev/null +++ b/train_model_class.py @@ -0,0 +1,199 @@ +import os +import sys +import argparse +import inspect +import datetime +import json + +import time + +import torch +import torch.nn as nn +import torch.nn.functional as F +import torch.optim as optim +from torch.optim import lr_scheduler + +#import models +import flow_2p1d_resnets + +# device = torch.device('cuda') + +################## +# +# Create model, dataset, and training setup +# +################## + + +class Model: + def __init__(self, device): + self.device = device + + def train(self, args): + model = flow_2p1d_resnets.resnet50(pretrained=False, mode=args.mode, n_iter=args.niter, + learnable=eval(args.learnable), num_classes=400) + + model = nn.DataParallel(model).to(self.device) + batch_size = args.batch_size + + if args.system == 'hmdb': + from hmdb_dataset import HMDB as DS + dataseta = DS('data/hmdb/split1_train.txt', '/ssd/hmdb/', model=args.model, mode=args.mode, length=args.length) + dl = torch.utils.data.DataLoader(dataseta, batch_size=batch_size, shuffle=True, num_workers=8, pin_memory=True) + + dataset = DS('data/hmdb/split1_test.txt', '/ssd/hmdb/', model=args.model, mode=args.mode, length=args.length, c2i=dataseta.class_to_id) + vdl = torch.utils.data.DataLoader(dataset, batch_size=batch_size, shuffle=True, num_workers=8, pin_memory=True) + dataloader = {'train':dl, 'val':vdl} + + if args.system == 'minikinetics': + train = 'data/kinetics/minikinetics_train.json' + val = 'data/kinetics/minikinetics_val.json' + root = '/ssd/kinetics/' + from minikinetics_dataset import MK + dataset_tr = MK(train, root, length=args.length, model=args.model, mode=args.mode) + dl = torch.utils.data.DataLoader(dataset_tr, batch_size=batch_size, shuffle=True, num_workers=8, pin_memory=True) + + dataset = MK(val, root, length=args.length, model=args.model, mode=args.mode) + vdl = torch.utils.data.DataLoader(dataset, batch_size=batch_size, shuffle=True, num_workers=8, pin_memory=True) + dataloader = {'train':dl, 'val':vdl} + + if args.system == 'kinetics': + train = 'data/kinetics/kinetics_train.json' + val = 'data/kinetics/kinetics_val.json' + root = '/ssd/kinetics/' + from minikinetics_dataset import MK + dataset_tr = MK(train, root, length=args.length, model=args.model, mode=args.mode) + dl = torch.utils.data.DataLoader(dataset_tr, batch_size=batch_size, shuffle=True, num_workers=8, pin_memory=True) + + dataset = MK(val, root, length=args.length, model=args.model, mode=args.mode) + vdl = torch.utils.data.DataLoader(dataset, batch_size=batch_size, shuffle=True, num_workers=8, pin_memory=True) + dataloader = {'train':dl, 'val':vdl} + + + # scale lr for flow layer + params = model.parameters() + params = [p for p in params] + other = [] + print(len(params)) + ln = eval(args.learnable) + if ln[0] == 1: + other += [p for p in params if (p.sum() == model.module.flow_layer.img_grad.sum()).all() and p.size() == model.module.flow_layer.img_grad.size()] + other += [p for p in params if (p.sum() == model.module.flow_layer.img_grad2.sum()).all() and p.size() == model.module.flow_layer.img_grad2.size()] + params = [p for p in params if (p.sum() != model.module.flow_layer.img_grad.sum()).all() or p.size() != model.module.flow_layer.img_grad.size()] + params = [p for p in params if (p.sum() != model.module.flow_layer.img_grad2.sum()).all() or p.size() != model.module.flow_layer.img_grad2.size()] + + if ln[1] == 1: + other += [p for p in params if (p.sum() == model.module.flow_layer.f_grad.sum()).all() and p.size() == model.module.flow_layer.f_grad.size()] + other += [p for p in params if (p.sum() == model.module.flow_layer.f_grad2.sum()).all() and p.size() == model.module.flow_layer.f_grad2.size()] + params = [p for p in params if (p.sum() != model.module.flow_layer.f_grad.sum()).all() or p.size() != model.module.flow_layer.f_grad.size()] + params = [p for p in params if (p.sum() != model.module.flow_layer.f_grad2.sum()).all() or p.size() != model.module.flow_layer.f_grad2.size()] + + if ln[2] == 1: + other += [p for p in params if (p.sum() == model.module.flow_layer.t.sum()).all() and p.size() == model.module.flow_layer.t.size()] + params = [p for p in params if (p.sum() != model.module.flow_layer.t.sum()).all() or p.size() != model.module.flow_layer.t.size()] + + if ln[3] == 1: + other += [p for p in params if (p.sum() == model.module.flow_layer.l.sum()).all() and p.size() == model.module.flow_layer.l.size()] + params = [p for p in params if (p.sum() != model.module.flow_layer.l.sum()).all() or p.size() != model.module.flow_layer.l.size()] + + if ln[4] == 1: + other += [p for p in params if (p.sum() == model.module.flow_layer.a.sum()).all() and p.size() == model.module.flow_layer.a.size()] + params = [p for p in params if (p.sum() != model.module.flow_layer.a.sum()).all() or p.size() != model.module.flow_layer.a.size()] + + + + #print([p for p in model.parameters() if (p == model.module.flow_layer.t).all()]) + #print(other) + print(len(params), len(other)) + #exit() + + lr = 0.01 + solver = optim.SGD([{'params':params}, {'params':other, 'lr':0.01*lr}], lr=lr, weight_decay=1e-6, momentum=0.9) + lr_sched = optim.lr_scheduler.ReduceLROnPlateau(solver, patience=7) + + + ################# + # + # Setup logs, store model code + # hyper-parameters, etc... + # + ################# + log_name = datetime.datetime.today().strftime('%m-%d-%H%M')+'-'+args.exp_name + log_path = os.path.join('logs/',log_name) + os.mkdir(log_path) + os.system('cp * logs/'+log_name+'/') + + # deal with hyper-params... + with open(os.path.join(log_path,'params.json'), 'w') as out: + hyper = vars(args) + json.dump(hyper, out) + log = {'iterations':[], 'epoch':[], 'validation':[], 'train_acc':[], 'val_acc':[]} + + + + ############### + # + # Train the model and save everything + # + ############### + num_epochs = 60 + for epoch in range(num_epochs): + + for phase in ['train', 'val']: + train = (phase=='train') + if phase == 'train': + model.train() + else: + model.eval() + + tloss = 0. + acc = 0. + tot = 0 + c = 0 + e=s=0 + + with torch.set_grad_enabled(train): + for vid, cls in dataloader[phase]: + if c%200 == 0: + print('epoch',epoch,'iter',c) + #s=time.time() + #print('btw batch', (s-e)*1000) + vid = vid.to(self.device) + cls = cls.to(self.device) + + outputs = model(vid) + + pred = torch.max(outputs, dim=1)[1] + corr = torch.sum((pred == cls).int()) + acc += corr.item() + tot += vid.size(0) + loss = F.cross_entropy(outputs, cls) + #print(loss) + + if phase == 'train': + solver.zero_grad() + loss.backward() + solver.step() + log['iterations'].append(loss.item()) + + tloss += loss.item() + c += 1 + #e=time.time() + #print('batch',batch_size,'time',(e-s)*1000) + + if phase == 'train': + log['epoch'].append(tloss/c) + log['train_acc'].append(acc/tot) + print('train loss',tloss/c, 'acc', acc/tot) + else: + log['validation'].append(tloss/c) + log['val_acc'].append(acc/tot) + print('val loss', tloss/c, 'acc', acc/tot) + lr_sched.step(tloss/c) + + with open(os.path.join(log_path,'log.json'), 'w') as out: + json.dump(log, out) + torch.save(model.state_dict(), os.path.join(log_path, 'hmdb_flow-of-flow_2p1d.pt')) + + + #lr_sched.step() From 6c6b14c67847da704ea586802b2a391bf1ead342 Mon Sep 17 00:00:00 2001 From: rfeinleib3 Date: Sun, 18 Jul 2021 16:33:38 -0400 Subject: [PATCH 2/4] fix links --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1660306..8008524 100644 --- a/README.md +++ b/README.md @@ -17,13 +17,13 @@ If you find the code useful for your research, please cite our paper: # Representation Flow Layer -![tsf](/examples/flow-layer.png?raw=true "repflow") +![tsf](./examples/flow-layer.png?raw=true "repflow") We introduce the representation flow layer, which can be found in [rep_flow_layer.py](rep_flow_layer.py). This layer iteratively estimates the flow, can be applied to CNN feature maps, and is fully learnable to maximize classification performance. # Activity Recognition Experiments -![model overview](/examples/flow-in-network.png?raw=true "model overview") +![model overview](./examples/flow-in-network.png?raw=true "model overview") We include our pretrained models for HMDB and Kinetics in [models/](models). From f2409d2cea26ef5fbf2492d81163b89cae8617fa Mon Sep 17 00:00:00 2001 From: rfeinleib3 Date: Wed, 21 Jul 2021 21:53:49 -0400 Subject: [PATCH 3/4] added colab nb and train class --- CS7643Sum21ProjTeam59.ipynb | 369 +----------------------------------- train_model_class.py | 1 + 2 files changed, 2 insertions(+), 368 deletions(-) diff --git a/CS7643Sum21ProjTeam59.ipynb b/CS7643Sum21ProjTeam59.ipynb index 6d65e0f..83fa0f2 100644 --- a/CS7643Sum21ProjTeam59.ipynb +++ b/CS7643Sum21ProjTeam59.ipynb @@ -1,368 +1 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "executionInfo": { - "elapsed": 38921, - "status": "ok", - "timestamp": 1626215545604, - "user": { - "displayName": "Rick Feinleib", - "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14GjoqYHQlggzOnw7kbmibkVT3DL6W7pv4Ot4VJKd=s64", - "userId": "17023243058419009217" - }, - "user_tz": 240 - }, - "id": "7OmNlqc1n2Jv", - "outputId": "c1b92d56-ed3f-414d-b116-e2ccb39568be" - }, - "outputs": [], - "source": [ - "from google.colab import drive\n", - "drive.mount('/content/drive')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "executionInfo": { - "elapsed": 595, - "status": "ok", - "timestamp": 1626216249718, - "user": { - "displayName": "Rick Feinleib", - "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14GjoqYHQlggzOnw7kbmibkVT3DL6W7pv4Ot4VJKd=s64", - "userId": "17023243058419009217" - }, - "user_tz": 240 - }, - "id": "ZnX1aeNg_kOw", - "outputId": "f415d6af-8a4b-4f8a-f313-763cba8eb438" - }, - "outputs": [], - "source": [ - "%cd '/content/drive/MyDrive'" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "executionInfo": { - "elapsed": 186, - "status": "ok", - "timestamp": 1626221994006, - "user": { - "displayName": "Rick Feinleib", - "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14GjoqYHQlggzOnw7kbmibkVT3DL6W7pv4Ot4VJKd=s64", - "userId": "17023243058419009217" - }, - "user_tz": 240 - }, - "id": "Uc6C2Mz7WXd1" - }, - "outputs": [], - "source": [ - "usr = 'rfeinleib3'\n", - "p = 'xxxxx'" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "executionInfo": { - "elapsed": 7911, - "status": "ok", - "timestamp": 1626222035230, - "user": { - "displayName": "Rick Feinleib", - "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14GjoqYHQlggzOnw7kbmibkVT3DL6W7pv4Ot4VJKd=s64", - "userId": "17023243058419009217" - }, - "user_tz": 240 - }, - "id": "RHepLguDAQL_", - "outputId": "601b3fb9-c003-49cc-85fd-a2e366977ab1" - }, - "outputs": [], - "source": [ - "!git clone https://{usr}:{p}@github.com/GaTechTeam59/representation-flow-cvpr19.git" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "/home/rick/dl-7643/GaTechTeam59/representation-flow-cvpr19\r\n" - ] - } - ], - "source": [ - "!pwd" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "id": "p38K8YZOfqf8" - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "/home/rick/dl-7643/GaTechTeam59/representation-flow-cvpr19\n" - ] - } - ], - "source": [ - "%cd 'representation-flow-cvpr19'" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "phla7FIdbC4C" - }, - "source": [ - "## Start code here" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "id": "OIjY-l7KbI4e" - }, - "outputs": [], - "source": [ - "import torch\n", - "from train_model_class import Model\n", - "\n", - "# for auto-reloading external modules\n", - "# see http://stackoverflow.com/questions/1907993/autoreload-of-modules-in-ipython\n", - "%load_ext autoreload\n", - "%autoreload 2" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "executionInfo": { - "elapsed": 261, - "status": "ok", - "timestamp": 1626054158450, - "user": { - "displayName": "Rick Feinleib", - "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14GjoqYHQlggzOnw7kbmibkVT3DL6W7pv4Ot4VJKd=s64", - "userId": "17023243058419009217" - }, - "user_tz": 240 - }, - "id": "eiV_KQz7nsL3", - "outputId": "2afd568a-890f-47fe-8b30-dbe24eb1fc81", - "tags": [] - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "You are using device: cpu\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/home/rick/anaconda3/lib/python3.8/site-packages/torch/cuda/__init__.py:52: UserWarning: CUDA initialization: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx (Triggered internally at /pytorch/c10/cuda/CUDAFunctions.cpp:100.)\n", - " return torch._C._cuda_getDeviceCount() > 0\n" - ] - } - ], - "source": [ - "# Check device availability\n", - "device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\n", - "print(\"You are using device: %s\" % device)" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "id": "JbDFZI6GjZFc" - }, - "outputs": [], - "source": [ - "class Args:\n", - " def __init__(self, mode: str='rgb', exp_name: str=\"hmdb-test\", batch_size: int=32, length: int=32, \n", - " learnable: str=\"[0,1,1,1,1]\", niter: int=20, system: str=\"hmdb\", model: str=\"3d\"):\n", - " self.mode = mode\n", - " self.exp_name = exp_name\n", - " self.batch_size = batch_size\n", - " self.length = length\n", - " self.learnable = learnable\n", - " self.niter = niter\n", - " self.system = system\n", - " self.model = model" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "id": "q1NuorLJiGNf" - }, - "outputs": [], - "source": [ - "# args = Args(mode=\"rgb\", exp_name=\"hmdb-test\", batch_size=32, length=32, learnable=\"[0,1,1,1,1]\", niter=20, system=\"hmdb\", model=\"3d\")\n", - "args = Args()\n", - "model = Model(device)" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "193\n", - "179 22\n" - ] - }, - { - "ename": "FileNotFoundError", - "evalue": "Caught FileNotFoundError in DataLoader worker process 0.\nOriginal Traceback (most recent call last):\n File \"/home/rick/anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py\", line 198, in _worker_loop\n data = fetcher.fetch(index)\n File \"/home/rick/anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py\", line 44, in fetch\n data = [self.dataset[idx] for idx in possibly_batched_index]\n File \"/home/rick/anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py\", line 44, in \n data = [self.dataset[idx] for idx in possibly_batched_index]\n File \"/home/rick/dl-7643/GaTechTeam59/representation-flow-cvpr19/hmdb_dataset.py\", line 59, in __getitem__\n with open(vid, 'rb') as f:\nFileNotFoundError: [Errno 2] No such file or directory: '/ssd/hmdb/rgb_BIG_FISH_eat_h_nm_np1_ri_goo_30.mp4'\n", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtrain\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;32m~/dl-7643/GaTechTeam59/representation-flow-cvpr19/train_model_class.py\u001b[0m in \u001b[0;36mtrain\u001b[0;34m(self, args)\u001b[0m\n\u001b[1;32m 154\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 155\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mtorch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mset_grad_enabled\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtrain\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 156\u001b[0;31m \u001b[0;32mfor\u001b[0m \u001b[0mvid\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcls\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mdataloader\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mphase\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 157\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mc\u001b[0m\u001b[0;34m%\u001b[0m\u001b[0;36m200\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 158\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'epoch'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mepoch\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m'iter'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mc\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/anaconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py\u001b[0m in \u001b[0;36m__next__\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 433\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_sampler_iter\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 434\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_reset\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 435\u001b[0;31m \u001b[0mdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_next_data\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 436\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_num_yielded\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 437\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_dataset_kind\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0m_DatasetKind\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mIterable\u001b[0m \u001b[0;32mand\u001b[0m\u001b[0;31m \u001b[0m\u001b[0;31m\\\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/anaconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py\u001b[0m in \u001b[0;36m_next_data\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 1083\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1084\u001b[0m \u001b[0;32mdel\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_task_info\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0midx\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1085\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_process_data\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1086\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1087\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_try_put_index\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/anaconda3/lib/python3.8/site-packages/torch/utils/data/dataloader.py\u001b[0m in \u001b[0;36m_process_data\u001b[0;34m(self, data)\u001b[0m\n\u001b[1;32m 1109\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_try_put_index\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1110\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mExceptionWrapper\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1111\u001b[0;31m \u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreraise\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1112\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1113\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/anaconda3/lib/python3.8/site-packages/torch/_utils.py\u001b[0m in \u001b[0;36mreraise\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 426\u001b[0m \u001b[0;31m# have message field\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 427\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexc_type\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmessage\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmsg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 428\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexc_type\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmsg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 429\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 430\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mFileNotFoundError\u001b[0m: Caught FileNotFoundError in DataLoader worker process 0.\nOriginal Traceback (most recent call last):\n File \"/home/rick/anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py\", line 198, in _worker_loop\n data = fetcher.fetch(index)\n File \"/home/rick/anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py\", line 44, in fetch\n data = [self.dataset[idx] for idx in possibly_batched_index]\n File \"/home/rick/anaconda3/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py\", line 44, in \n data = [self.dataset[idx] for idx in possibly_batched_index]\n File \"/home/rick/dl-7643/GaTechTeam59/representation-flow-cvpr19/hmdb_dataset.py\", line 59, in __getitem__\n with open(vid, 'rb') as f:\nFileNotFoundError: [Errno 2] No such file or directory: '/ssd/hmdb/rgb_BIG_FISH_eat_h_nm_np1_ri_goo_30.mp4'\n" - ] - } - ], - "source": [ - "model.train(args)" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [], - "source": [ - "import datetime" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'07-17-1937'" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "datetime.datetime.today().strftime('%m-%d-%H%M')" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [], - "source": [ - "!mkdir logs" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "executionInfo": { - "elapsed": 553, - "status": "ok", - "timestamp": 1626219170610, - "user": { - "displayName": "Rick Feinleib", - "photoUrl": "https://lh3.googleusercontent.com/a-/AOh14GjoqYHQlggzOnw7kbmibkVT3DL6W7pv4Ot4VJKd=s64", - "userId": "17023243058419009217" - }, - "user_tz": 240 - }, - "id": "j4e806VECt8D" - }, - "outputs": [], - "source": [ - "#!python train_model.py -mode rgb -exp_name \"hmdb-test\" -batch_size 32 -length 32 -learnable \"[0,1,1,1,1]\" -niter 20 -system hmdb -model \"3d\"" - ] - } - ], - "metadata": { - "colab": { - "authorship_tag": "ABX9TyOsbdZ6pIid2PXEU8d3nNuQ", - "collapsed_sections": [], - "name": "CS7643Sum21ProjTeam59.ipynb", - "provenance": [] - }, - "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.8.5" - } - }, - "nbformat": 4, - "nbformat_minor": 1 -} +{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"CS7643Sum21ProjTeam59.ipynb","provenance":[],"collapsed_sections":["mCxFIVoQuDZQ"]},"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.8.5"}},"cells":[{"cell_type":"markdown","metadata":{"id":"WkxIUDpV5CGh"},"source":["### The typical starting cell for a colab notebook"]},{"cell_type":"markdown","metadata":{"id":"RUkK19pL5fM8"},"source":["Run cell (Shift+Enter), click link, sign into Google account (or grant access), copy access code to clipboard, paste (Ctrl+V) into box below, and press Enter"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"7OmNlqc1n2Jv","executionInfo":{"status":"ok","timestamp":1626907755278,"user_tz":240,"elapsed":34150,"user":{"displayName":"Rick Feinleib","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GjoqYHQlggzOnw7kbmibkVT3DL6W7pv4Ot4VJKd=s64","userId":"17023243058419009217"}},"outputId":"a3ddf84c-f97d-4476-b8cf-6e1ab0936895"},"source":["from google.colab import drive\n","drive.mount('/content/drive')"],"execution_count":null,"outputs":[{"output_type":"stream","text":["Mounted at /content/drive\n"],"name":"stdout"}]},{"cell_type":"markdown","metadata":{"id":"mCxFIVoQuDZQ"},"source":["#### Use the following cells for first time setup"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"ZnX1aeNg_kOw","executionInfo":{"status":"ok","timestamp":1626916183839,"user_tz":240,"elapsed":191,"user":{"displayName":"Rick Feinleib","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GjoqYHQlggzOnw7kbmibkVT3DL6W7pv4Ot4VJKd=s64","userId":"17023243058419009217"}},"outputId":"84ac7048-6dc0-4ae7-cc5c-13d48706f89b"},"source":["%cd '/content/drive/MyDrive'"],"execution_count":25,"outputs":[{"output_type":"stream","text":["/content/drive/MyDrive\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"Uc6C2Mz7WXd1"},"source":["usr = 'rfeinleib3'\n","p = 'xxxxx'"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"id":"RHepLguDAQL_"},"source":["!git clone https://{usr}:{p}@github.com/GaTechTeam59/representation-flow-cvpr19.git"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"id":"H48hT44Unrhn","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1626912787193,"user_tz":240,"elapsed":613,"user":{"displayName":"Rick Feinleib","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GjoqYHQlggzOnw7kbmibkVT3DL6W7pv4Ot4VJKd=s64","userId":"17023243058419009217"}},"outputId":"f7a7e5e1-b20f-40a6-e987-2502b6618ad3"},"source":["!pwd"],"execution_count":null,"outputs":[{"output_type":"stream","text":["/content/drive/My Drive\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"p38K8YZOfqf8"},"source":["%cd 'representation-flow-cvpr19'"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"id":"LIy3t3a1qMUq"},"source":["# This cell from https://programmersought.com/article/80741316664/\n","!git clone https://github.com/dukebw/lintel.git\n","%cd lintel\n","!python setup.py build\n","!python setup.py install"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"id":"Zy7ob1t5yx1J","executionInfo":{"status":"ok","timestamp":1626917724950,"user_tz":240,"elapsed":630,"user":{"displayName":"Rick Feinleib","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GjoqYHQlggzOnw7kbmibkVT3DL6W7pv4Ot4VJKd=s64","userId":"17023243058419009217"}}},"source":["# This code downloads a small mp4 file from the web. No idea if this really is working\n","import requests\n","file_url = \"https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4\"\n","\n","r = requests.get(file_url, stream=True)\n","\n","with open(\"/content/drive/My Drive/representation-flow-cvpr19/data/sample.mp4\", \"wb\") as file:\n"," for blk in r.iter_content(chunk_size=1024):\n"," if blk:\n"," file.write(blk)"],"execution_count":33,"outputs":[]},{"cell_type":"code","metadata":{"id":"WIGP7VfszqFU"},"source":["# if not in lintel dir, then run: %cd lintel"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"id":"yHWE8_4QkR_Y"},"source":["!lintel_test --filename ../data/sample.mp4 --width 480 --height 270"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"CpjEZ08tuU8_"},"source":["#### Need to run this cell to start using the Notebook"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"YwO-IKiltc8S","executionInfo":{"status":"ok","timestamp":1626915828690,"user_tz":240,"elapsed":218,"user":{"displayName":"Rick Feinleib","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GjoqYHQlggzOnw7kbmibkVT3DL6W7pv4Ot4VJKd=s64","userId":"17023243058419009217"}},"outputId":"c0c2f77c-08b4-49f1-d6c3-92bb41899fac"},"source":["%cd '/content/drive/MyDrive/representation-flow-cvpr19'"],"execution_count":null,"outputs":[{"output_type":"stream","text":["/content/drive/MyDrive/representation-flow-cvpr19\n"],"name":"stdout"}]},{"cell_type":"markdown","metadata":{"id":"phla7FIdbC4C"},"source":["## Start code here"]},{"cell_type":"code","metadata":{"id":"OIjY-l7KbI4e"},"source":["import torch\n","from train_model_class import Model\n","\n","# for auto-reloading external modules\n","# see http://stackoverflow.com/questions/1907993/autoreload-of-modules-in-ipython\n","%load_ext autoreload\n","%autoreload 2"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"eiV_KQz7nsL3","tags":[],"executionInfo":{"status":"ok","timestamp":1626915838786,"user_tz":240,"elapsed":469,"user":{"displayName":"Rick Feinleib","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GjoqYHQlggzOnw7kbmibkVT3DL6W7pv4Ot4VJKd=s64","userId":"17023243058419009217"}},"outputId":"6d7f63a8-be83-4bc2-ac6a-1adf47dba0f0"},"source":["# Check device availability\n","device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\n","print(\"You are using device: %s\" % device)"],"execution_count":null,"outputs":[{"output_type":"stream","text":["You are using device: cpu\n"],"name":"stdout"}]},{"cell_type":"code","metadata":{"id":"JbDFZI6GjZFc"},"source":["class Args:\n"," def __init__(self, mode: str='rgb', exp_name: str=\"hmdb-test\", batch_size: int=32, length: int=32, \n"," learnable: str=\"[0,1,1,1,1]\", niter: int=20, system: str=\"hmdb\", model: str=\"3d\"):\n"," self.mode = mode\n"," self.exp_name = exp_name\n"," self.batch_size = batch_size\n"," self.length = length\n"," self.learnable = learnable\n"," self.niter = niter\n"," self.system = system\n"," self.model = model"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"id":"q1NuorLJiGNf"},"source":["# args = Args(mode=\"rgb\", exp_name=\"hmdb-test\", batch_size=32, length=32, learnable=\"[0,1,1,1,1]\", niter=20, system=\"hmdb\", model=\"3d\")\n","args = Args()\n","model = Model(device)"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":1000},"id":"3WhE9ng4nrhx","executionInfo":{"status":"error","timestamp":1626916034460,"user_tz":240,"elapsed":3431,"user":{"displayName":"Rick Feinleib","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GjoqYHQlggzOnw7kbmibkVT3DL6W7pv4Ot4VJKd=s64","userId":"17023243058419009217"}},"outputId":"d261ec9c-ebfb-43f2-e380-208e086706dd"},"source":["model.train(args)"],"execution_count":null,"outputs":[{"output_type":"stream","text":["/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py:481: UserWarning: This DataLoader will create 8 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":"stderr"},{"output_type":"stream","text":["193\n","179 22\n"],"name":"stdout"},{"output_type":"stream","text":["/usr/local/lib/python3.7/dist-packages/torch/optim/sgd.py:69: UserWarning: optimizer contains a parameter group with duplicate parameters; in future, this will cause an error; see github.com/pytorch/pytorch/issues/40967 for more information\n"," super(SGD, self).__init__(params, defaults)\n"],"name":"stderr"},{"output_type":"error","ename":"FileNotFoundError","evalue":"ignored","traceback":["\u001b[0;31m---------------------------------------------------------------------------\u001b[0m","\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)","\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtrain\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m","\u001b[0;32m/content/drive/MyDrive/representation-flow-cvpr19/train_model_class.py\u001b[0m in \u001b[0;36mtrain\u001b[0;34m(self, args)\u001b[0m\n\u001b[1;32m 155\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 156\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mtorch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mset_grad_enabled\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtrain\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 157\u001b[0;31m \u001b[0;32mfor\u001b[0m \u001b[0mvid\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcls\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mdataloader\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mphase\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 158\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mc\u001b[0m\u001b[0;34m%\u001b[0m\u001b[0;36m200\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 159\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'epoch'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mepoch\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m'iter'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mc\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py\u001b[0m in \u001b[0;36m__next__\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 519\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_sampler_iter\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 520\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_reset\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 521\u001b[0;31m \u001b[0mdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_next_data\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 522\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_num_yielded\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 523\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_dataset_kind\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0m_DatasetKind\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mIterable\u001b[0m \u001b[0;32mand\u001b[0m\u001b[0;31m \u001b[0m\u001b[0;31m\\\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py\u001b[0m in \u001b[0;36m_next_data\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 1201\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1202\u001b[0m \u001b[0;32mdel\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_task_info\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0midx\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1203\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_process_data\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1204\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1205\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_try_put_index\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py\u001b[0m in \u001b[0;36m_process_data\u001b[0;34m(self, data)\u001b[0m\n\u001b[1;32m 1227\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_try_put_index\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1228\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mExceptionWrapper\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1229\u001b[0;31m \u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreraise\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1230\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1231\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/torch/_utils.py\u001b[0m in \u001b[0;36mreraise\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 423\u001b[0m \u001b[0;31m# have message field\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 424\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexc_type\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmessage\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmsg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 425\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexc_type\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmsg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 426\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 427\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;31mFileNotFoundError\u001b[0m: Caught FileNotFoundError in DataLoader worker process 0.\nOriginal Traceback (most recent call last):\n File \"/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/worker.py\", line 287, in _worker_loop\n data = fetcher.fetch(index)\n File \"/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py\", line 44, in fetch\n data = [self.dataset[idx] for idx in possibly_batched_index]\n File \"/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py\", line 44, in \n data = [self.dataset[idx] for idx in possibly_batched_index]\n File \"/content/drive/My Drive/representation-flow-cvpr19/hmdb_dataset.py\", line 59, in __getitem__\n with open(vid, 'rb') as f:\nFileNotFoundError: [Errno 2] No such file or directory: '/ssd/hmdb/rgb_YouTube_smiles!_smile_h_nm_np1_fr_med_8.mp4'\n"]}]},{"cell_type":"code","metadata":{"id":"j4e806VECt8D"},"source":["#!python train_model.py -mode rgb -exp_name \"hmdb-test\" -batch_size 32 -length 32 -learnable \"[0,1,1,1,1]\" -niter 20 -system hmdb -model \"3d\""],"execution_count":null,"outputs":[]}]} \ No newline at end of file diff --git a/train_model_class.py b/train_model_class.py index 7ca4e0c..c5e7456 100644 --- a/train_model_class.py +++ b/train_model_class.py @@ -119,6 +119,7 @@ def train(self, args): # ################# log_name = datetime.datetime.today().strftime('%m-%d-%H%M')+'-'+args.exp_name + os.mkdir('./logs') # REF added log_path = os.path.join('logs/',log_name) os.mkdir(log_path) os.system('cp * logs/'+log_name+'/') From c66cad97d1f4f1a844e03a563570161fd00b8b4d Mon Sep 17 00:00:00 2001 From: rfeinleib3 Date: Wed, 28 Jul 2021 19:06:10 -0400 Subject: [PATCH 4/4] add start point project.py --- project.py | 25 +++++++++++++++++++++++++ train_model_class.py | 22 ++++++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 project.py diff --git a/project.py b/project.py new file mode 100644 index 0000000..7a30141 --- /dev/null +++ b/project.py @@ -0,0 +1,25 @@ +import torch +from train_model_class import Model + +# Check device availability +device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') +print("You are using device: %s" % device) + +class Args: + def __init__(self, mode: str='rgb', exp_name: str="hmdb-test", batch_size: int=32, length: int=32, + learnable: str="[0,1,1,1,1]", niter: int=20, system: str="hmdb", model: str="3d"): + self.mode = mode + self.exp_name = exp_name + self.batch_size = batch_size + self.length = length + self.learnable = learnable + self.niter = niter + self.system = system + self.model = model + + +# args = Args(mode="rgb", exp_name="hmdb-test", batch_size=32, length=32, learnable="[0,1,1,1,1]", niter=20, system="hmdb", model="3d") +args = Args() +model = Model(device) + +model.train(args) diff --git a/train_model_class.py b/train_model_class.py index c5e7456..bce6b16 100644 --- a/train_model_class.py +++ b/train_model_class.py @@ -38,10 +38,28 @@ def train(self, args): if args.system == 'hmdb': from hmdb_dataset import HMDB as DS - dataseta = DS('data/hmdb/split1_train.txt', '/ssd/hmdb/', model=args.model, mode=args.mode, length=args.length) + dataseta = DS('data/hmdb/split0_train.txt', './ssd/hmdb/', model=args.model, mode=args.mode, length=args.length) dl = torch.utils.data.DataLoader(dataseta, batch_size=batch_size, shuffle=True, num_workers=8, pin_memory=True) - dataset = DS('data/hmdb/split1_test.txt', '/ssd/hmdb/', model=args.model, mode=args.mode, length=args.length, c2i=dataseta.class_to_id) + dataset = DS('data/hmdb/split0_test.txt', './ssd/hmdb/', model=args.model, mode=args.mode, length=args.length, c2i=dataseta.class_to_id) + vdl = torch.utils.data.DataLoader(dataset, batch_size=batch_size, shuffle=True, num_workers=8, pin_memory=True) + dataloader = {'train':dl, 'val':vdl} + + if args.system == 'hmdb_noise_aware': + from hmdb_dataset import HMDB as DS + dataseta = DS('data/hmdb/split1_train.txt', './ssd/hmdb/', model=args.model, mode=args.mode, length=args.length) + dl = torch.utils.data.DataLoader(dataseta, batch_size=batch_size, shuffle=True, num_workers=8, pin_memory=True) + + dataset = DS('data/hmdb/split1_test.txt', './ssd/hmdb/', model=args.model, mode=args.mode, length=args.length, c2i=dataseta.class_to_id) + vdl = torch.utils.data.DataLoader(dataset, batch_size=batch_size, shuffle=True, num_workers=8, pin_memory=True) + dataloader = {'train':dl, 'val':vdl} + + if args.system == 'hmdb_noisy_test': + from hmdb_dataset import HMDB as DS + dataseta = DS('data/hmdb/split0_train.txt', './ssd/hmdb/', model=args.model, mode=args.mode, length=args.length) + dl = torch.utils.data.DataLoader(dataseta, batch_size=batch_size, shuffle=True, num_workers=8, pin_memory=True) + + dataset = DS('data/hmdb/split1_test.txt', './ssd/hmdb/', model=args.model, mode=args.mode, length=args.length, c2i=dataseta.class_to_id) vdl = torch.utils.data.DataLoader(dataset, batch_size=batch_size, shuffle=True, num_workers=8, pin_memory=True) dataloader = {'train':dl, 'val':vdl}