From bcd2f5e66e72a37904585d642036d2c55b64d2f7 Mon Sep 17 00:00:00 2001 From: Yoink3000 Date: Sat, 29 Jun 2024 10:21:56 +0800 Subject: [PATCH] update download cell and setup script --- assets/build/setup.sh | 4 ++-- assets/workspace/SD Next.ipynb | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/assets/build/setup.sh b/assets/build/setup.sh index e341338..bfa3fb8 100644 --- a/assets/build/setup.sh +++ b/assets/build/setup.sh @@ -15,5 +15,5 @@ apt install -y git \ curl \ wget > /dev/null -echo Installing Jupyter Lab... -pip install jupyterlab "huggingface_hub[hf_transfer]" > /dev/null \ No newline at end of file +echo Installing necessary python packages... +pip install jupyterlab "huggingface_hub[hf_transfer]" humanize > /dev/null \ No newline at end of file diff --git a/assets/workspace/SD Next.ipynb b/assets/workspace/SD Next.ipynb index cae58ab..1e55230 100644 --- a/assets/workspace/SD Next.ipynb +++ b/assets/workspace/SD Next.ipynb @@ -76,12 +76,22 @@ "from urllib.parse import urlsplit\n", "import requests\n", "from huggingface_hub import hf_hub_download\n", + "import humanize\n", + "import time\n", "\n", "for dl in HUGGINGFACE_LIST:\n", " repo, filePath = dl[:2]\n", " dest = f'{dl[2] if len(dl) == 3 else \"./\"}'\n", - " print(f'\\n\\nDownloading \"{os.path.basename(filePath)}\" from \"{repo}\" to {os.path.join(dest, filePath)}...')\n", + " resultPath = os.path.join(dest, filePath)\n", + " print(f'\\n\\nDownloading \"{os.path.basename(filePath)}\" from \"{repo}\" to {resultPath}...')\n", + " start = time.time()\n", " hf_hub_download(repo_id=repo, filename=filePath, local_dir=dest)\n", + " end = time.time()\n", + " timeUsed = end - start\n", + " fileSize = os.path.getsize(resultPath)\n", + " avgSpeed = humanize.naturalsize(fileSize/timeUsed, binary=True)\n", + " fileSize = humanize.naturalsize(fileSize, binary=True)\n", + " print(f'Download completed\\n- Time used: {timeUsed}s\\n- File size: {fileSize}\\n- Average speed: {avgSpeed}/s')\n", "\n", "for dl in DOWNLOAD_LIST:\n", " baseLink = dl[0]\n",