{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"ESRGAN Colab.ipynb","provenance":[{"file_id":"https://github.com/AhabbscienceStudioPak/ESRGAN/blob/master/ESRGAN_Colab.ipynb","timestamp":1677818747534}]},"kernelspec":{"name":"python3","display_name":"Python 3"},"accelerator":"GPU"},"cells":[{"cell_type":"markdown","metadata":{"id":"r6VnlRGZ9PiH"},"source":["# ESRGAN (new arch.) on Colab\n","Official Github Repo: https://github.com/xinntao/ESRGAN
\n","This notebook was curated by M. Ahabb (Ahabbscience Studio)"]},{"cell_type":"code","metadata":{"id":"Os9gHotRC8y1","colab":{"base_uri":"https://localhost:8080/"},"outputId":"be8eee0a-6cd3-4182-9335-f0902a4e47cb","executionInfo":{"status":"ok","timestamp":1677815884776,"user_tz":360,"elapsed":298,"user":{"displayName":"","userId":""}}},"source":["!nvidia-smi #recommended gpus are p100 and T4"],"execution_count":22,"outputs":[{"output_type":"stream","name":"stdout","text":["NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.\n","\n"]}]},{"cell_type":"code","source":[" !sudo apt install -y nvidia-driver"],"metadata":{"id":"n-hAearYoPKn","executionInfo":{"status":"ok","timestamp":1677816305472,"user_tz":360,"elapsed":2104,"user":{"displayName":"","userId":""}},"outputId":"30a28ed3-0725-4689-8ed1-fb40ac77cef0","colab":{"base_uri":"https://localhost:8080/"}},"execution_count":30,"outputs":[{"output_type":"stream","name":"stdout","text":["Reading package lists... Done\n","Building dependency tree \n","Reading state information... Done\n","Package nvidia-driver is not available, but is referred to by another package.\n","This may mean that the package is missing, has been obsoleted, or\n","is only available from another source\n","\n","\u001b[1;31mE: \u001b[0mPackage 'nvidia-driver' has no installation candidate\u001b[0m\n"]}]},{"cell_type":"code","source":["!wget https://developer.nvidia.com/compute/cuda/9.2/Prod/local_installers/cuda-repo-ubuntu1710-9-2-local_9.2.88-1_amd64"],"metadata":{"id":"M1dY-hzWl02K","executionInfo":{"status":"ok","timestamp":1677815863730,"user_tz":360,"elapsed":20823,"user":{"displayName":"","userId":""}},"outputId":"0fdd8ce6-4530-43a5-ab5f-5352b7b65915","colab":{"base_uri":"https://localhost:8080/"}},"execution_count":20,"outputs":[{"output_type":"stream","name":"stdout","text":["--2023-03-03 03:57:21-- https://developer.nvidia.com/compute/cuda/9.2/Prod/local_installers/cuda-repo-ubuntu1710-9-2-local_9.2.88-1_amd64\n","Resolving developer.nvidia.com (developer.nvidia.com)... 152.195.19.142\n","Connecting to developer.nvidia.com (developer.nvidia.com)|152.195.19.142|:443... connected.\n","HTTP request sent, awaiting response... 301 Moved Permanently\n","Location: https://developer.nvidia.com/downloads/compute/cuda/9.2/Prod/local_installers/cuda-repo-ubuntu1710-9-2-local_9.2.88-1_amd64 [following]\n","--2023-03-03 03:57:21-- https://developer.nvidia.com/downloads/compute/cuda/9.2/Prod/local_installers/cuda-repo-ubuntu1710-9-2-local_9.2.88-1_amd64\n","Reusing existing connection to developer.nvidia.com:443.\n","HTTP request sent, awaiting response... 302 Found\n","Location: https://developer.download.nvidia.com/compute/cuda/9.2/secure/Prod/local_installers/cuda-repo-ubuntu1710-9-2-local_9.2.88-1_amd64.deb?l5baGVQCHJo-qe2xSo1GJ0zNvl4sMTAJPy-Fo5YQvWL3A5rsMOfGF3PnsYeoKgzVpo8S7YMoaP25a1lnOkL6uz-wSqSzBcnVg2VfgZ66B9NKGSFHMDhW6tzTESpWcvLN1199LHSiT0-2VlJt8CHhJ3DrldexvIZJDae0-Z4hbeZXEbt9xHbsAEzL1wtz6unraensOt6dRgQ5N605Idg= [following]\n","--2023-03-03 03:57:21-- https://developer.download.nvidia.com/compute/cuda/9.2/secure/Prod/local_installers/cuda-repo-ubuntu1710-9-2-local_9.2.88-1_amd64.deb?l5baGVQCHJo-qe2xSo1GJ0zNvl4sMTAJPy-Fo5YQvWL3A5rsMOfGF3PnsYeoKgzVpo8S7YMoaP25a1lnOkL6uz-wSqSzBcnVg2VfgZ66B9NKGSFHMDhW6tzTESpWcvLN1199LHSiT0-2VlJt8CHhJ3DrldexvIZJDae0-Z4hbeZXEbt9xHbsAEzL1wtz6unraensOt6dRgQ5N605Idg=\n","Resolving developer.download.nvidia.com (developer.download.nvidia.com)... 152.195.19.142\n","Connecting to developer.download.nvidia.com (developer.download.nvidia.com)|152.195.19.142|:443... connected.\n","HTTP request sent, awaiting response... 200 OK\n","Length: 1269204396 (1.2G) [application/x-deb]\n","Saving to: ‘cuda-repo-ubuntu1710-9-2-local_9.2.88-1_amd64’\n","\n","cuda-repo-ubuntu171 100%[===================>] 1.18G 61.7MB/s in 20s \n","\n","2023-03-03 03:57:42 (60.5 MB/s) - ‘cuda-repo-ubuntu1710-9-2-local_9.2.88-1_amd64’ saved [1269204396/1269204396]\n","\n"]}]},{"cell_type":"markdown","metadata":{"id":"Bi7GziskW-p5"},"source":["Clone ESRGAN repo"]},{"cell_type":"code","metadata":{"id":"E-qvTH2nWSDN","colab":{"base_uri":"https://localhost:8080/"},"outputId":"1784dd05-4335-46f6-8926-0754757bdf17","executionInfo":{"status":"ok","timestamp":1677815647532,"user_tz":360,"elapsed":1127,"user":{"displayName":"","userId":""}}},"source":["\n","!git clone https://github.com/xinntao/ESRGAN"],"execution_count":16,"outputs":[{"output_type":"stream","name":"stdout","text":["Cloning into 'ESRGAN'...\n","remote: Enumerating objects: 225, done.\u001b[K\n","remote: Total 225 (delta 0), reused 0 (delta 0), pack-reused 225\u001b[K\n","Receiving objects: 100% (225/225), 24.86 MiB | 39.90 MiB/s, done.\n","Resolving deltas: 100% (86/86), done.\n"]}]},{"cell_type":"markdown","metadata":{"id":"zVx7tHDE8HnH"},"source":["This is optional if you want to link your google drive to the notebook to add files or pretrained models of your choice from your google drive."]},{"cell_type":"code","metadata":{"id":"mojoepFQ8Gaf","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1677814723132,"user_tz":360,"elapsed":15795,"user":{"displayName":"","userId":""}},"outputId":"19ff0b9b-a74a-44c3-fe98-72578fab67df"},"source":["from google.colab import drive\n","drive.mount('/content/gdrive')"],"execution_count":3,"outputs":[{"output_type":"stream","name":"stdout","text":["Mounted at /content/gdrive\n"]}]},{"cell_type":"markdown","metadata":{"id":"Lf5gDnAI8cdf"},"source":["(Optional) Add Files via youtube_dl"]},{"cell_type":"code","metadata":{"id":"tZ2Sn97Y81Ww"},"source":["!pip install youtube_dl"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"id":"hiGc2_eL8nrP"},"source":["!mkdir -p /content/ESRGAN/video_input\n","!youtube-dl -f 18 -o \"/content/ESRGAN/video_input/video.mp4\" https://www.youtube.com/watch?v=ljwTaMfORzs "],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"kiE9gKYvZMqN"},"source":["Run this cell to upload images"]},{"cell_type":"code","metadata":{"id":"MZuFBZncXRy1","colab":{"base_uri":"https://localhost:8080/","height":202},"outputId":"a6b77b97-5a91-4570-aac9-a36f5d53dff4","executionInfo":{"status":"ok","timestamp":1677814824325,"user_tz":360,"elapsed":90761,"user":{"displayName":"","userId":""}}},"source":["%cd /content/ESRGAN/LR\n","\n","from google.colab import files\n","uploaded = files.upload() \n","for filename in uploaded.keys():\n"," print('User uploaded file \"{name}\" with {length} bytes'.format(name=filename, length=len(uploaded[filename])))"],"execution_count":4,"outputs":[{"output_type":"stream","name":"stdout","text":["/content/ESRGAN/LR\n"]},{"output_type":"display_data","data":{"text/plain":[""],"text/html":["\n"," \n"," \n"," Upload widget is only available when the cell has been executed in the\n"," current browser session. Please rerun this cell to enable.\n"," \n"," "]},"metadata":{}},{"output_type":"stream","name":"stdout","text":["Saving Y2Mate.is - Part 3 Cooking with Betty Crocker-B_igcIKV5BQ-720p-1655558503913~2.mp4 to Y2Mate.is - Part 3 Cooking with Betty Crocker-B_igcIKV5BQ-720p-1655558503913~2.mp4\n","User uploaded file \"Y2Mate.is - Part 3 Cooking with Betty Crocker-B_igcIKV5BQ-720p-1655558503913~2.mp4\" with 5598953 bytes\n"]}]},{"cell_type":"markdown","metadata":{"id":"m-pVBNJJ5g7_"},"source":["Run this cell if you want to upload your video. Make sure your video filename contains no spaces, e.g, \"my_video\" - not \"my video\". And upload one video per operation."]},{"cell_type":"code","metadata":{"id":"0fgBfLuwYd8F","colab":{"base_uri":"https://localhost:8080/","height":167},"outputId":"69b2eac2-f298-43d6-de7b-4dbdfa54a0af","executionInfo":{"status":"ok","timestamp":1677815108046,"user_tz":360,"elapsed":206873,"user":{"displayName":"","userId":""}}},"source":["!mkdir -p /content/ESRGAN/video_input\n","%cd /content/ESRGAN/video_input\n","\n","from google.colab import files\n","uploaded = files.upload() \n","for filename in uploaded.keys():\n"," print('User uploaded file \"{name}\" with {length} bytes'.format(name=filename, length=len(uploaded[filename])))"],"execution_count":5,"outputs":[{"output_type":"stream","name":"stdout","text":["/content/ESRGAN/video_input\n"]},{"output_type":"display_data","data":{"text/plain":[""],"text/html":["\n"," \n"," \n"," Upload widget is only available when the cell has been executed in the\n"," current browser session. Please rerun this cell to enable.\n"," \n"," "]},"metadata":{}},{"output_type":"stream","name":"stdout","text":["Saving videoplayback~2.mp4 to videoplayback~2.mp4\n","User uploaded file \"videoplayback~2.mp4\" with 4824480 bytes\n"]}]},{"cell_type":"markdown","metadata":{"id":"bmIXu-DC5RyF"},"source":["Run this cell to convert your video to individual frames and save them to 'LR' folder."]},{"cell_type":"code","metadata":{"id":"-i7budAKZLgw","colab":{"base_uri":"https://localhost:8080/"},"outputId":"67335493-cc89-4c18-9ccf-469744986c60","executionInfo":{"status":"ok","timestamp":1677815115077,"user_tz":360,"elapsed":1713,"user":{"displayName":"","userId":""}}},"source":["%cd /content/ESRGAN/LR\n","!ffmpeg -i /content/ESRGAN/video_input/* %04d.png"],"execution_count":6,"outputs":[{"output_type":"stream","name":"stdout","text":["/content/ESRGAN/LR\n","ffmpeg version 4.2.7-0ubuntu0.1 Copyright (c) 2000-2022 the FFmpeg developers\n"," built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1)\n"," configuration: --prefix=/usr --extra-version=0ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared\n"," libavutil 56. 31.100 / 56. 31.100\n"," libavcodec 58. 54.100 / 58. 54.100\n"," libavformat 58. 29.100 / 58. 29.100\n"," libavdevice 58. 8.100 / 58. 8.100\n"," libavfilter 7. 57.100 / 7. 57.100\n"," libavresample 4. 0. 0 / 4. 0. 0\n"," libswscale 5. 5.100 / 5. 5.100\n"," libswresample 3. 5.100 / 3. 5.100\n"," libpostproc 55. 5.100 / 55. 5.100\n","Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/content/ESRGAN/video_input/videoplayback~2.mp4':\n"," Metadata:\n"," major_brand : mp42\n"," minor_version : 0\n"," compatible_brands: isommp42\n"," creation_time : 2017-04-11T01:34:56.000000Z\n"," com.android.version: 11\n"," Duration: 00:01:30.88, start: 0.000000, bitrate: 424 kb/s\n"," Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt470bg/smpte170m), 320x240, 325 kb/s, SAR 1:1 DAR 4:3, 24 fps, 24 tbr, 90k tbn, 180k tbc (default)\n"," Metadata:\n"," creation_time : 2023-02-19T23:30:22.000000Z\n"," handler_name : VideoHandle\n"," Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s (default)\n"," Metadata:\n"," creation_time : 2023-02-19T23:30:22.000000Z\n"," handler_name : SoundHandle\n","Stream mapping:\n"," Stream #0:0 -> #0:0 (h264 (native) -> png (native))\n","Press [q] to stop, [?] for help\n","Output #0, image2, to '%04d.png':\n"," Metadata:\n"," major_brand : mp42\n"," minor_version : 0\n"," compatible_brands: isommp42\n"," com.android.version: 11\n"," encoder : Lavf58.29.100\n"," Stream #0:0(eng): Video: png, rgb24, 320x240 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 24 fps, 24 tbn, 24 tbc (default)\n"," Metadata:\n"," creation_time : 2023-02-19T23:30:22.000000Z\n"," handler_name : VideoHandle\n"," encoder : Lavc58.54.100 png\n","frame= 99 fps=0.0 q=-0.0 Lsize=N/A time=00:00:04.12 bitrate=N/A speed=5.61x \n","video:11411kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown\n","Exiting normally, received signal 2.\n"]}]},{"cell_type":"markdown","metadata":{"id":"d8dvwYOp-ArK"},"source":["Download pretrained models"]},{"cell_type":"code","metadata":{"id":"xsO_9uQelXoG","colab":{"base_uri":"https://localhost:8080/","height":164},"outputId":"cc190836-7c7e-4fe4-bc12-881d41bcf023","executionInfo":{"status":"ok","timestamp":1677815133518,"user_tz":360,"elapsed":15319,"user":{"displayName":"","userId":""}}},"source":["import gdown\n","print(\"Downloading pretrained models\")\n","output1 = '/content/ESRGAN/models/RRDB_ESRGAN_x4.pth'\n","output2 = '/content/ESRGAN/models/RRDB_PSNR_x4.pth'\n","output3 = '/content/ESRGAN/models/PPON_D.pth'\n","output4 = '/content/ESRGAN/models/PPON_G.pth'\n","print ('Downloading RRDB_ESRGAN_x4.pth')\n","gdown.download('https://drive.google.com/uc?id=1TPrz5QKd8DHHt1k8SRtm6tMiPjz_Qene', output1, quiet=True) \n","print ('Downloading RRDB_PSNR_x4.pth')\n","gdown.download('https://drive.google.com/uc?id=1pJ_T-V1dpb1ewoEra1TGSWl5e6H7M4NN', output2, quiet=True)\n","print ('Downloading PPON_D.pth by Zheng Hui')\n","gdown.download('https://drive.google.com/uc?id=1Fr5aKCD6mw6P-hI0BZr6My2gHNhtUk-V', output3, quiet=True) \n","print ('Downloading PPON_G.pth by Zheng Hui')\n","gdown.download('https://drive.google.com/uc?id=12uR3BSftNA0HDYiKda23GyAj_crpSjOm', output4, quiet=True)"],"execution_count":7,"outputs":[{"output_type":"stream","name":"stdout","text":["Downloading pretrained models\n","Downloading RRDB_ESRGAN_x4.pth\n","Downloading RRDB_PSNR_x4.pth\n","Downloading PPON_D.pth by Zheng Hui\n","Downloading PPON_G.pth by Zheng Hui\n"]},{"output_type":"execute_result","data":{"text/plain":["'/content/ESRGAN/models/PPON_G.pth'"],"application/vnd.google.colaboratory.intrinsic+json":{"type":"string"}},"metadata":{},"execution_count":7}]},{"cell_type":"markdown","metadata":{"id":"8taWI7VI43A7"},"source":["Configure the code and run the cell to upscale images/video frames"]},{"cell_type":"code","metadata":{"id":"Rqh162AbbsjB","cellView":"form","colab":{"base_uri":"https://localhost:8080/"},"outputId":"3c6c988c-ebc7-4094-d788-aa307009f6a5"},"source":["#@title Upscale images/video frames\n","%cd /content/ESRGAN\n","\n","import os.path as osp\n","import glob\n","import cv2\n","import numpy as np\n","import torch\n","import RRDBNet_arch as arch\n","import requests\n","import imageio\n","import requests\n","import warnings\n","warnings.filterwarnings(\"ignore\")\n","from google.colab import files\n","\n","Choose_device = \"cpu\" #@param [\"cuda\",\"cpu\"]\n","\n","model_path = 'models/RRDB_PSNR_x4.pth' #@param ['models/RRDB_ESRGAN_x4.pth','models/RRDB_PSNR_x4.pth','models/PPON_G.pth','models/PPON_D.pth'] \n","device = torch.device(Choose_device) \n","\n","\n","test_img_folder = 'LR/*'\n","\n","model = arch.RRDBNet(3, 3, 64, 23, gc=32)\n","model.load_state_dict(torch.load(model_path), strict=True)\n","model.eval()\n","model = model.to(device)\n","\n","print('Model path {:s}. \\nTesting...'.format(model_path))\n","\n","idx = 0\n","for path in glob.glob(test_img_folder):\n"," idx += 1\n"," base = osp.splitext(osp.basename(path))[0]\n"," print(idx, base)\n"," # read images\n"," img = cv2.imread(path, cv2.IMREAD_COLOR)\n"," img = img * 1.0 / 255\n"," img = torch.from_numpy(np.transpose(img[:, :, [2, 1, 0]], (2, 0, 1))).float()\n"," img_LR = img.unsqueeze(0)\n"," img_LR = img_LR.to(device)\n","\n"," with torch.no_grad():\n"," output = model(img_LR).data.squeeze().float().cpu().clamp_(0, 1).numpy()\n"," output = np.transpose(output[[2, 1, 0], :, :], (1, 2, 0))\n"," output = (output * 255.0).round()\n"," cv2.imwrite('results/{:s}.png'.format(base), output)"],"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["/content/ESRGAN\n","Model path models/RRDB_PSNR_x4.pth. \n","Testing...\n","1 0006\n","2 0046\n","3 0001\n","4 0093\n","5 0033\n","6 0002\n","7 0095\n","8 baboon\n","9 0094\n","10 0049\n","11 0023\n","12 0065\n","13 0057\n","14 0013\n","15 0012\n","16 0014\n","17 0051\n","18 0036\n","19 0092\n","20 0016\n","21 0081\n","22 0026\n","23 0020\n","24 0005\n","25 0097\n","26 0085\n","27 0088\n","28 0021\n","29 0035\n","30 0050\n","31 0080\n","32 0091\n","33 0047\n","34 0011\n","35 0066\n","36 0086\n","37 0059\n","38 0009\n","39 0090\n","40 0071\n"]}]},{"cell_type":"markdown","metadata":{"id":"-6MfrTPk68a4"},"source":["Run this cell to encode your results into a video."]},{"cell_type":"code","metadata":{"id":"s2IZXfzLcYJI"},"source":["!ffmpeg -f image2 -framerate 25 -i /content/ESRGAN/results/%04d.png -c:v h264_nvenc -preset slow -qp 18 -pix_fmt yuv420p output.mp4"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"iM6hHGvf7jhY"},"source":["Make a zip file of your results"]},{"cell_type":"code","metadata":{"id":"GrkFxYPH59rl","colab":{"base_uri":"https://localhost:8080/","height":136},"outputId":"7e623133-0579-45fe-cf87-e7bb771009c0"},"source":["from google.colab import files\n","\n","!zip -r results.zip /content/ESRGAN/results"],"execution_count":null,"outputs":[{"output_type":"stream","text":[" adding: content/ESRGAN/results/ (stored 0%)\n"," adding: content/ESRGAN/results/comic_rlt.png (deflated 0%)\n"," adding: content/ESRGAN/results/.ipynb_checkpoints/ (stored 0%)\n"," adding: content/ESRGAN/results/k2.png (deflated 1%)\n"," adding: content/ESRGAN/results/baboon.png (deflated 0%)\n"," adding: content/ESRGAN/results/baboon_rlt.png (deflated 0%)\n"," adding: content/ESRGAN/results/comic.png (deflated 0%)\n"],"name":"stdout"}]},{"cell_type":"markdown","metadata":{"id":"Wu7WBi2E7w_O"},"source":["Download Zip file"]},{"cell_type":"code","metadata":{"id":"Sz6lLjTV6ZaR","colab":{"base_uri":"https://localhost:8080/","height":17},"outputId":"7718de2c-3879-408e-fdbd-017bf8dff080"},"source":["files.download('results.zip')"],"execution_count":null,"outputs":[{"output_type":"display_data","data":{"application/javascript":["\n"," async function download(id, filename, size) {\n"," if (!google.colab.kernel.accessAllowed) {\n"," return;\n"," }\n"," const div = document.createElement('div');\n"," const label = document.createElement('label');\n"," label.textContent = `Downloading \"${filename}\": `;\n"," div.appendChild(label);\n"," const progress = document.createElement('progress');\n"," progress.max = size;\n"," div.appendChild(progress);\n"," document.body.appendChild(div);\n","\n"," const buffers = [];\n"," let downloaded = 0;\n","\n"," const channel = await google.colab.kernel.comms.open(id);\n"," // Send a message to notify the kernel that we're ready.\n"," channel.send({})\n","\n"," for await (const message of channel.messages) {\n"," // Send a message to notify the kernel that we're ready.\n"," channel.send({})\n"," if (message.buffers) {\n"," for (const buffer of message.buffers) {\n"," buffers.push(buffer);\n"," downloaded += buffer.byteLength;\n"," progress.value = downloaded;\n"," }\n"," }\n"," }\n"," const blob = new Blob(buffers, {type: 'application/binary'});\n"," const a = document.createElement('a');\n"," a.href = window.URL.createObjectURL(blob);\n"," a.download = filename;\n"," div.appendChild(a);\n"," a.click();\n"," div.remove();\n"," }\n"," "],"text/plain":[""]},"metadata":{"tags":[]}},{"output_type":"display_data","data":{"application/javascript":["download(\"download_ef5ac29a-a832-45b7-a959-ac91a9917775\", \"results.zip\", 12103728)"],"text/plain":[""]},"metadata":{"tags":[]}}]},{"cell_type":"code","metadata":{"id":"7OqbcvpuOeaz"},"source":["import shutil\n","\n","#move zip file to google drive\n","shutil.move(\"./results.zip\", \"/content/gdrive/My Drive/results.zip\")"],"execution_count":null,"outputs":[]}]}