mirror of
https://github.com/mrdbourke/pytorch-deep-learning.git
synced 2026-11-27 06:07:09 +00:00
add annotations and launch steps for 09
This commit is contained in:
1 parent
88305d9430
commit
8da2100ea8
1 file changed
+188
-115
+188
-115
@@ -600,7 +600,7 @@
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "a8599b28ff2d4718a9db23ab3f9d5cd8",
|
||||
"model_id": "17fc73b62c534fea8e718ce8451fd278",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
@@ -1085,7 +1085,7 @@
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "46327bc73c3e4dd3869582bd6ea45208",
|
||||
"model_id": "a95edc1f03484c5c844ce3a8fb05f81a",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
@@ -1534,7 +1534,7 @@
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "df735c5321ec4b13863b1844dcdf7fc1",
|
||||
"model_id": "43ebdbf2e5b4495890fa49e9f043490f",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
@@ -1576,13 +1576,13 @@
|
||||
" 'class_name': 'steak',\n",
|
||||
" 'pred_prob': 0.9293,\n",
|
||||
" 'pred_class': 'steak',\n",
|
||||
" 'time_for_pred': 0.0574,\n",
|
||||
" 'time_for_pred': 0.0575,\n",
|
||||
" 'correct': True},\n",
|
||||
" {'image_path': PosixPath('data/pizza_steak_sushi_20_percent/test/steak/3100563.jpg'),\n",
|
||||
" 'class_name': 'steak',\n",
|
||||
" 'pred_prob': 0.9534,\n",
|
||||
" 'pred_class': 'steak',\n",
|
||||
" 'time_for_pred': 0.0326,\n",
|
||||
" 'time_for_pred': 0.0381,\n",
|
||||
" 'correct': True}]"
|
||||
]
|
||||
},
|
||||
@@ -1650,7 +1650,7 @@
|
||||
" <td>steak</td>\n",
|
||||
" <td>0.9293</td>\n",
|
||||
" <td>steak</td>\n",
|
||||
" <td>0.0574</td>\n",
|
||||
" <td>0.0575</td>\n",
|
||||
" <td>True</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
@@ -1659,7 +1659,7 @@
|
||||
" <td>steak</td>\n",
|
||||
" <td>0.9534</td>\n",
|
||||
" <td>steak</td>\n",
|
||||
" <td>0.0326</td>\n",
|
||||
" <td>0.0381</td>\n",
|
||||
" <td>True</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
@@ -1668,7 +1668,7 @@
|
||||
" <td>steak</td>\n",
|
||||
" <td>0.7531</td>\n",
|
||||
" <td>steak</td>\n",
|
||||
" <td>0.0313</td>\n",
|
||||
" <td>0.0370</td>\n",
|
||||
" <td>True</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
@@ -1677,7 +1677,7 @@
|
||||
" <td>steak</td>\n",
|
||||
" <td>0.5935</td>\n",
|
||||
" <td>steak</td>\n",
|
||||
" <td>0.0320</td>\n",
|
||||
" <td>0.0311</td>\n",
|
||||
" <td>True</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
@@ -1686,7 +1686,7 @@
|
||||
" <td>steak</td>\n",
|
||||
" <td>0.8959</td>\n",
|
||||
" <td>steak</td>\n",
|
||||
" <td>0.0328</td>\n",
|
||||
" <td>0.0317</td>\n",
|
||||
" <td>True</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
@@ -1702,11 +1702,11 @@
|
||||
"4 data/pizza_steak_sushi_20_percent/test/steak/7... steak 0.8959 \n",
|
||||
"\n",
|
||||
" pred_class time_for_pred correct \n",
|
||||
"0 steak 0.0574 True \n",
|
||||
"1 steak 0.0326 True \n",
|
||||
"2 steak 0.0313 True \n",
|
||||
"3 steak 0.0320 True \n",
|
||||
"4 steak 0.0328 True "
|
||||
"0 steak 0.0575 True \n",
|
||||
"1 steak 0.0381 True \n",
|
||||
"2 steak 0.0370 True \n",
|
||||
"3 steak 0.0311 True \n",
|
||||
"4 steak 0.0317 True "
|
||||
]
|
||||
},
|
||||
"execution_count": 34,
|
||||
@@ -1773,7 +1773,7 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"EffNetB2 average time per prediction: 0.0298 seconds\n"
|
||||
"EffNetB2 average time per prediction: 0.0311 seconds\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -1806,7 +1806,7 @@
|
||||
" 'test_acc': 0.96875,\n",
|
||||
" 'number_of_parameters': 7705221,\n",
|
||||
" 'model_size (MB)': 29,\n",
|
||||
" 'time_per_pred_cpu': 0.0298}"
|
||||
" 'time_per_pred_cpu': 0.0311}"
|
||||
]
|
||||
},
|
||||
"execution_count": 37,
|
||||
@@ -1841,7 +1841,7 @@
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "4c86bf70c6c243448cdd2b5c6a4d61bd",
|
||||
"model_id": "8ee5506748b7417cab5ac1fc4d465d6c",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
@@ -1883,13 +1883,13 @@
|
||||
" 'class_name': 'steak',\n",
|
||||
" 'pred_prob': 0.9933,\n",
|
||||
" 'pred_class': 'steak',\n",
|
||||
" 'time_for_pred': 0.1304,\n",
|
||||
" 'time_for_pred': 0.1643,\n",
|
||||
" 'correct': True},\n",
|
||||
" {'image_path': PosixPath('data/pizza_steak_sushi_20_percent/test/steak/3100563.jpg'),\n",
|
||||
" 'class_name': 'steak',\n",
|
||||
" 'pred_prob': 0.9893,\n",
|
||||
" 'pred_class': 'steak',\n",
|
||||
" 'time_for_pred': 0.0654,\n",
|
||||
" 'time_for_pred': 0.099,\n",
|
||||
" 'correct': True}]"
|
||||
]
|
||||
},
|
||||
@@ -1953,7 +1953,7 @@
|
||||
" <td>steak</td>\n",
|
||||
" <td>0.9933</td>\n",
|
||||
" <td>steak</td>\n",
|
||||
" <td>0.1304</td>\n",
|
||||
" <td>0.1643</td>\n",
|
||||
" <td>True</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
@@ -1962,7 +1962,7 @@
|
||||
" <td>steak</td>\n",
|
||||
" <td>0.9893</td>\n",
|
||||
" <td>steak</td>\n",
|
||||
" <td>0.0654</td>\n",
|
||||
" <td>0.0990</td>\n",
|
||||
" <td>True</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
@@ -1971,7 +1971,7 @@
|
||||
" <td>steak</td>\n",
|
||||
" <td>0.9971</td>\n",
|
||||
" <td>steak</td>\n",
|
||||
" <td>0.0642</td>\n",
|
||||
" <td>0.0637</td>\n",
|
||||
" <td>True</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
@@ -1980,7 +1980,7 @@
|
||||
" <td>steak</td>\n",
|
||||
" <td>0.7685</td>\n",
|
||||
" <td>steak</td>\n",
|
||||
" <td>0.0649</td>\n",
|
||||
" <td>0.0645</td>\n",
|
||||
" <td>True</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
@@ -1989,7 +1989,7 @@
|
||||
" <td>steak</td>\n",
|
||||
" <td>0.9499</td>\n",
|
||||
" <td>steak</td>\n",
|
||||
" <td>0.0658</td>\n",
|
||||
" <td>0.0649</td>\n",
|
||||
" <td>True</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
@@ -2005,11 +2005,11 @@
|
||||
"4 data/pizza_steak_sushi_20_percent/test/steak/7... steak 0.9499 \n",
|
||||
"\n",
|
||||
" pred_class time_for_pred correct \n",
|
||||
"0 steak 0.1304 True \n",
|
||||
"1 steak 0.0654 True \n",
|
||||
"2 steak 0.0642 True \n",
|
||||
"3 steak 0.0649 True \n",
|
||||
"4 steak 0.0658 True "
|
||||
"0 steak 0.1643 True \n",
|
||||
"1 steak 0.0990 True \n",
|
||||
"2 steak 0.0637 True \n",
|
||||
"3 steak 0.0645 True \n",
|
||||
"4 steak 0.0649 True "
|
||||
]
|
||||
},
|
||||
"execution_count": 40,
|
||||
@@ -2076,7 +2076,7 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ViT average time per prediction: 0.0679 seconds\n"
|
||||
"ViT average time per prediction: 0.0661 seconds\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -2109,7 +2109,7 @@
|
||||
" 'test_acc': 0.984659090909091,\n",
|
||||
" 'number_of_parameters': 85800963,\n",
|
||||
" 'model_size (MB)': 327,\n",
|
||||
" 'time_per_pred_cpu': 0.0679}"
|
||||
" 'time_per_pred_cpu': 0.0661}"
|
||||
]
|
||||
},
|
||||
"execution_count": 43,
|
||||
@@ -2179,7 +2179,7 @@
|
||||
" <td>96.88</td>\n",
|
||||
" <td>7705221</td>\n",
|
||||
" <td>29</td>\n",
|
||||
" <td>0.0298</td>\n",
|
||||
" <td>0.0311</td>\n",
|
||||
" <td>EffNetB2</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
@@ -2188,7 +2188,7 @@
|
||||
" <td>98.47</td>\n",
|
||||
" <td>85800963</td>\n",
|
||||
" <td>327</td>\n",
|
||||
" <td>0.0679</td>\n",
|
||||
" <td>0.0661</td>\n",
|
||||
" <td>ViT</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
@@ -2201,8 +2201,8 @@
|
||||
"1 0.064182 98.47 85800963 327 \n",
|
||||
"\n",
|
||||
" time_per_pred_cpu model \n",
|
||||
"0 0.0298 EffNetB2 \n",
|
||||
"1 0.0679 ViT "
|
||||
"0 0.0311 EffNetB2 \n",
|
||||
"1 0.0661 ViT "
|
||||
]
|
||||
},
|
||||
"execution_count": 44,
|
||||
@@ -2276,7 +2276,7 @@
|
||||
" <td>1.016412</td>\n",
|
||||
" <td>11.135432</td>\n",
|
||||
" <td>11.275862</td>\n",
|
||||
" <td>2.278523</td>\n",
|
||||
" <td>2.125402</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
@@ -2287,7 +2287,7 @@
|
||||
"ViT to EffNetB2 ratios 0.228173 1.016412 11.135432 \n",
|
||||
"\n",
|
||||
" model_size (MB) time_per_pred_cpu \n",
|
||||
"ViT to EffNetB2 ratios 11.275862 2.278523 "
|
||||
"ViT to EffNetB2 ratios 11.275862 2.125402 "
|
||||
]
|
||||
},
|
||||
"execution_count": 45,
|
||||
@@ -2343,7 +2343,7 @@
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAt8AAAH7CAYAAAAU3/N5AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAABa50lEQVR4nO3deZgcVdmw8fvJRkKGsDPshH1fQiKvC0tCWAUhgCLILgrCp6+o4AKIEREX8MUFFVAQApGAICAgBlnCrpJgQCSABBIIS9gjk4SQ5Xx/VE3odHpmeqZ7ajLD/buuvma66tSpU6erZ54+/dSpSCkhSZIkqfP16uoGSJIkSR8UBt+SJElSQQy+JUmSpIIYfEuSJEkFMfiWJEmSCmLwLUmSJBXE4Fuqs4gYHhEpIo7tijoiYkJETOvovpcF+bFfXsP2o/M6BtevVa3ub/mI+HlEPB8RC7t7/6ttPeF9Vg8RsUNE3BkRb+XvudFd3SZpWWfwrW6rJEBt6fHhrm4jQET8IW/PDq2UiYh4LiLejogBBTavU5QEvykiPtlCmYNKyowuuIml7bg8b8NqNVTzDeBLwDXAscApdWhajxMRG0XEJRHxZETMyQO2JyLiiogY0dXt685a+HvYFBGTIuLLEdG7E/bZB7ge2BT4NnAU8Md670fqafp0dQOkOrga+HOF5c8U3ZAWXAp8EjgO+HILZUYAg4GLU0pzI+JeYAAwvwP72wuIDmzXGd4lO+7rKqz7bL6+f4V1A4CFNez3HO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mlI6rcV2uDEc3tTsD+tHyOlH9Qr3RetqYjf4ut7aOldlb7fvB7sm+PLiX7huRNsnStj5O9LpWyAFbovx+t3Ay+Ve+m5j+3rbBum/zns50ou3WFspWWNbuM7CKwE8i+9lwH+EGq8gLGlE29dUP+ICJOIfva9URaviCrPcdVEymlJyPiYbJUjIdSSk/Vcn8riP/kP2e38yv7cs+Q/YPv1cl6KnmKbMrHHYB/tFLuP2Tzcf8tdfH0bymlFBF/Jwu+1y9bvU15+YhYlyxtpfmcfY3sG6V+VfbPf8hGy+9O+QWbrZhKdoFgv9LR74hYhWx0t9LI7jJSSo9FxGPA0RHxHbIg/G2yNI/ysi8DvyW7GLo7+YV6EfGTPPWhs/5D9po/n1Ja5puFLjIV2C8i1qjwTc42ZCk7baXZdYmIWIMs8L4qpfTFsnUf62T1y/3vRysnc75V7x4lu4jqhMjmlgaWzGLQfAHhzR0oO5FsxPqE0plWIps2cKk3+FIppUfJRkE/DXwpr/N31RxIhRldmtsMWSDfkvYcVy19iywf9dsF7GtFMI7sa/VvRcQyr09E9ImyKdEqSSm9QZYjfmhUuGtrZNbLine truncated
|
||||
"text/plain": [
|
||||
"<Figure size 864x576 with 1 Axes>"
|
||||
]
|
||||
@@ -2635,11 +2635,11 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[INFO] Predicting on image at path: data/pizza_steak_sushi_20_percent/test/steak/1972463.jpg\n",
|
||||
"[INFO] Predicting on image at path: data/pizza_steak_sushi_20_percent/test/sushi/2378406.jpg\n",
|
||||
"\n",
|
||||
"Prediction label and probability dictionary: \n",
|
||||
"{'pizza': 0.05136595293879509, 'steak': 0.6942882537841797, 'sushi': 0.25434577465057373}\n",
|
||||
"Prediction time: 0.02819 seconds\n"
|
||||
"{'pizza': 0.0847441777586937, 'steak': 0.39468735456466675, 'sushi': 0.5205684900283813}\n",
|
||||
"Prediction time: 0.02805 seconds\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -2701,9 +2701,9 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"[['data/pizza_steak_sushi_20_percent/test/pizza/3785667.jpg'],\n",
|
||||
" ['data/pizza_steak_sushi_20_percent/test/sushi/2416569.jpg'],\n",
|
||||
" ['data/pizza_steak_sushi_20_percent/test/steak/2307638.jpg']]"
|
||||
"[['data/pizza_steak_sushi_20_percent/test/sushi/128616.jpg'],\n",
|
||||
" ['data/pizza_steak_sushi_20_percent/test/pizza/833711.jpg'],\n",
|
||||
" ['data/pizza_steak_sushi_20_percent/test/pizza/1032754.jpg']]"
|
||||
]
|
||||
},
|
||||
"execution_count": 51,
|
||||
@@ -2765,7 +2765,7 @@
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Running on local URL: http://127.0.0.1:7860/\n",
|
||||
"Running on public URL: https://47231.gradio.app\n",
|
||||
"Running on public URL: https://40175.gradio.app\n",
|
||||
"\n",
|
||||
"This share link expires in 72 hours. For free permanent hosting, check out Spaces: https://huggingface.co/spaces\n"
|
||||
]
|
||||
@@ -2773,7 +2773,7 @@
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div><iframe src=\"https://47231.gradio.app\" width=\"900\" height=\"500\" allow=\"autoplay; camera; microphone;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
||||
"<div><iframe src=\"https://40175.gradio.app\" width=\"900\" height=\"500\" allow=\"autoplay; camera; microphone;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.HTML object>"
|
||||
@@ -2785,9 +2785,9 @@
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"(<gradio.routes.App at 0x7f52617071c0>,\n",
|
||||
"(<gradio.routes.App at 0x7f05f1a94610>,\n",
|
||||
" 'http://127.0.0.1:7860/',\n",
|
||||
" 'https://47231.gradio.app')"
|
||||
" 'https://40175.gradio.app')"
|
||||
]
|
||||
},
|
||||
"execution_count": 52,
|
||||
@@ -3506,26 +3506,25 @@
|
||||
"9. Copy/move the contents of the downloaded `foodvision_mini` folder to the cloned repo folder.\n",
|
||||
"10. To upload and track larger files (e.g. files over 10MB or in our case, our PyTorch model file) you'll need to [install Git LFS](https://git-lfs.github.com/) (which stands for \"git large file storage\").\n",
|
||||
"11. After you've installed Git LFS, you can activate it by running `git lfs install`.\n",
|
||||
"12. In the `foodvision_mini`, track the files over 10MB with Git LFS with `git lfs track \"*.file_extension\"`.\n",
|
||||
" * To track our EffNetB2 PyTorch model you can run `git lfs track \"09_pretrained_effnetb2_feature_extractor_pizza_steak_sushi_20_percent.pth\"`.\n",
|
||||
"13. Track `.gitattributes` (automatically created when cloning from HuggingFace) using `git add .gitattributes` (this file will help ensure our larger files are tracked with Git LFS).\n",
|
||||
" * You can see an example `.gitattributes` file at https://huggingface.co/spaces/mrdbourke/foodvision_mini/blob/main/.gitattributes \n",
|
||||
"12. In the `foodvision_mini` directory, track the files over 10MB with Git LFS with `git lfs track \"*.file_extension\"`.\n",
|
||||
" * Track EffNetB2 PyTorch model file with `git lfs track \"09_pretrained_effnetb2_feature_extractor_pizza_steak_sushi_20_percent.pth\"`.\n",
|
||||
"13. Track `.gitattributes` (automatically created when cloning from HuggingFace, this file will help ensure our larger files are tracked with Git LFS). You can see an example `.gitattributes` file on the [FoodVision Mini Hugging Face Space](https://huggingface.co/spaces/mrdbourke/foodvision_mini/blob/main/.gitattributes).\n",
|
||||
" * `git add .gitattributes`\n",
|
||||
"14. Add the rest of the `foodvision_mini` app files and commit them with: \n",
|
||||
" * `git add *`.\n",
|
||||
" * `git commit -m \"first commit\"`.\n",
|
||||
" * `git add *`\n",
|
||||
" * `git commit -m \"first commit\"`\n",
|
||||
"15. Push (upload) the files to Hugging Face:\n",
|
||||
" * `git push`.\n",
|
||||
" * `git push`\n",
|
||||
"16. Wait 3-5 minutes for the build to happen (future builds are faster) and your app to become live!\n",
|
||||
"\n",
|
||||
"If everything worked, you should see a live running example of our FoodVision Mini Gradio demo like the one here: https://huggingface.co/spaces/mrdbourke/foodvision_mini \n",
|
||||
"\n",
|
||||
"* TK image - gif of the above workflow from Google Colab -> Hugging Face Space\n",
|
||||
"* TK explain embedding as iFrame - https://gradio.app/sharing_your_app/"
|
||||
"And we can even embed our FoodVision Mini Gradio demo into our notebook as an [iframe](https://gradio.app/sharing_your_app/#embedding-with-iframes) with [`IPython.display.IFrame`](https://ipython.readthedocs.io/en/stable/api/generated/IPython.display.html#IPython.display.IFrame) and a link to our space in the format `https://hf.space/embed/[YOUR_USERNAME]/[YOUR_SPACE_NAME]/+`."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 95,
|
||||
"execution_count": 62,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -3543,17 +3542,19 @@
|
||||
" "
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.lib.display.IFrame at 0x7f51d44cac40>"
|
||||
"<IPython.lib.display.IFrame at 0x7f05f1af82e0>"
|
||||
]
|
||||
},
|
||||
"execution_count": 95,
|
||||
"execution_count": 62,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# IPython is a library to help make Python interactive\n",
|
||||
"from IPython.display import IFrame\n",
|
||||
"\n",
|
||||
"# Embed FoodVision Mini Gradio demo\n",
|
||||
"IFrame(src=\"https://hf.space/embed/mrdbourke/foodvision_mini/+\", width=900, height=750)"
|
||||
]
|
||||
},
|
||||
@@ -3601,7 +3602,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 62,
|
||||
"execution_count": 63,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -3620,7 +3621,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 63,
|
||||
"execution_count": 64,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -3686,7 +3687,7 @@
|
||||
"============================================================================================================================================"
|
||||
]
|
||||
},
|
||||
"execution_count": 63,
|
||||
"execution_count": 64,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -3720,7 +3721,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 64,
|
||||
"execution_count": 65,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -3742,7 +3743,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 65,
|
||||
"execution_count": 66,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -3798,7 +3799,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 66,
|
||||
"execution_count": 67,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -3832,7 +3833,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 67,
|
||||
"execution_count": 68,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -3850,7 +3851,7 @@
|
||||
" 'breakfast_burrito']"
|
||||
]
|
||||
},
|
||||
"execution_count": 67,
|
||||
"execution_count": 68,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -3918,7 +3919,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 68,
|
||||
"execution_count": 69,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -3949,7 +3950,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 69,
|
||||
"execution_count": 70,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -3966,7 +3967,7 @@
|
||||
"(15150, 5050)"
|
||||
]
|
||||
},
|
||||
"execution_count": 69,
|
||||
"execution_count": 70,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -3998,7 +3999,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 70,
|
||||
"execution_count": 71,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -4062,13 +4063,13 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 71,
|
||||
"execution_count": 72,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "16b0907b60e145d6a824e79654e86ccd",
|
||||
"model_id": "d3bcf7fef2d8423fbce24dd1096a1ab6",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
@@ -4136,7 +4137,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 72,
|
||||
"execution_count": 73,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -4179,7 +4180,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 73,
|
||||
"execution_count": 74,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -4215,7 +4216,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 74,
|
||||
"execution_count": 75,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -4224,7 +4225,7 @@
|
||||
"<All keys matched successfully>"
|
||||
]
|
||||
},
|
||||
"execution_count": 74,
|
||||
"execution_count": 75,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -4252,7 +4253,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 75,
|
||||
"execution_count": 76,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -4328,7 +4329,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 76,
|
||||
"execution_count": 77,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -4366,16 +4367,16 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"--2022-08-19 15:25:11-- https://raw.githubusercontent.com/mrdbourke/pytorch-deep-learning/main/images/04-pizza-dad.jpeg\n",
|
||||
"Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.108.133, 185.199.111.133, 185.199.110.133, ...\n",
|
||||
"--2022-08-19 17:58:23-- https://raw.githubusercontent.com/mrdbourke/pytorch-deep-learning/main/images/04-pizza-dad.jpeg\n",
|
||||
"Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.108.133, 185.199.110.133, 185.199.109.133, ...\n",
|
||||
"Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.108.133|:443... connected.\n",
|
||||
"HTTP request sent, awaiting response... 200 OK\n",
|
||||
"Length: 2874848 (2.7M) [image/jpeg]\n",
|
||||
"Saving to: '04-pizza-dad.jpeg’\n",
|
||||
"\n",
|
||||
"04-pizza-dad.jpeg 100%[===================>] 2.74M 7.98MB/s in 0.3s \n",
|
||||
"04-pizza-dad.jpeg 100%[===================>] 2.74M 7.15MB/s in 0.4s \n",
|
||||
"\n",
|
||||
"2022-08-19 15:25:11 (7.98 MB/s) - '04-pizza-dad.jpeg’ saved [2874848/2874848]\n",
|
||||
"2022-08-19 17:58:25 (7.15 MB/s) - '04-pizza-dad.jpeg’ saved [2874848/2874848]\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
@@ -4383,7 +4384,7 @@
|
||||
"source": [
|
||||
"# Download and move an example image\n",
|
||||
"!wget https://raw.githubusercontent.com/mrdbourke/pytorch-deep-learning/main/images/04-pizza-dad.jpeg \n",
|
||||
"!mv 04-pizza-dad.jpeg demos/foodvision_big/examples\n",
|
||||
"!mv 04-pizza-dad.jpeg demos/foodvision_big/examples/04-pizza-dad.jpg\n",
|
||||
"\n",
|
||||
"# Move trained model to FoodVision Big demo folder (will error if model is already moved)\n",
|
||||
"!mv models/09_pretrained_effnetb2_feature_extractor_food101_20_percent.pth demos/foodvision_big"
|
||||
@@ -4402,7 +4403,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 77,
|
||||
"execution_count": 79,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -4420,7 +4421,7 @@
|
||||
" 'breakfast_burrito']"
|
||||
]
|
||||
},
|
||||
"execution_count": 77,
|
||||
"execution_count": 79,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -4450,7 +4451,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 83,
|
||||
"execution_count": 80,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -4484,7 +4485,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 84,
|
||||
"execution_count": 81,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -4493,7 +4494,7 @@
|
||||
"['apple_pie', 'baby_back_ribs', 'baklava', 'beef_carpaccio', 'beef_tartare']"
|
||||
]
|
||||
},
|
||||
"execution_count": 84,
|
||||
"execution_count": 81,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -4518,7 +4519,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 86,
|
||||
"execution_count": 82,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -4575,13 +4576,21 @@
|
||||
"source": [
|
||||
"### TK - Turning our FoodVision Big Gradio app into a Python script (`app.py`)\n",
|
||||
"\n",
|
||||
"TK - This file is largely the same as FoodVision Mini but differs for the: model, class names, display text\n",
|
||||
"* next: format to look nice"
|
||||
"We've got a FoodVision Big `model.py` script, now let's create a FoodVision Big `app.py` script.\n",
|
||||
"\n",
|
||||
"This will again mostly be the same as the FoodVision Mini `app.py` script except we'll change:\n",
|
||||
"\n",
|
||||
"1. **Imports and class names setup** - The `class_names` variable will be a list for all of the Food101 classes rather than pizza, steak, sushi. We can access these via `demos/foodvision_big/class_names.txt`.\n",
|
||||
"2. **Model and transforms preparation** - The `model` will have `num_classes=101` rather than `num_classes=3`. We'll also be sure to load the weights from `\"09_pretrained_effnetb2_feature_extractor_food101_20_percent.pth\"` (our FoodVision Big model path).\n",
|
||||
"3. **Predict function** - This will stay the same as FoodVision Mini's `app.py`.\n",
|
||||
"4. **Gradio app** - The Gradio interace will have different `title`, `description` and `article` parameters to reflect the details of FoodVision Big.\n",
|
||||
"\n",
|
||||
"We'll also make sure to save it to `demos/foodvision_big/app.py` using the `%%writefile` magic command."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 72,
|
||||
"execution_count": 83,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -4610,12 +4619,12 @@
|
||||
"### 2. Model and transforms preparation ### \n",
|
||||
"\n",
|
||||
"# Create model\n",
|
||||
"model, transforms = create_effnetb2_model(\n",
|
||||
"effnetb2, effnetb2_transforms = create_effnetb2_model(\n",
|
||||
" num_classes=101, # could also use len(class_names)\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"# Load saved weights\n",
|
||||
"model.load_state_dict(\n",
|
||||
"effnetb2.load_state_dict(\n",
|
||||
" torch.load(\n",
|
||||
" f=\"09_pretrained_effnetb2_feature_extractor_food101_20_percent.pth\",\n",
|
||||
" map_location=torch.device(\"cpu\"), # load to CPU\n",
|
||||
@@ -4659,6 +4668,7 @@
|
||||
"# Create examples list from \"examples/\" directory\n",
|
||||
"example_list = [[\"examples/\" + example] for example in os.listdir(\"examples\")]\n",
|
||||
"\n",
|
||||
"# Create Gradio interface \n",
|
||||
"demo = gr.Interface(\n",
|
||||
" fn=predict,\n",
|
||||
" inputs=gr.Image(type=\"pil\"),\n",
|
||||
@@ -4672,6 +4682,7 @@
|
||||
" article=article,\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"# Launch the app!\n",
|
||||
"demo.launch()"
|
||||
]
|
||||
},
|
||||
@@ -4679,12 +4690,14 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### TK - Creating a requirements file for FoodVision Big (`requirements.txt`)"
|
||||
"### TK - Creating a requirements file for FoodVision Big (`requirements.txt`)\n",
|
||||
"\n",
|
||||
"Now all we need is a `requirements.txt` file to tell our Hugging Face Space what dependencies our FoodVision Big app requires."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 73,
|
||||
"execution_count": 84,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -4706,12 +4719,16 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### TK - Downloading our FoodVision Big app files"
|
||||
"### TK - Downloading our FoodVision Big app files\n",
|
||||
"\n",
|
||||
"We've got all the files we need to deploy our FoodVision Big app on Hugging Face, let's now zip them together and download them. \n",
|
||||
"\n",
|
||||
"We'll use the same process we used for the FoodVision Mini app above in section (TK - what section number?)."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 74,
|
||||
"execution_count": 85,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -4719,13 +4736,13 @@
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"updating: 09_pretrained_effnetb2_feature_extractor_food101_20_percent.pth (deflated 8%)\n",
|
||||
"updating: app.py (deflated 49%)\n",
|
||||
"updating: app.py (deflated 54%)\n",
|
||||
"updating: class_names.txt (deflated 48%)\n",
|
||||
"updating: examples/ (stored 0%)\n",
|
||||
"updating: examples/04-pizza-dad.jpeg (deflated 0%)\n",
|
||||
"updating: flagged/ (stored 0%)\n",
|
||||
"updating: model.py (deflated 46%)\n",
|
||||
"updating: model.py (deflated 56%)\n",
|
||||
"updating: requirements.txt (deflated 4%)\n",
|
||||
"updating: examples/04-pizza-dad.jpg (deflated 0%)\n",
|
||||
"Not running in Google Colab, can't use google.colab.files.download()\n"
|
||||
]
|
||||
}
|
||||
@@ -4748,20 +4765,50 @@
|
||||
"source": [
|
||||
"## TK - Deploying our FoodVision Big app to HuggingFace Spaces\n",
|
||||
"\n",
|
||||
"TK - rather than repeating the steps, we'll folow the same steps as section XYZ for FoodVision Mini, except we'll make sure to give the Hugging Face Space a different name... \n",
|
||||
"Alright, alright, alright time to bring our biggest model of the whole course to life!\n",
|
||||
"\n",
|
||||
"See here for uploading to HuggingFace: https://huggingface.co/docs/hub/repositories-getting-started#getting-started-with-repositories\n",
|
||||
"Let's deploy our FoodVision Big Gradio demo to Hugging Face Spaces so we can test it interactively and let others experience the magic of our machine learning efforts!\n",
|
||||
"\n",
|
||||
"See the deployed app - https://huggingface.co/spaces/mrdbourke/foodvision_big/\n",
|
||||
"> **Note:** There are [several ways to upload files to Hugging Face Spaces](https://huggingface.co/docs/hub/repositories-getting-started#getting-started-with-repositories). The following steps treat Hugging Face as a git repository to track files. However, you can also upload directly to Hugging Face Spaces via the [web interface](https://huggingface.co/docs/hub/repositories-getting-started#adding-files-to-a-repository-web-ui) or by the [`huggingface_hub` library](https://huggingface.co/docs/huggingface_hub/index). \n",
|
||||
"\n",
|
||||
"TK image - gif of deployed app (what it looks like on Hugging Face Spaces when deployed\n",
|
||||
"The good news is, we've already done the steps to do so with FoodVision Mini, so now all we have to do is customize them to suit FoodVision Big:\n",
|
||||
"\n",
|
||||
"<iframe src=\"https://hf.space/embed/abidlabs/pytorch-image-classifier/+\"></iframe>"
|
||||
"1. [Sign up](https://huggingface.co/join) for a Hugging Face account. \n",
|
||||
"2. Start a new Hugging Face Space by going to your profile and then [clicking \"New Space\"](https://huggingface.co/new-space).\n",
|
||||
" * **Note:** A Space in Hugging Face is also known as a \"code repository\" (a place to store your code/files) or \"repo\" for short.\n",
|
||||
"3. Give the Space a name, for example, mine is called `mrdbourke/foodvision_big`, you can see it here: https://huggingface.co/spaces/mrdbourke/foodvision_big\n",
|
||||
"4. Select a license (I used [MIT](https://opensource.org/licenses/MIT)).\n",
|
||||
"5. Select Gradio as the Space SDK (software development kit). \n",
|
||||
" * **Note:** You can use other options such as Streamlit but since our app is built with Gradio, we'll stick with that.\n",
|
||||
"6. Choose whether your Space is it's public or private (I selected public since I'd like my Space to be available to others).\n",
|
||||
"7. Click \"Create Space\".\n",
|
||||
"8. Clone the repo locally by running: `git clone https://huggingface.co/spaces/[YOUR_USERNAME]/[YOUR_SPACE_NAME]` in terminal or command prompt.\n",
|
||||
" * **Note:** You can also add files via uploading them under the \"Files and versions\" tab.\n",
|
||||
"9. Copy/move the contents of the downloaded `foodvision_big` folder to the cloned repo folder.\n",
|
||||
"10. To upload and track larger files (e.g. files over 10MB or in our case, our PyTorch model file) you'll need to [install Git LFS](https://git-lfs.github.com/) (which stands for \"git large file storage\").\n",
|
||||
"11. After you've installed Git LFS, you can activate it by running `git lfs install`.\n",
|
||||
"12. In the `foodvision_big` directory, track the files over 10MB with Git LFS with `git lfs track \"*.file_extension\"`.\n",
|
||||
" * Track EffNetB2 PyTorch model file with `git lfs track \"09_pretrained_effnetb2_feature_extractor_food101_20_percent.pth\"`.\n",
|
||||
" * **Note:** If you get any errors uploading images, you may have to track them with `git lfs` too, for example `git lfs track \"examples/04-pizza-dad.jpg\"`\n",
|
||||
"13. Track `.gitattributes` (automatically created when cloning from HuggingFace, this file will help ensure our larger files are tracked with Git LFS). You can see an example `.gitattributes` file on the [FoodVision Big Hugging Face Space](https://huggingface.co/spaces/mrdbourke/foodvision_big/blob/main/.gitattributes).\n",
|
||||
" * `git add .gitattributes`\n",
|
||||
"14. Add the rest of the `foodvision_big` app files and commit them with: \n",
|
||||
" * `git add *`\n",
|
||||
" * `git commit -m \"first commit\"`\n",
|
||||
"15. Push (upload) the files to Hugging Face:\n",
|
||||
" * `git push`\n",
|
||||
"16. Wait 3-5 minutes for the build to happen (future builds are faster) and your app to become live!\n",
|
||||
"\n",
|
||||
"If everything worked correctly, our FoodVision Big Gradio demo should be ready to classify!\n",
|
||||
"\n",
|
||||
"You can see my version here: https://huggingface.co/spaces/mrdbourke/foodvision_big/\n",
|
||||
"\n",
|
||||
"Or we can even embed our FoodVision Big Gradio demo right within our notebook as an [iframe](https://gradio.app/sharing_your_app/#embedding-with-iframes) with [`IPython.display.IFrame`](https://ipython.readthedocs.io/en/stable/api/generated/IPython.display.html#IPython.display.IFrame) and a link to our space in the format `https://hf.space/embed/[YOUR_USERNAME]/[YOUR_SPACE_NAME]/+`."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 91,
|
||||
"execution_count": 86,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -4769,8 +4816,8 @@
|
||||
"text/html": [
|
||||
"\n",
|
||||
" <iframe\n",
|
||||
" width=\"1000\"\n",
|
||||
" height=\"600\"\n",
|
||||
" width=\"900\"\n",
|
||||
" height=\"750\"\n",
|
||||
" src=\"https://hf.space/embed/mrdbourke/foodvision_big/+\"\n",
|
||||
" frameborder=\"0\"\n",
|
||||
" allowfullscreen\n",
|
||||
@@ -4779,25 +4826,51 @@
|
||||
" "
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.lib.display.IFrame at 0x7f5261645c10>"
|
||||
"<IPython.lib.display.IFrame at 0x7f05def07d60>"
|
||||
]
|
||||
},
|
||||
"execution_count": 91,
|
||||
"execution_count": 86,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# IPython is a library to help work with Python iteractively \n",
|
||||
"from IPython.display import IFrame\n",
|
||||
"\n",
|
||||
"# Embed FoodVision Big Gradio demo as an iFrame\n",
|
||||
"IFrame(src=\"https://hf.space/embed/mrdbourke/foodvision_big/+\", width=900, height=750)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"How cool is that!?!\n",
|
||||
"\n",
|
||||
"We've come a long way from building PyTorch models to predict a straight line... now we're building computer vision models accessible to people all around the world!"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## TK - Main takeaways\n",
|
||||
"\n",
|
||||
"UPTOHERE:\n",
|
||||
"* Go back through notebook and fix up TK's\n",
|
||||
"* Complete intro paragraphs\n",
|
||||
"* Fill out main takeaways"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## TK - Exercises\n",
|
||||
"\n",
|
||||
"TK - resources for exercises\n",
|
||||
"\n",
|
||||
"* Compare the model's prediction times on GPU vs CPU - does this close the gap?\n",
|
||||
"* ViT seems to have more learning capacity than EffNetB2, how does it go on the larger Food101 dataset? - train for 5 epochs\n",
|
||||
" * Use same training setup as we've done for the EffNetB2 model\n",
|
||||
@@ -4834,7 +4907,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 75,
|
||||
"execution_count": 87,
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user