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,
|
| 3 |
+
"nbformat_minor": 0,
|
| 4 |
+
"metadata": {
|
| 5 |
+
"colab": {
|
| 6 |
+
"provenance": [],
|
| 7 |
+
"gpuType": "T4"
|
| 8 |
+
},
|
| 9 |
+
"kernelspec": {
|
| 10 |
+
"name": "python3",
|
| 11 |
+
"display_name": "Python 3"
|
| 12 |
+
},
|
| 13 |
+
"language_info": {
|
| 14 |
+
"name": "python"
|
| 15 |
+
},
|
| 16 |
+
"accelerator": "GPU"
|
| 17 |
+
},
|
| 18 |
+
"cells": [
|
| 19 |
+
{
|
| 20 |
+
"cell_type": "code",
|
| 21 |
+
"execution_count": 1,
|
| 22 |
+
"metadata": {
|
| 23 |
+
"id": "zlD1ysQ7Tckp"
|
| 24 |
+
},
|
| 25 |
+
"outputs": [],
|
| 26 |
+
"source": [
|
| 27 |
+
"import torch\n",
|
| 28 |
+
"from torch import nn\n",
|
| 29 |
+
"from pathlib import Path"
|
| 30 |
+
]
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"cell_type": "code",
|
| 34 |
+
"source": [
|
| 35 |
+
"!pip3 install gradio"
|
| 36 |
+
],
|
| 37 |
+
"metadata": {
|
| 38 |
+
"colab": {
|
| 39 |
+
"base_uri": "https://localhost:8080/"
|
| 40 |
+
},
|
| 41 |
+
"id": "YJQBJHP1Tym5",
|
| 42 |
+
"outputId": "46afdd2e-b5fc-4eef-93e3-1f3bc9b7f1ce"
|
| 43 |
+
},
|
| 44 |
+
"execution_count": 6,
|
| 45 |
+
"outputs": [
|
| 46 |
+
{
|
| 47 |
+
"output_type": "stream",
|
| 48 |
+
"name": "stdout",
|
| 49 |
+
"text": [
|
| 50 |
+
"Collecting gradio\n",
|
| 51 |
+
" Downloading gradio-3.38.0-py3-none-any.whl (19.8 MB)\n",
|
| 52 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m19.8/19.8 MB\u001b[0m \u001b[31m72.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 53 |
+
"\u001b[?25hCollecting aiofiles<24.0,>=22.0 (from gradio)\n",
|
| 54 |
+
" Downloading aiofiles-23.1.0-py3-none-any.whl (14 kB)\n",
|
| 55 |
+
"Requirement already satisfied: aiohttp~=3.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.8.4)\n",
|
| 56 |
+
"Requirement already satisfied: altair<6.0,>=4.2.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (4.2.2)\n",
|
| 57 |
+
"Collecting fastapi (from gradio)\n",
|
| 58 |
+
" Downloading fastapi-0.100.0-py3-none-any.whl (65 kB)\n",
|
| 59 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m65.7/65.7 kB\u001b[0m \u001b[31m7.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 60 |
+
"\u001b[?25hCollecting ffmpy (from gradio)\n",
|
| 61 |
+
" Downloading ffmpy-0.3.1.tar.gz (5.5 kB)\n",
|
| 62 |
+
" Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
|
| 63 |
+
"Collecting gradio-client>=0.2.10 (from gradio)\n",
|
| 64 |
+
" Downloading gradio_client-0.2.10-py3-none-any.whl (288 kB)\n",
|
| 65 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m289.0/289.0 kB\u001b[0m \u001b[31m31.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 66 |
+
"\u001b[?25hCollecting httpx (from gradio)\n",
|
| 67 |
+
" Downloading httpx-0.24.1-py3-none-any.whl (75 kB)\n",
|
| 68 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m75.4/75.4 kB\u001b[0m \u001b[31m10.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 69 |
+
"\u001b[?25hCollecting huggingface-hub>=0.14.0 (from gradio)\n",
|
| 70 |
+
" Downloading huggingface_hub-0.16.4-py3-none-any.whl (268 kB)\n",
|
| 71 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m268.8/268.8 kB\u001b[0m \u001b[31m28.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 72 |
+
"\u001b[?25hRequirement already satisfied: jinja2<4.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.1.2)\n",
|
| 73 |
+
"Requirement already satisfied: markdown-it-py[linkify]>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.0.0)\n",
|
| 74 |
+
"Requirement already satisfied: markupsafe~=2.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.1.3)\n",
|
| 75 |
+
"Requirement already satisfied: matplotlib~=3.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (3.7.1)\n",
|
| 76 |
+
"Collecting mdit-py-plugins<=0.3.3 (from gradio)\n",
|
| 77 |
+
" Downloading mdit_py_plugins-0.3.3-py3-none-any.whl (50 kB)\n",
|
| 78 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m50.5/50.5 kB\u001b[0m \u001b[31m2.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 79 |
+
"\u001b[?25hRequirement already satisfied: numpy~=1.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (1.22.4)\n",
|
| 80 |
+
"Collecting orjson~=3.0 (from gradio)\n",
|
| 81 |
+
" Downloading orjson-3.9.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (138 kB)\n",
|
| 82 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m138.7/138.7 kB\u001b[0m \u001b[31m17.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 83 |
+
"\u001b[?25hRequirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from gradio) (23.1)\n",
|
| 84 |
+
"Requirement already satisfied: pandas<3.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (1.5.3)\n",
|
| 85 |
+
"Requirement already satisfied: pillow<11.0,>=8.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (8.4.0)\n",
|
| 86 |
+
"Requirement already satisfied: pydantic!=1.8,!=1.8.1,!=2.0.0,!=2.0.1,<3.0.0,>=1.7.4 in /usr/local/lib/python3.10/dist-packages (from gradio) (1.10.11)\n",
|
| 87 |
+
"Collecting pydub (from gradio)\n",
|
| 88 |
+
" Downloading pydub-0.25.1-py2.py3-none-any.whl (32 kB)\n",
|
| 89 |
+
"Collecting python-multipart (from gradio)\n",
|
| 90 |
+
" Downloading python_multipart-0.0.6-py3-none-any.whl (45 kB)\n",
|
| 91 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m45.7/45.7 kB\u001b[0m \u001b[31m5.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 92 |
+
"\u001b[?25hRequirement already satisfied: pyyaml<7.0,>=5.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (6.0.1)\n",
|
| 93 |
+
"Requirement already satisfied: requests~=2.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (2.27.1)\n",
|
| 94 |
+
"Collecting semantic-version~=2.0 (from gradio)\n",
|
| 95 |
+
" Downloading semantic_version-2.10.0-py2.py3-none-any.whl (15 kB)\n",
|
| 96 |
+
"Requirement already satisfied: typing-extensions~=4.0 in /usr/local/lib/python3.10/dist-packages (from gradio) (4.7.1)\n",
|
| 97 |
+
"Collecting uvicorn>=0.14.0 (from gradio)\n",
|
| 98 |
+
" Downloading uvicorn-0.23.1-py3-none-any.whl (59 kB)\n",
|
| 99 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m59.5/59.5 kB\u001b[0m \u001b[31m7.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 100 |
+
"\u001b[?25hCollecting websockets<12.0,>=10.0 (from gradio)\n",
|
| 101 |
+
" Downloading websockets-11.0.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (129 kB)\n",
|
| 102 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m129.9/129.9 kB\u001b[0m \u001b[31m16.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 103 |
+
"\u001b[?25hRequirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp~=3.0->gradio) (23.1.0)\n",
|
| 104 |
+
"Requirement already satisfied: charset-normalizer<4.0,>=2.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp~=3.0->gradio) (2.0.12)\n",
|
| 105 |
+
"Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp~=3.0->gradio) (6.0.4)\n",
|
| 106 |
+
"Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in /usr/local/lib/python3.10/dist-packages (from aiohttp~=3.0->gradio) (4.0.2)\n",
|
| 107 |
+
"Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp~=3.0->gradio) (1.9.2)\n",
|
| 108 |
+
"Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp~=3.0->gradio) (1.4.0)\n",
|
| 109 |
+
"Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp~=3.0->gradio) (1.3.1)\n",
|
| 110 |
+
"Requirement already satisfied: entrypoints in /usr/local/lib/python3.10/dist-packages (from altair<6.0,>=4.2.0->gradio) (0.4)\n",
|
| 111 |
+
"Requirement already satisfied: jsonschema>=3.0 in /usr/local/lib/python3.10/dist-packages (from altair<6.0,>=4.2.0->gradio) (4.3.3)\n",
|
| 112 |
+
"Requirement already satisfied: toolz in /usr/local/lib/python3.10/dist-packages (from altair<6.0,>=4.2.0->gradio) (0.12.0)\n",
|
| 113 |
+
"Requirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-packages (from gradio-client>=0.2.10->gradio) (2023.6.0)\n",
|
| 114 |
+
"Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.14.0->gradio) (3.12.2)\n",
|
| 115 |
+
"Requirement already satisfied: tqdm>=4.42.1 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.14.0->gradio) (4.65.0)\n",
|
| 116 |
+
"Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.10/dist-packages (from markdown-it-py[linkify]>=2.0.0->gradio) (0.1.2)\n",
|
| 117 |
+
"Collecting linkify-it-py<3,>=1 (from markdown-it-py[linkify]>=2.0.0->gradio)\n",
|
| 118 |
+
" Downloading linkify_it_py-2.0.2-py3-none-any.whl (19 kB)\n",
|
| 119 |
+
"Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (1.1.0)\n",
|
| 120 |
+
"Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (0.11.0)\n",
|
| 121 |
+
"Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (4.41.0)\n",
|
| 122 |
+
"Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (1.4.4)\n",
|
| 123 |
+
"Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (3.1.0)\n",
|
| 124 |
+
"Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.10/dist-packages (from matplotlib~=3.0->gradio) (2.8.2)\n",
|
| 125 |
+
"INFO: pip is looking at multiple versions of mdit-py-plugins to determine which version is compatible with other requirements. This could take a while.\n",
|
| 126 |
+
"Collecting mdit-py-plugins<=0.3.3 (from gradio)\n",
|
| 127 |
+
" Downloading mdit_py_plugins-0.3.2-py3-none-any.whl (50 kB)\n",
|
| 128 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m50.4/50.4 kB\u001b[0m \u001b[31m6.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 129 |
+
"\u001b[?25h Downloading mdit_py_plugins-0.3.1-py3-none-any.whl (46 kB)\n",
|
| 130 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m46.5/46.5 kB\u001b[0m \u001b[31m5.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 131 |
+
"\u001b[?25h Downloading mdit_py_plugins-0.3.0-py3-none-any.whl (43 kB)\n",
|
| 132 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m43.7/43.7 kB\u001b[0m \u001b[31m5.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 133 |
+
"\u001b[?25h Downloading mdit_py_plugins-0.2.8-py3-none-any.whl (41 kB)\n",
|
| 134 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m41.0/41.0 kB\u001b[0m \u001b[31m5.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 135 |
+
"\u001b[?25h Downloading mdit_py_plugins-0.2.7-py3-none-any.whl (41 kB)\n",
|
| 136 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m41.0/41.0 kB\u001b[0m \u001b[31m5.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 137 |
+
"\u001b[?25h Downloading mdit_py_plugins-0.2.6-py3-none-any.whl (39 kB)\n",
|
| 138 |
+
" Downloading mdit_py_plugins-0.2.5-py3-none-any.whl (39 kB)\n",
|
| 139 |
+
"INFO: pip is looking at multiple versions of mdit-py-plugins to determine which version is compatible with other requirements. This could take a while.\n",
|
| 140 |
+
" Downloading mdit_py_plugins-0.2.4-py3-none-any.whl (39 kB)\n",
|
| 141 |
+
" Downloading mdit_py_plugins-0.2.3-py3-none-any.whl (39 kB)\n",
|
| 142 |
+
" Downloading mdit_py_plugins-0.2.2-py3-none-any.whl (39 kB)\n",
|
| 143 |
+
" Downloading mdit_py_plugins-0.2.1-py3-none-any.whl (38 kB)\n",
|
| 144 |
+
" Downloading mdit_py_plugins-0.2.0-py3-none-any.whl (38 kB)\n",
|
| 145 |
+
"INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. See https://pip.pypa.io/warnings/backtracking for guidance. If you want to abort this run, press Ctrl + C.\n",
|
| 146 |
+
" Downloading mdit_py_plugins-0.1.0-py3-none-any.whl (37 kB)\n",
|
| 147 |
+
"Collecting markdown-it-py[linkify]>=2.0.0 (from gradio)\n",
|
| 148 |
+
" Downloading markdown_it_py-3.0.0-py3-none-any.whl (87 kB)\n",
|
| 149 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m87.5/87.5 kB\u001b[0m \u001b[31m11.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 150 |
+
"\u001b[?25h Downloading markdown_it_py-2.2.0-py3-none-any.whl (84 kB)\n",
|
| 151 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m84.5/84.5 kB\u001b[0m \u001b[31m9.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 152 |
+
"\u001b[?25hRequirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas<3.0,>=1.0->gradio) (2022.7.1)\n",
|
| 153 |
+
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests~=2.0->gradio) (1.26.16)\n",
|
| 154 |
+
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests~=2.0->gradio) (2023.5.7)\n",
|
| 155 |
+
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests~=2.0->gradio) (3.4)\n",
|
| 156 |
+
"Requirement already satisfied: click>=7.0 in /usr/local/lib/python3.10/dist-packages (from uvicorn>=0.14.0->gradio) (8.1.6)\n",
|
| 157 |
+
"Collecting h11>=0.8 (from uvicorn>=0.14.0->gradio)\n",
|
| 158 |
+
" Downloading h11-0.14.0-py3-none-any.whl (58 kB)\n",
|
| 159 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m58.3/58.3 kB\u001b[0m \u001b[31m7.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 160 |
+
"\u001b[?25hCollecting starlette<0.28.0,>=0.27.0 (from fastapi->gradio)\n",
|
| 161 |
+
" Downloading starlette-0.27.0-py3-none-any.whl (66 kB)\n",
|
| 162 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m67.0/67.0 kB\u001b[0m \u001b[31m7.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 163 |
+
"\u001b[?25hCollecting httpcore<0.18.0,>=0.15.0 (from httpx->gradio)\n",
|
| 164 |
+
" Downloading httpcore-0.17.3-py3-none-any.whl (74 kB)\n",
|
| 165 |
+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m74.5/74.5 kB\u001b[0m \u001b[31m8.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
| 166 |
+
"\u001b[?25hRequirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from httpx->gradio) (1.3.0)\n",
|
| 167 |
+
"Requirement already satisfied: anyio<5.0,>=3.0 in /usr/local/lib/python3.10/dist-packages (from httpcore<0.18.0,>=0.15.0->httpx->gradio) (3.7.1)\n",
|
| 168 |
+
"Requirement already satisfied: pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=3.0->altair<6.0,>=4.2.0->gradio) (0.19.3)\n",
|
| 169 |
+
"Collecting uc-micro-py (from linkify-it-py<3,>=1->markdown-it-py[linkify]>=2.0.0->gradio)\n",
|
| 170 |
+
" Downloading uc_micro_py-1.0.2-py3-none-any.whl (6.2 kB)\n",
|
| 171 |
+
"Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.7->matplotlib~=3.0->gradio) (1.16.0)\n",
|
| 172 |
+
"Requirement already satisfied: exceptiongroup in /usr/local/lib/python3.10/dist-packages (from anyio<5.0,>=3.0->httpcore<0.18.0,>=0.15.0->httpx->gradio) (1.1.2)\n",
|
| 173 |
+
"Building wheels for collected packages: ffmpy\n",
|
| 174 |
+
" Building wheel for ffmpy (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
|
| 175 |
+
" Created wheel for ffmpy: filename=ffmpy-0.3.1-py3-none-any.whl size=5579 sha256=1f000f2f7853794c5857deb6ffb3305dbe3ceedf8e546a42ffd49709d11a0496\n",
|
| 176 |
+
" Stored in directory: /root/.cache/pip/wheels/01/a6/d1/1c0828c304a4283b2c1639a09ad86f83d7c487ef34c6b4a1bf\n",
|
| 177 |
+
"Successfully built ffmpy\n",
|
| 178 |
+
"Installing collected packages: pydub, ffmpy, websockets, uc-micro-py, semantic-version, python-multipart, orjson, markdown-it-py, h11, aiofiles, uvicorn, starlette, mdit-py-plugins, linkify-it-py, huggingface-hub, httpcore, httpx, fastapi, gradio-client, gradio\n",
|
| 179 |
+
" Attempting uninstall: markdown-it-py\n",
|
| 180 |
+
" Found existing installation: markdown-it-py 3.0.0\n",
|
| 181 |
+
" Uninstalling markdown-it-py-3.0.0:\n",
|
| 182 |
+
" Successfully uninstalled markdown-it-py-3.0.0\n",
|
| 183 |
+
"Successfully installed aiofiles-23.1.0 fastapi-0.100.0 ffmpy-0.3.1 gradio-3.38.0 gradio-client-0.2.10 h11-0.14.0 httpcore-0.17.3 httpx-0.24.1 huggingface-hub-0.16.4 linkify-it-py-2.0.2 markdown-it-py-2.2.0 mdit-py-plugins-0.3.3 orjson-3.9.2 pydub-0.25.1 python-multipart-0.0.6 semantic-version-2.10.0 starlette-0.27.0 uc-micro-py-1.0.2 uvicorn-0.23.1 websockets-11.0.3\n"
|
| 184 |
+
]
|
| 185 |
+
}
|
| 186 |
+
]
|
| 187 |
+
},
|
| 188 |
+
{
|
| 189 |
+
"cell_type": "code",
|
| 190 |
+
"source": [
|
| 191 |
+
"LABELS=Path('class_names.txt').read_text().splitlines()"
|
| 192 |
+
],
|
| 193 |
+
"metadata": {
|
| 194 |
+
"id": "PGdL4zXMT8Bn"
|
| 195 |
+
},
|
| 196 |
+
"execution_count": 3,
|
| 197 |
+
"outputs": []
|
| 198 |
+
},
|
| 199 |
+
{
|
| 200 |
+
"cell_type": "code",
|
| 201 |
+
"source": [
|
| 202 |
+
"model = nn.Sequential(\n",
|
| 203 |
+
" nn.Conv2d(1, 32, 3, padding='same'),\n",
|
| 204 |
+
" nn.ReLU(),\n",
|
| 205 |
+
" nn.MaxPool2d(2),\n",
|
| 206 |
+
" nn.Conv2d(32, 64, 3, padding='same'),\n",
|
| 207 |
+
" nn.ReLU(),\n",
|
| 208 |
+
" nn.MaxPool2d(2),\n",
|
| 209 |
+
" nn.Conv2d(64, 128, 3, padding='same'),\n",
|
| 210 |
+
" nn.ReLU(),\n",
|
| 211 |
+
" nn.MaxPool2d(2),\n",
|
| 212 |
+
" nn.Flatten(),\n",
|
| 213 |
+
" nn.Linear(1152, 256),\n",
|
| 214 |
+
" nn.ReLU(),\n",
|
| 215 |
+
" nn.Linear(256, len(LABELS)),\n",
|
| 216 |
+
")"
|
| 217 |
+
],
|
| 218 |
+
"metadata": {
|
| 219 |
+
"id": "XZ1AM4BxUMnH"
|
| 220 |
+
},
|
| 221 |
+
"execution_count": 4,
|
| 222 |
+
"outputs": []
|
| 223 |
+
},
|
| 224 |
+
{
|
| 225 |
+
"cell_type": "code",
|
| 226 |
+
"source": [
|
| 227 |
+
"state_dict=torch.load('pytorch_model.bin',map_location='cpu')"
|
| 228 |
+
],
|
| 229 |
+
"metadata": {
|
| 230 |
+
"id": "lDJZ7Vo9Ui0Y"
|
| 231 |
+
},
|
| 232 |
+
"execution_count": 9,
|
| 233 |
+
"outputs": []
|
| 234 |
+
},
|
| 235 |
+
{
|
| 236 |
+
"cell_type": "code",
|
| 237 |
+
"source": [
|
| 238 |
+
"import gradio as gr"
|
| 239 |
+
],
|
| 240 |
+
"metadata": {
|
| 241 |
+
"id": "LzwKoPfTUq5x"
|
| 242 |
+
},
|
| 243 |
+
"execution_count": 7,
|
| 244 |
+
"outputs": []
|
| 245 |
+
},
|
| 246 |
+
{
|
| 247 |
+
"cell_type": "code",
|
| 248 |
+
"source": [
|
| 249 |
+
"model.load_state_dict(state_dict, strict=False)\n",
|
| 250 |
+
"model.eval()\n"
|
| 251 |
+
],
|
| 252 |
+
"metadata": {
|
| 253 |
+
"colab": {
|
| 254 |
+
"base_uri": "https://localhost:8080/"
|
| 255 |
+
},
|
| 256 |
+
"id": "e_6paL_qU4YB",
|
| 257 |
+
"outputId": "e018df13-6ac1-47a0-d634-cb8084d05d5a"
|
| 258 |
+
},
|
| 259 |
+
"execution_count": 10,
|
| 260 |
+
"outputs": [
|
| 261 |
+
{
|
| 262 |
+
"output_type": "execute_result",
|
| 263 |
+
"data": {
|
| 264 |
+
"text/plain": [
|
| 265 |
+
"Sequential(\n",
|
| 266 |
+
" (0): Conv2d(1, 32, kernel_size=(3, 3), stride=(1, 1), padding=same)\n",
|
| 267 |
+
" (1): ReLU()\n",
|
| 268 |
+
" (2): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
|
| 269 |
+
" (3): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=same)\n",
|
| 270 |
+
" (4): ReLU()\n",
|
| 271 |
+
" (5): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
|
| 272 |
+
" (6): Conv2d(64, 128, kernel_size=(3, 3), stride=(1, 1), padding=same)\n",
|
| 273 |
+
" (7): ReLU()\n",
|
| 274 |
+
" (8): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
|
| 275 |
+
" (9): Flatten(start_dim=1, end_dim=-1)\n",
|
| 276 |
+
" (10): Linear(in_features=1152, out_features=256, bias=True)\n",
|
| 277 |
+
" (11): ReLU()\n",
|
| 278 |
+
" (12): Linear(in_features=256, out_features=100, bias=True)\n",
|
| 279 |
+
")"
|
| 280 |
+
]
|
| 281 |
+
},
|
| 282 |
+
"metadata": {},
|
| 283 |
+
"execution_count": 10
|
| 284 |
+
}
|
| 285 |
+
]
|
| 286 |
+
},
|
| 287 |
+
{
|
| 288 |
+
"cell_type": "code",
|
| 289 |
+
"source": [
|
| 290 |
+
"def predict(im):\n",
|
| 291 |
+
" x = torch.tensor(im, dtype=torch.float32).unsqueeze(0).unsqueeze(0) / 255.\n",
|
| 292 |
+
"\n",
|
| 293 |
+
" with torch.no_grad():\n",
|
| 294 |
+
" out = model(x)\n",
|
| 295 |
+
"\n",
|
| 296 |
+
" probabilities = torch.nn.functional.softmax(out[0], dim=0)\n",
|
| 297 |
+
"\n",
|
| 298 |
+
" values, indices = torch.topk(probabilities, 5)\n",
|
| 299 |
+
"\n",
|
| 300 |
+
" return {LABELS[i]: v.item() for i, v in zip(indices, values)}"
|
| 301 |
+
],
|
| 302 |
+
"metadata": {
|
| 303 |
+
"id": "baptDAiGVCvF"
|
| 304 |
+
},
|
| 305 |
+
"execution_count": 11,
|
| 306 |
+
"outputs": []
|
| 307 |
+
},
|
| 308 |
+
{
|
| 309 |
+
"cell_type": "code",
|
| 310 |
+
"source": [
|
| 311 |
+
"interface=gr.Interface(\n",
|
| 312 |
+
" predict,\n",
|
| 313 |
+
" inputs=\"sketchpad\",\n",
|
| 314 |
+
" outputs='label',\n",
|
| 315 |
+
" theme=\"huggingface\",\n",
|
| 316 |
+
" title=\"Sketch Recognition\",\n",
|
| 317 |
+
" description=\"Sketch something for the model to guess in realtime\",\n",
|
| 318 |
+
" article = \"<p style='text-align: center'>Sketch Recognition | Demo Model</p>\",\n",
|
| 319 |
+
" live=True)\n",
|
| 320 |
+
"interface.launch(share=True)\n"
|
| 321 |
+
],
|
| 322 |
+
"metadata": {
|
| 323 |
+
"colab": {
|
| 324 |
+
"base_uri": "https://localhost:8080/",
|
| 325 |
+
"height": 1000
|
| 326 |
+
},
|
| 327 |
+
"id": "4sZiRCv-VI9O",
|
| 328 |
+
"outputId": "476b68b7-397e-4465-fb83-fb9b6dff499d"
|
| 329 |
+
},
|
| 330 |
+
"execution_count": 13,
|
| 331 |
+
"outputs": [
|
| 332 |
+
{
|
| 333 |
+
"output_type": "stream",
|
| 334 |
+
"name": "stderr",
|
| 335 |
+
"text": [
|
| 336 |
+
"/usr/local/lib/python3.10/dist-packages/gradio/blocks.py:694: UserWarning: Cannot load huggingface. Caught Exception: The space huggingface does not exist\n",
|
| 337 |
+
" warnings.warn(f\"Cannot load {theme}. Caught Exception: {str(e)}\")\n"
|
| 338 |
+
]
|
| 339 |
+
},
|
| 340 |
+
{
|
| 341 |
+
"output_type": "stream",
|
| 342 |
+
"name": "stdout",
|
| 343 |
+
"text": [
|
| 344 |
+
"Colab notebook detected. This cell will run indefinitely so that you can see errors and logs. To turn off, set debug=False in launch().\n",
|
| 345 |
+
"Running on public URL: https://033d7a67112f637955.gradio.live\n",
|
| 346 |
+
"\n",
|
| 347 |
+
"This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n"
|
| 348 |
+
]
|
| 349 |
+
},
|
| 350 |
+
{
|
| 351 |
+
"output_type": "display_data",
|
| 352 |
+
"data": {
|
| 353 |
+
"text/plain": [
|
| 354 |
+
"<IPython.core.display.HTML object>"
|
| 355 |
+
],
|
| 356 |
+
"text/html": [
|
| 357 |
+
"<div><iframe src=\"https://033d7a67112f637955.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
| 358 |
+
]
|
| 359 |
+
},
|
| 360 |
+
"metadata": {}
|
| 361 |
+
},
|
| 362 |
+
{
|
| 363 |
+
"output_type": "stream",
|
| 364 |
+
"name": "stderr",
|
| 365 |
+
"text": [
|
| 366 |
+
"Traceback (most recent call last):\n",
|
| 367 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/routes.py\", line 442, in run_predict\n",
|
| 368 |
+
" output = await app.get_blocks().process_api(\n",
|
| 369 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/blocks.py\", line 1389, in process_api\n",
|
| 370 |
+
" result = await self.call_function(\n",
|
| 371 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/blocks.py\", line 1094, in call_function\n",
|
| 372 |
+
" prediction = await anyio.to_thread.run_sync(\n",
|
| 373 |
+
" File \"/usr/local/lib/python3.10/dist-packages/anyio/to_thread.py\", line 33, in run_sync\n",
|
| 374 |
+
" return await get_asynclib().run_sync_in_worker_thread(\n",
|
| 375 |
+
" File \"/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py\", line 877, in run_sync_in_worker_thread\n",
|
| 376 |
+
" return await future\n",
|
| 377 |
+
" File \"/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py\", line 807, in run\n",
|
| 378 |
+
" result = context.run(func, *args)\n",
|
| 379 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/utils.py\", line 703, in wrapper\n",
|
| 380 |
+
" response = f(*args, **kwargs)\n",
|
| 381 |
+
" File \"<ipython-input-11-83491c3d48b5>\", line 2, in predict\n",
|
| 382 |
+
" x = torch.tensor(im, dtype=torch.float32).unsqueeze(0).unsqueeze(0) / 255.\n",
|
| 383 |
+
"TypeError: must be real number, not NoneType\n",
|
| 384 |
+
"Traceback (most recent call last):\n",
|
| 385 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/routes.py\", line 442, in run_predict\n",
|
| 386 |
+
" output = await app.get_blocks().process_api(\n",
|
| 387 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/blocks.py\", line 1389, in process_api\n",
|
| 388 |
+
" result = await self.call_function(\n",
|
| 389 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/blocks.py\", line 1094, in call_function\n",
|
| 390 |
+
" prediction = await anyio.to_thread.run_sync(\n",
|
| 391 |
+
" File \"/usr/local/lib/python3.10/dist-packages/anyio/to_thread.py\", line 33, in run_sync\n",
|
| 392 |
+
" return await get_asynclib().run_sync_in_worker_thread(\n",
|
| 393 |
+
" File \"/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py\", line 877, in run_sync_in_worker_thread\n",
|
| 394 |
+
" return await future\n",
|
| 395 |
+
" File \"/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py\", line 807, in run\n",
|
| 396 |
+
" result = context.run(func, *args)\n",
|
| 397 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/utils.py\", line 703, in wrapper\n",
|
| 398 |
+
" response = f(*args, **kwargs)\n",
|
| 399 |
+
" File \"<ipython-input-11-83491c3d48b5>\", line 2, in predict\n",
|
| 400 |
+
" x = torch.tensor(im, dtype=torch.float32).unsqueeze(0).unsqueeze(0) / 255.\n",
|
| 401 |
+
"TypeError: must be real number, not NoneType\n",
|
| 402 |
+
"Traceback (most recent call last):\n",
|
| 403 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/routes.py\", line 442, in run_predict\n",
|
| 404 |
+
" output = await app.get_blocks().process_api(\n",
|
| 405 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/blocks.py\", line 1389, in process_api\n",
|
| 406 |
+
" result = await self.call_function(\n",
|
| 407 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/blocks.py\", line 1094, in call_function\n",
|
| 408 |
+
" prediction = await anyio.to_thread.run_sync(\n",
|
| 409 |
+
" File \"/usr/local/lib/python3.10/dist-packages/anyio/to_thread.py\", line 33, in run_sync\n",
|
| 410 |
+
" return await get_asynclib().run_sync_in_worker_thread(\n",
|
| 411 |
+
" File \"/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py\", line 877, in run_sync_in_worker_thread\n",
|
| 412 |
+
" return await future\n",
|
| 413 |
+
" File \"/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py\", line 807, in run\n",
|
| 414 |
+
" result = context.run(func, *args)\n",
|
| 415 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/utils.py\", line 703, in wrapper\n",
|
| 416 |
+
" response = f(*args, **kwargs)\n",
|
| 417 |
+
" File \"<ipython-input-11-83491c3d48b5>\", line 2, in predict\n",
|
| 418 |
+
" x = torch.tensor(im, dtype=torch.float32).unsqueeze(0).unsqueeze(0) / 255.\n",
|
| 419 |
+
"TypeError: must be real number, not NoneType\n",
|
| 420 |
+
"Traceback (most recent call last):\n",
|
| 421 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/routes.py\", line 442, in run_predict\n",
|
| 422 |
+
" output = await app.get_blocks().process_api(\n",
|
| 423 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/blocks.py\", line 1389, in process_api\n",
|
| 424 |
+
" result = await self.call_function(\n",
|
| 425 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/blocks.py\", line 1094, in call_function\n",
|
| 426 |
+
" prediction = await anyio.to_thread.run_sync(\n",
|
| 427 |
+
" File \"/usr/local/lib/python3.10/dist-packages/anyio/to_thread.py\", line 33, in run_sync\n",
|
| 428 |
+
" return await get_asynclib().run_sync_in_worker_thread(\n",
|
| 429 |
+
" File \"/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py\", line 877, in run_sync_in_worker_thread\n",
|
| 430 |
+
" return await future\n",
|
| 431 |
+
" File \"/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py\", line 807, in run\n",
|
| 432 |
+
" result = context.run(func, *args)\n",
|
| 433 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/utils.py\", line 703, in wrapper\n",
|
| 434 |
+
" response = f(*args, **kwargs)\n",
|
| 435 |
+
" File \"<ipython-input-11-83491c3d48b5>\", line 2, in predict\n",
|
| 436 |
+
" x = torch.tensor(im, dtype=torch.float32).unsqueeze(0).unsqueeze(0) / 255.\n",
|
| 437 |
+
"TypeError: must be real number, not NoneType\n",
|
| 438 |
+
"Traceback (most recent call last):\n",
|
| 439 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/routes.py\", line 442, in run_predict\n",
|
| 440 |
+
" output = await app.get_blocks().process_api(\n",
|
| 441 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/blocks.py\", line 1389, in process_api\n",
|
| 442 |
+
" result = await self.call_function(\n",
|
| 443 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/blocks.py\", line 1094, in call_function\n",
|
| 444 |
+
" prediction = await anyio.to_thread.run_sync(\n",
|
| 445 |
+
" File \"/usr/local/lib/python3.10/dist-packages/anyio/to_thread.py\", line 33, in run_sync\n",
|
| 446 |
+
" return await get_asynclib().run_sync_in_worker_thread(\n",
|
| 447 |
+
" File \"/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py\", line 877, in run_sync_in_worker_thread\n",
|
| 448 |
+
" return await future\n",
|
| 449 |
+
" File \"/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py\", line 807, in run\n",
|
| 450 |
+
" result = context.run(func, *args)\n",
|
| 451 |
+
" File \"/usr/local/lib/python3.10/dist-packages/gradio/utils.py\", line 703, in wrapper\n",
|
| 452 |
+
" response = f(*args, **kwargs)\n",
|
| 453 |
+
" File \"<ipython-input-11-83491c3d48b5>\", line 2, in predict\n",
|
| 454 |
+
" x = torch.tensor(im, dtype=torch.float32).unsqueeze(0).unsqueeze(0) / 255.\n",
|
| 455 |
+
"TypeError: must be real number, not NoneType\n"
|
| 456 |
+
]
|
| 457 |
+
},
|
| 458 |
+
{
|
| 459 |
+
"output_type": "stream",
|
| 460 |
+
"name": "stdout",
|
| 461 |
+
"text": [
|
| 462 |
+
"Keyboard interruption in main thread... closing server.\n",
|
| 463 |
+
"Killing tunnel 127.0.0.1:7860 <> https://033d7a67112f637955.gradio.live\n"
|
| 464 |
+
]
|
| 465 |
+
},
|
| 466 |
+
{
|
| 467 |
+
"output_type": "execute_result",
|
| 468 |
+
"data": {
|
| 469 |
+
"text/plain": []
|
| 470 |
+
},
|
| 471 |
+
"metadata": {},
|
| 472 |
+
"execution_count": 13
|
| 473 |
+
}
|
| 474 |
+
]
|
| 475 |
+
},
|
| 476 |
+
{
|
| 477 |
+
"cell_type": "code",
|
| 478 |
+
"source": [],
|
| 479 |
+
"metadata": {
|
| 480 |
+
"id": "30uwS_0zVhT3"
|
| 481 |
+
},
|
| 482 |
+
"execution_count": null,
|
| 483 |
+
"outputs": []
|
| 484 |
+
}
|
| 485 |
+
]
|
| 486 |
+
}
|
class_names.txt
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
airplane
|
| 2 |
+
alarm_clock
|
| 3 |
+
anvil
|
| 4 |
+
apple
|
| 5 |
+
axe
|
| 6 |
+
baseball
|
| 7 |
+
baseball_bat
|
| 8 |
+
basketball
|
| 9 |
+
beard
|
| 10 |
+
bed
|
| 11 |
+
bench
|
| 12 |
+
bicycle
|
| 13 |
+
bird
|
| 14 |
+
book
|
| 15 |
+
bread
|
| 16 |
+
bridge
|
| 17 |
+
broom
|
| 18 |
+
butterfly
|
| 19 |
+
camera
|
| 20 |
+
candle
|
| 21 |
+
car
|
| 22 |
+
cat
|
| 23 |
+
ceiling_fan
|
| 24 |
+
cell_phone
|
| 25 |
+
chair
|
| 26 |
+
circle
|
| 27 |
+
clock
|
| 28 |
+
cloud
|
| 29 |
+
coffee_cup
|
| 30 |
+
cookie
|
| 31 |
+
cup
|
| 32 |
+
diving_board
|
| 33 |
+
donut
|
| 34 |
+
door
|
| 35 |
+
drums
|
| 36 |
+
dumbbell
|
| 37 |
+
envelope
|
| 38 |
+
eye
|
| 39 |
+
eyeglasses
|
| 40 |
+
face
|
| 41 |
+
fan
|
| 42 |
+
flower
|
| 43 |
+
frying_pan
|
| 44 |
+
grapes
|
| 45 |
+
hammer
|
| 46 |
+
hat
|
| 47 |
+
headphones
|
| 48 |
+
helmet
|
| 49 |
+
hot_dog
|
| 50 |
+
ice_cream
|
| 51 |
+
key
|
| 52 |
+
knife
|
| 53 |
+
ladder
|
| 54 |
+
laptop
|
| 55 |
+
light_bulb
|
| 56 |
+
lightning
|
| 57 |
+
line
|
| 58 |
+
lollipop
|
| 59 |
+
microphone
|
| 60 |
+
moon
|
| 61 |
+
mountain
|
| 62 |
+
moustache
|
| 63 |
+
mushroom
|
| 64 |
+
pants
|
| 65 |
+
paper_clip
|
| 66 |
+
pencil
|
| 67 |
+
pillow
|
| 68 |
+
pizza
|
| 69 |
+
power_outlet
|
| 70 |
+
radio
|
| 71 |
+
rainbow
|
| 72 |
+
rifle
|
| 73 |
+
saw
|
| 74 |
+
scissors
|
| 75 |
+
screwdriver
|
| 76 |
+
shorts
|
| 77 |
+
shovel
|
| 78 |
+
smiley_face
|
| 79 |
+
snake
|
| 80 |
+
sock
|
| 81 |
+
spider
|
| 82 |
+
spoon
|
| 83 |
+
square
|
| 84 |
+
star
|
| 85 |
+
stop_sign
|
| 86 |
+
suitcase
|
| 87 |
+
sun
|
| 88 |
+
sword
|
| 89 |
+
syringe
|
| 90 |
+
t-shirt
|
| 91 |
+
table
|
| 92 |
+
tennis_racquet
|
| 93 |
+
tent
|
| 94 |
+
tooth
|
| 95 |
+
traffic_light
|
| 96 |
+
tree
|
| 97 |
+
triangle
|
| 98 |
+
umbrella
|
| 99 |
+
wheel
|
| 100 |
+
wristwatch
|
pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:effb6ea6f1593c09e8247944028ed9c309b5ff1cef82ba38b822bee2ca4d0f3c
|
| 3 |
+
size 1656903
|