Update Prompt_Engineering_for_ImageNet.ipynb

Fix bug caused by changing default to jit=False with handling the case jit=True as well
This commit is contained in:
or-toledano 2021-08-08 22:10:06 +03:00 committed by Jong Wook Kim
parent 6599907d3e
commit 991ca4a48f
1 changed files with 1180 additions and 1174 deletions

View File

@ -573,22 +573,22 @@
"text": [
"Looking in links: https://download.pytorch.org/whl/torch_stable.html\n",
"Collecting torch==1.7.1+cu101\n",
"\u001b[?25l Downloading https://download.pytorch.org/whl/cu101/torch-1.7.1%2Bcu101-cp36-cp36m-linux_x86_64.whl (735.4MB)\n",
"\u001b[K |████████████████████████████████| 735.4MB 25kB/s \n",
"\u001b[?25hCollecting torchvision==0.8.2+cu101\n",
"\u001b[?25l Downloading https://download.pytorch.org/whl/cu101/torchvision-0.8.2%2Bcu101-cp36-cp36m-linux_x86_64.whl (12.8MB)\n",
"\u001b[K |████████████████████████████████| 12.8MB 248kB/s \n",
"\u001b[?25hCollecting ftfy\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/ff/e2/3b51c53dffb1e52d9210ebc01f1fb9f2f6eba9b3201fa971fd3946643c71/ftfy-5.8.tar.gz (64kB)\n",
"\u001b[K |████████████████████████████████| 71kB 5.6MB/s \n",
"\u001b[?25hRequirement already satisfied: regex in /usr/local/lib/python3.6/dist-packages (2019.12.20)\n",
"\u001B[?25l Downloading https://download.pytorch.org/whl/cu101/torch-1.7.1%2Bcu101-cp36-cp36m-linux_x86_64.whl (735.4MB)\n",
"\u001B[K |████████████████████████████████| 735.4MB 25kB/s \n",
"\u001B[?25hCollecting torchvision==0.8.2+cu101\n",
"\u001B[?25l Downloading https://download.pytorch.org/whl/cu101/torchvision-0.8.2%2Bcu101-cp36-cp36m-linux_x86_64.whl (12.8MB)\n",
"\u001B[K |████████████████████████████████| 12.8MB 248kB/s \n",
"\u001B[?25hCollecting ftfy\n",
"\u001B[?25l Downloading https://files.pythonhosted.org/packages/ff/e2/3b51c53dffb1e52d9210ebc01f1fb9f2f6eba9b3201fa971fd3946643c71/ftfy-5.8.tar.gz (64kB)\n",
"\u001B[K |████████████████████████████████| 71kB 5.6MB/s \n",
"\u001B[?25hRequirement already satisfied: regex in /usr/local/lib/python3.6/dist-packages (2019.12.20)\n",
"Requirement already satisfied: typing-extensions in /usr/local/lib/python3.6/dist-packages (from torch==1.7.1+cu101) (3.7.4.3)\n",
"Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from torch==1.7.1+cu101) (1.19.5)\n",
"Requirement already satisfied: dataclasses; python_version < \"3.7\" in /usr/local/lib/python3.6/dist-packages (from torch==1.7.1+cu101) (0.8)\n",
"Requirement already satisfied: pillow>=4.1.1 in /usr/local/lib/python3.6/dist-packages (from torchvision==0.8.2+cu101) (7.0.0)\n",
"Requirement already satisfied: wcwidth in /usr/local/lib/python3.6/dist-packages (from ftfy) (0.2.5)\n",
"Building wheels for collected packages: ftfy\n",
" Building wheel for ftfy (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Building wheel for ftfy (setup.py) ... \u001B[?25l\u001B[?25hdone\n",
" Created wheel for ftfy: filename=ftfy-5.8-cp36-none-any.whl size=45613 sha256=73a94b51b7fe03350783d5b9dd638801a904c618d3b0dc7237ce77f401f33404\n",
" Stored in directory: /root/.cache/pip/wheels/ba/c0/ef/f28c4da5ac84a4e06ac256ca9182fc34fa57fefffdbc68425b\n",
"Successfully built ftfy\n",
@ -645,7 +645,7 @@
"Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from torch~=1.7.1->clip==1.0) (1.19.5)\n",
"Requirement already satisfied: pillow>=4.1.1 in /usr/local/lib/python3.6/dist-packages (from torchvision~=0.8.2->clip==1.0) (7.0.0)\n",
"Building wheels for collected packages: clip\n",
" Building wheel for clip (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Building wheel for clip (setup.py) ... \u001B[?25l\u001B[?25hdone\n",
" Created wheel for clip: filename=clip-1.0-cp36-none-any.whl size=1367993 sha256=1839a2f0b015f75579b578ebfa15bcbe8ebab1ff535127c9357c5b26f8473de3\n",
" Stored in directory: /tmp/pip-ephem-wheel-cache-jwymwzm4/wheels/79/51/d7/69f91d37121befe21d9c52332e04f592e17d1cabc7319b3e09\n",
"Successfully built clip\n",
@ -733,7 +733,8 @@
"outputId": "58e644d4-6e23-43b5-964e-1e9e8540d22e"
},
"source": [
"model, preprocess = clip.load(\"ViT-B/32\")"
"jit = True\n",
"model, preprocess = clip.load(\"ViT-B/32\", jit=jit)"
],
"execution_count": 6,
"outputs": [
@ -756,9 +757,14 @@
"outputId": "58641dc2-919d-40ae-b71a-7b7b47830f77"
},
"source": [
"if jit:\n",
" input_resolution = model.input_resolution.item()\n",
" context_length = model.context_length.item()\n",
" vocab_size = model.vocab_size.item()\n",
"else:\n",
" input_resolution = model.visual.input_resolution\n",
" context_length = model.context_length\n",
" vocab_size = model.vocab_size\n",
"\n",
"print(\"Model parameters:\", f\"{np.sum([int(np.prod(p.shape)) for p in model.parameters()]):,}\")\n",
"print(\"Input resolution:\", input_resolution)\n",
@ -988,7 +994,7 @@
" Cloning https://github.com/modestyachts/ImageNetV2_pytorch to /tmp/pip-req-build-2fnslbyv\n",
" Running command git clone -q https://github.com/modestyachts/ImageNetV2_pytorch /tmp/pip-req-build-2fnslbyv\n",
"Building wheels for collected packages: imagenetv2-pytorch\n",
" Building wheel for imagenetv2-pytorch (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Building wheel for imagenetv2-pytorch (setup.py) ... \u001B[?25l\u001B[?25hdone\n",
" Created wheel for imagenetv2-pytorch: filename=imagenetv2_pytorch-0.1-cp36-none-any.whl size=2665 sha256=0978fc64026ab86ace52a9f3ebcef53331c43288433173c450a4b5ddcc197f31\n",
" Stored in directory: /tmp/pip-ephem-wheel-cache-4eewuaap/wheels/f7/09/0d/03ded955ce95b04c9590b999ae9be076bb5d8f389650aa2147\n",
"Successfully built imagenetv2-pytorch\n",