jreji/RestNet
1
1{2 "cells": [3 {4 "cell_type": "code",5 "execution_count": 7,6 "id": "fb770960",7 "metadata": {},8 "outputs": [9 {10 "name": "stdout",11 "output_type": "stream",12 "text": [13 "Collecting gradio\n",14 " Downloading gradio-3.16.1-py3-none-any.whl (14.2 MB)\n",15 "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m14.2/14.2 MB\u001b[0m \u001b[31m5.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",16 "\u001b[?25hCollecting altair>=4.2.0\n",17 " Downloading altair-4.2.0-py3-none-any.whl (812 kB)\n",18 "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m812.8/812.8 kB\u001b[0m \u001b[31m5.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n",19 "\u001b[?25hCollecting fastapi\n",20 " Downloading fastapi-0.89.1-py3-none-any.whl (55 kB)\n",21 "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m55.8/55.8 kB\u001b[0m \u001b[31m1.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",22 "\u001b[?25hCollecting orjson\n",23 " Downloading orjson-3.8.5-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (489 kB)\n",24 "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m489.2/489.2 kB\u001b[0m \u001b[31m5.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",25 "\u001b[?25hRequirement already satisfied: matplotlib in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from gradio) (3.5.2)\n",26 "Collecting ffmpy\n",27 " Downloading ffmpy-0.3.0.tar.gz (4.8 kB)\n",28 " Preparing metadata (setup.py) ... \u001b[?25ldone\n",29 "\u001b[?25hRequirement already satisfied: requests in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from gradio) (2.28.1)\n",30 "Collecting markdown-it-py[linkify,plugins]\n",31 " Downloading markdown_it_py-2.1.0-py3-none-any.whl (84 kB)\n",32 "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m84.5/84.5 kB\u001b[0m \u001b[31m2.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",33 "\u001b[?25hCollecting python-multipart\n",34 " Downloading python-multipart-0.0.5.tar.gz (32 kB)\n",35 " Preparing metadata (setup.py) ... \u001b[?25ldone\n",36 "\u001b[?25hCollecting uvicorn\n",37 " Downloading uvicorn-0.20.0-py3-none-any.whl (56 kB)\n",38 "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m56.9/56.9 kB\u001b[0m \u001b[31m2.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",39 "\u001b[?25hRequirement already satisfied: numpy in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from gradio) (1.21.5)\n",40 "Requirement already satisfied: typing-extensions in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from gradio) (4.3.0)\n",41 "Requirement already satisfied: pyyaml in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from gradio) (6.0)\n",42 "Collecting pydub\n",43 " Downloading pydub-0.25.1-py2.py3-none-any.whl (32 kB)\n",44 "Requirement already satisfied: markupsafe in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from gradio) (2.0.1)\n",45 "Collecting websockets>=10.0\n",46 " Downloading websockets-10.4-cp39-cp39-macosx_10_9_x86_64.whl (97 kB)\n",47 "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m97.9/97.9 kB\u001b[0m \u001b[31m3.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",48 "\u001b[?25hRequirement already satisfied: pydantic in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from gradio) (1.10.4)\n",49 "Collecting aiohttp\n",50 " Downloading aiohttp-3.8.3-cp39-cp39-macosx_10_9_x86_64.whl (360 kB)\n",51 "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m360.7/360.7 kB\u001b[0m \u001b[31m5.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n",52 "\u001b[?25hCollecting httpx\n",53 " Downloading httpx-0.23.3-py3-none-any.whl (71 kB)\n",54 "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m71.5/71.5 kB\u001b[0m \u001b[31m2.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",55 "\u001b[?25hRequirement already satisfied: pandas in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from gradio) (1.4.4)\n",56 "Collecting pycryptodome\n",57 " Downloading pycryptodome-3.16.0-cp35-abi3-macosx_10_9_x86_64.whl (1.6 MB)\n",58 "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.6/1.6 MB\u001b[0m \u001b[31m6.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0mm\n",59 "\u001b[?25hRequirement already satisfied: pillow in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from gradio) (9.2.0)\n",60 "Requirement already satisfied: jinja2 in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from gradio) (2.11.3)\n",61 "Requirement already satisfied: fsspec in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from gradio) (2022.7.1)\n",62 "Requirement already satisfied: entrypoints in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from altair>=4.2.0->gradio) (0.4)\n",63 "Requirement already satisfied: jsonschema>=3.0 in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from altair>=4.2.0->gradio) (4.16.0)\n",64 "Requirement already satisfied: toolz in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from altair>=4.2.0->gradio) (0.11.2)\n",65 "Requirement already satisfied: python-dateutil>=2.8.1 in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from pandas->gradio) (2.8.2)\n",66 "Requirement already satisfied: pytz>=2020.1 in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from pandas->gradio) (2022.1)\n",67 "Requirement already satisfied: charset-normalizer<3.0,>=2.0 in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from aiohttp->gradio) (2.0.4)\n",68 "Collecting async-timeout<5.0,>=4.0.0a3\n",69 " Downloading async_timeout-4.0.2-py3-none-any.whl (5.8 kB)\n",70 "Collecting yarl<2.0,>=1.0\n",71 " Downloading yarl-1.8.2-cp39-cp39-macosx_10_9_x86_64.whl (61 kB)\n",72 "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m61.2/61.2 kB\u001b[0m \u001b[31m2.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",73 "\u001b[?25hCollecting aiosignal>=1.1.2\n",74 " Downloading aiosignal-1.3.1-py3-none-any.whl (7.6 kB)\n",75 "Collecting frozenlist>=1.1.1\n",76 " Downloading frozenlist-1.3.3-cp39-cp39-macosx_10_9_x86_64.whl (36 kB)\n",77 "Requirement already satisfied: attrs>=17.3.0 in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from aiohttp->gradio) (21.4.0)\n",78 "Collecting multidict<7.0,>=4.5\n",79 " Downloading multidict-6.0.4-cp39-cp39-macosx_10_9_x86_64.whl (29 kB)\n",80 "Collecting starlette==0.22.0\n",81 " Downloading starlette-0.22.0-py3-none-any.whl (64 kB)\n",82 "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m64.3/64.3 kB\u001b[0m \u001b[31m2.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",83 "\u001b[?25hRequirement already satisfied: anyio<5,>=3.4.0 in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from starlette==0.22.0->fastapi->gradio) (3.5.0)\n",84 "Requirement already satisfied: certifi in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from httpx->gradio) (2022.9.24)\n",85 "Collecting rfc3986[idna2008]<2,>=1.3\n",86 " Downloading rfc3986-1.5.0-py2.py3-none-any.whl (31 kB)\n",87 "Requirement already satisfied: sniffio in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from httpx->gradio) (1.2.0)\n",88 "Collecting httpcore<0.17.0,>=0.15.0\n",89 " Downloading httpcore-0.16.3-py3-none-any.whl (69 kB)\n",90 "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m69.6/69.6 kB\u001b[0m \u001b[31m2.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",91 "\u001b[?25hCollecting mdurl~=0.1\n",92 " Downloading mdurl-0.1.2-py3-none-any.whl (10.0 kB)\n",93 "Collecting mdit-py-plugins\n",94 " Downloading mdit_py_plugins-0.3.3-py3-none-any.whl (50 kB)\n",95 "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m50.5/50.5 kB\u001b[0m \u001b[31m1.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",96 "\u001b[?25hCollecting linkify-it-py~=1.0\n",97 " Downloading linkify_it_py-1.0.3-py3-none-any.whl (19 kB)\n",98 "Requirement already satisfied: pyparsing>=2.2.1 in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from matplotlib->gradio) (3.0.9)\n",99 "Requirement already satisfied: kiwisolver>=1.0.1 in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from matplotlib->gradio) (1.4.2)\n",100 "Requirement already satisfied: fonttools>=4.22.0 in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from matplotlib->gradio) (4.25.0)\n",101 "Requirement already satisfied: cycler>=0.10 in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from matplotlib->gradio) (0.11.0)\n",102 "Requirement already satisfied: packaging>=20.0 in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from matplotlib->gradio) (21.3)\n",103 "Requirement already satisfied: six>=1.4.0 in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from python-multipart->gradio) (1.16.0)\n",104 "Requirement already satisfied: idna<4,>=2.5 in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from requests->gradio) (3.3)\n",105 "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from requests->gradio) (1.26.11)\n",106 "Collecting h11>=0.8\n",107 " Downloading h11-0.14.0-py3-none-any.whl (58 kB)\n",108 "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m58.3/58.3 kB\u001b[0m \u001b[31m1.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",109 "\u001b[?25hRequirement already satisfied: click>=7.0 in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from uvicorn->gradio) (8.0.4)\n"110 ]111 },112 {113 "name": "stdout",114 "output_type": "stream",115 "text": [116 "Requirement already satisfied: pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 in /Users/joelreji/opt/anaconda3/lib/python3.9/site-packages (from jsonschema>=3.0->altair>=4.2.0->gradio) (0.18.0)\n",117 "Collecting uc-micro-py\n",118 " Downloading uc_micro_py-1.0.1-py3-none-any.whl (6.2 kB)\n",119 "Building wheels for collected packages: ffmpy, python-multipart\n",120 " Building wheel for ffmpy (setup.py) ... \u001b[?25ldone\n",121 "\u001b[?25h Created wheel for ffmpy: filename=ffmpy-0.3.0-py3-none-any.whl size=4693 sha256=d553dfefac2deb39111f938631f5485039cae467932da62ba761868bc2e6e5f8\n",122 " Stored in directory: /Users/joelreji/Library/Caches/pip/wheels/91/e2/96/f676aa08bfd789328c6576cd0f1fde4a3d686703bb0c247697\n",123 " Building wheel for python-multipart (setup.py) ... \u001b[?25ldone\n",124 "\u001b[?25h Created wheel for python-multipart: filename=python_multipart-0.0.5-py3-none-any.whl size=31671 sha256=c18d4225fca1b42560a88ad68202d54c5f35f25cf20d121c31510c94627fa174\n",125 " Stored in directory: /Users/joelreji/Library/Caches/pip/wheels/fe/04/d1/a10661cc45f03c3cecda50deb2d2c22f57b4e84a75b2a5987e\n",126 "Successfully built ffmpy python-multipart\n",127 "Installing collected packages: rfc3986, pydub, ffmpy, websockets, uc-micro-py, python-multipart, pycryptodome, orjson, multidict, mdurl, h11, frozenlist, async-timeout, yarl, uvicorn, starlette, markdown-it-py, linkify-it-py, httpcore, aiosignal, mdit-py-plugins, httpx, fastapi, altair, aiohttp, gradio\n",128 "Successfully installed aiohttp-3.8.3 aiosignal-1.3.1 altair-4.2.0 async-timeout-4.0.2 fastapi-0.89.1 ffmpy-0.3.0 frozenlist-1.3.3 gradio-3.16.1 h11-0.14.0 httpcore-0.16.3 httpx-0.23.3 linkify-it-py-1.0.3 markdown-it-py-2.1.0 mdit-py-plugins-0.3.3 mdurl-0.1.2 multidict-6.0.4 orjson-3.8.5 pycryptodome-3.16.0 pydub-0.25.1 python-multipart-0.0.5 rfc3986-1.5.0 starlette-0.22.0 uc-micro-py-1.0.1 uvicorn-0.20.0 websockets-10.4 yarl-1.8.2\n"129 ]130 }131 ],132 "source": [133 "!pip install gradio\n",134 "from fastai.vision.all import *\n",135 "import gradio as gr"136 ]137 },138 {139 "cell_type": "markdown",140 "id": "583662a9",141 "metadata": {},142 "source": [143 "# Train resnet50 Neural Net on the pet images "144 ]145 },146 {147 "cell_type": "code",148 "execution_count": 2,149 "id": "b4a28ca9",150 "metadata": {},151 "outputs": [152 {153 "name": "stderr",154 "output_type": "stream",155 "text": [156 "/Users/joelreji/opt/anaconda3/lib/python3.9/site-packages/torchvision/models/_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and may be removed in the future, please use 'weights' instead.\n",157 " warnings.warn(\n",158 "/Users/joelreji/opt/anaconda3/lib/python3.9/site-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing `weights=ResNet50_Weights.IMAGENET1K_V1`. You can also use `weights=ResNet50_Weights.DEFAULT` to get the most up-to-date weights.\n",159 " warnings.warn(msg)\n",160 "[W NNPACK.cpp:53] Could not initialize NNPACK! Reason: Unsupported hardware.\n"161 ]162 },163 {164 "data": {165 "text/html": [166 "\n",167 "<style>\n",168 " /* Turns off some styling */\n",169 " progress {\n",170 " /* gets rid of default border in Firefox and Opera. */\n",171 " border: none;\n",172 " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",173 " background-size: auto;\n",174 " }\n",175 " progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",176 " background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",177 " }\n",178 " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",179 " background: #F44336;\n",180 " }\n",181 "</style>\n"182 ],183 "text/plain": [184 "<IPython.core.display.HTML object>"185 ]186 },187 "metadata": {},188 "output_type": "display_data"189 },190 {191 "data": {192 "text/html": [193 "<table border=\"1\" class=\"dataframe\">\n",194 " <thead>\n",195 " <tr style=\"text-align: left;\">\n",196 " <th>epoch</th>\n",197 " <th>train_loss</th>\n",198 " <th>valid_loss</th>\n",199 " <th>accuracy</th>\n",200 " <th>time</th>\n",201 " </tr>\n",202 " </thead>\n",203 " <tbody>\n",204 " <tr>\n",205 " <td>0</td>\n",206 " <td>1.007373</td>\n",207 " <td>0.315782</td>\n",208 " <td>0.894452</td>\n",209 " <td>19:25</td>\n",210 " </tr>\n",211 " </tbody>\n",212 "</table>"213 ],214 "text/plain": [215 "<IPython.core.display.HTML object>"216 ]217 },218 "metadata": {},219 "output_type": "display_data"220 },221 {222 "data": {223 "text/html": [224 "\n",225 "<style>\n",226 " /* Turns off some styling */\n",227 " progress {\n",228 " /* gets rid of default border in Firefox and Opera. */\n",229 " border: none;\n",230 " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",231 " background-size: auto;\n",232 " }\n",233 " progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",234 " background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",235 " }\n",236 " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",237 " background: #F44336;\n",238 " }\n",239 "</style>\n"240 ],241 "text/plain": [242 "<IPython.core.display.HTML object>"243 ]244 },245 "metadata": {},246 "output_type": "display_data"247 },248 {249 "data": {250 "text/html": [251 "<table border=\"1\" class=\"dataframe\">\n",252 " <thead>\n",253 " <tr style=\"text-align: left;\">\n",254 " <th>epoch</th>\n",255 " <th>train_loss</th>\n",256 " <th>valid_loss</th>\n",257 " <th>accuracy</th>\n",258 " <th>time</th>\n",259 " </tr>\n",260 " </thead>\n",261 " <tbody>\n",262 " <tr>\n",263 " <td>0</td>\n",264 " <td>0.467073</td>\n",265 " <td>0.262647</td>\n",266 " <td>0.922869</td>\n",267 " <td>26:27</td>\n",268 " </tr>\n",269 " </tbody>\n",270 "</table>"271 ],272 "text/plain": [273 "<IPython.core.display.HTML object>"274 ]275 },276 "metadata": {},277 "output_type": "display_data"278 }279 ],280 "source": [281 "path = untar_data(URLs.PETS)\n",282 "dls = ImageDataLoaders.from_name_re(path, get_image_files(path/'images'), pat='(.+)_\\d+.jpg', item_tfms=Resize(460), \n",283 " batch_tfms=aug_transforms(size=224, min_scale=0.75))\n",284 "learn = vision_learner(dls, models.resnet50, metrics=accuracy)\n",285 "learn.fine_tune(1)\n",286 "learn.path = Path('.')\n",287 "learn.export()"288 ]289 },290 {291 "cell_type": "markdown",292 "id": "5d353326",293 "metadata": {},294 "source": [295 "# Grab pickle file so you dont have to rerun model"296 ]297 },298 {299 "cell_type": "code",300 "execution_count": 5,301 "id": "b821446f",302 "metadata": {},303 "outputs": [],304 "source": [305 "learn = load_learner('export.pkl')"306 ]307 },308 {309 "cell_type": "markdown",310 "id": "97e5aaac",311 "metadata": {},312 "source": [313 "## Function to predict"314 ]315 },316 {317 "cell_type": "code",318 "execution_count": 6,319 "id": "28062741",320 "metadata": {},321 "outputs": [],322 "source": [323 "labels = learn.dls.vocab\n",324 "def predict(img):\n",325 " img = PILImage.create(img)\n",326 " pred,pred_idx,probs = learn.predict(img)\n",327 " return {labels[i]: float(probs[i]) for i in range(len(labels))}"328 ]329 },330 {331 "cell_type": "code",332 "execution_count": 8,333 "id": "47e8248c",334 "metadata": {},335 "outputs": [336 {337 "name": "stderr",338 "output_type": "stream",339 "text": [340 "/Users/joelreji/opt/anaconda3/lib/python3.9/site-packages/gradio/inputs.py:257: UserWarning: Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your component from gradio.components\n",341 " warnings.warn(\n",342 "/Users/joelreji/opt/anaconda3/lib/python3.9/site-packages/gradio/deprecation.py:40: UserWarning: `optional` parameter is deprecated, and it has no effect\n",343 " warnings.warn(value)\n",344 "/Users/joelreji/opt/anaconda3/lib/python3.9/site-packages/gradio/outputs.py:197: UserWarning: Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components\n",345 " warnings.warn(\n",346 "/Users/joelreji/opt/anaconda3/lib/python3.9/site-packages/gradio/deprecation.py:40: UserWarning: The 'type' parameter has been deprecated. Use the Number component instead.\n",347 " warnings.warn(value)\n"348 ]349 },350 {351 "name": "stdout",352 "output_type": "stream",353 "text": [354 "Running on local URL: http://127.0.0.1:7860\n",355 "Running on public URL: https://b041567a-e2e3-4a3c.gradio.live\n",356 "\n",357 "This share link expires in 72 hours. For free permanent hosting and GPU upgrades (NEW!), check out Spaces: https://huggingface.co/spaces\n"358 ]359 },360 {361 "data": {362 "text/html": [363 "<div><iframe src=\"https://b041567a-e2e3-4a3c.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"364 ],365 "text/plain": [366 "<IPython.core.display.HTML object>"367 ]368 },369 "metadata": {},370 "output_type": "display_data"371 },372 {373 "data": {374 "text/plain": []375 },376 "execution_count": 8,377 "metadata": {},378 "output_type": "execute_result"379 },380 {381 "data": {382 "text/html": [383 "\n",384 "<style>\n",385 " /* Turns off some styling */\n",386 " progress {\n",387 " /* gets rid of default border in Firefox and Opera. */\n",388 " border: none;\n",389 " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",390 " background-size: auto;\n",391 " }\n",392 " progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",393 " background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",394 " }\n",395 " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",396 " background: #F44336;\n",397 " }\n",398 "</style>\n"399 ],400 "text/plain": [401 "<IPython.core.display.HTML object>"402 ]403 },404 "metadata": {},405 "output_type": "display_data"406 },407 {408 "data": {409 "text/html": [],410 "text/plain": [411 "<IPython.core.display.HTML object>"412 ]413 },414 "metadata": {},415 "output_type": "display_data"416 },417 {418 "data": {419 "text/html": [420 "\n",421 "<style>\n",422 " /* Turns off some styling */\n",423 " progress {\n",424 " /* gets rid of default border in Firefox and Opera. */\n",425 " border: none;\n",426 " /* Needs to be in here for Safari polyfill so background images work as expected. */\n",427 " background-size: auto;\n",428 " }\n",429 " progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",430 " background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",431 " }\n",432 " .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",433 " background: #F44336;\n",434 " }\n",435 "</style>\n"436 ],437 "text/plain": [438 "<IPython.core.display.HTML object>"439 ]440 },441 "metadata": {},442 "output_type": "display_data"443 },444 {445 "data": {446 "text/html": [],447 "text/plain": [448 "<IPython.core.display.HTML object>"449 ]450 },451 "metadata": {},452 "output_type": "display_data"453 }454 ],455 "source": [456 "gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)).launch(share=True)"457 ]458 },459 {460 "cell_type": "code",461 "execution_count": null,462 "id": "6636da82",463 "metadata": {},464 "outputs": [],465 "source": []466 }467 ],468 "metadata": {469 "kernelspec": {470 "display_name": "Python 3",471 "language": "python",472 "name": "python3"473 },474 "language_info": {475 "codemirror_mode": {476 "name": "ipython",477 "version": 3478 },479 "file_extension": ".py",480 "mimetype": "text/x-python",481 "name": "python",482 "nbconvert_exporter": "python",483 "pygments_lexer": "ipython3",484 "version": "3.9.6 (default, Oct 18 2022, 12:41:40) \n[Clang 14.0.0 (clang-1400.0.29.202)]"485 },486 "vscode": {487 "interpreter": {488 "hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"489 }490 }491 },492 "nbformat": 4,493 "nbformat_minor": 5494}495 