Spaces:
Runtime error
Runtime error
File size: 24,210 Bytes
13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 e551c67 13537a7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "18acb717",
"metadata": {},
"outputs": [],
"source": [
"#|default_exp app"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "44eb0ad3",
"metadata": {},
"outputs": [],
"source": [
"#|export\n",
"from fastai.vision.all import *\n",
"import gradio as gr\n",
"\n",
"def is_cat(x): return x[0].isupper()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d838c0b3",
"metadata": {},
"outputs": [],
"source": [
"path = untar_data(URLs.PETS)/'images'\n",
"\n",
"dls = ImageDataLoaders.from_name_func('.',\n",
" get_image_files(path), valid_pct=0.2, seed=42,\n",
" label_func=is_cat,\n",
" item_tfms=Resize(192, method='squish'))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c107f724",
"metadata": {},
"outputs": [],
"source": [
"learn = vision_learner(dls, resnet18, metrics=error_rate)\n",
"learn.fine_tune(3)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bed928f3",
"metadata": {},
"outputs": [],
"source": [
"path = untar_data(URLs.PETS)/'images'\n",
"\n",
"dls = ImageDataLoaders.from_name_func('.',\n",
" get_image_files(path), valid_pct=0.2, seed=42,\n",
" label_func=is_cat,\n",
" item_tfms=Resize(192))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7e56b200",
"metadata": {},
"outputs": [],
"source": [
"learn = vision_learner(dls, resnet18, metrics=error_rate).to_fp16()\n",
"learn.fine_tune(3)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5171c7fc",
"metadata": {},
"outputs": [],
"source": [
"learn.export('model.pkl')"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "3295ef11",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAJUAAADACAIAAACCg7ZcAAAu90lEQVR4nO19W48lR5XuWpG5c19qV1Vf7Op2G9vt4zniImNkzxxjqYWEBEL4jbc5D0i8WTJv/AWE4C/wwk+Y4dUyDJgjGPEAY8M5yMJi3G3axpf2peuyL3mJWOdh7Vh7ZURm1u5qu6u2vZdarazckZER8a1brFgZgUQEG1pbMqfdgA3dFW3wW2/a4Lfet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JBcKFJ4ypl9CtATT+kVdba/f39o6OjoEly0pzwkKhEqVxUi7yXv9D4+te//uyzz371q1+9cOGCTHtOPKR3Snclf0Q0nU4//PBDa+3zzz+/t7f39ttvz+dz9uCzLDt37pxsTM6HoLEukrW6xgveqxRaNlpdnWKnA+snozD1+/3EH2es1bXQYDDgE7z4WN0sywaDwWg0Gg6HV69e/cpXvnLx4kXeXDXYHPce0N3Kn9iJyWRycHAgZydyAMz4vbeZBDlBlG/KBdNsNrt9+zbfZ1bgSR4fw7W7uwv+OxU5GI/UDvZSIV9zk3h2MZvN+D7rQGPM5cuXt7a2hsPh1tYWozIej7e2tra3t3d2dra2tsbjMd/hYoPBIMuy0WjU7/f7/T7vjzsYDE4rXH63/ouQVlOgjIf2/fR6HkQHl0KUpxs4n+QjLPKn8Ip4GdbvPyz4zWYzntvwNTMEq8Fer3fx4sV+v8/ixXLG2GRZlmWZdqPAL29B+45z954+Tvw+uf4IwIE9gzqjkJrgQ9PGyMGD2scJtlM8ti+6PXB6WH5s+G3oVOhs5e9u6E5pg9960wa/9aYNfutNG/zWmzb4rTdt8Ftv2uC33rTBb71pg9960wa/9aYNfutNG/zWmzb4rTdt8Ftv2uC33rTBb71pg9960wa/9aYNfutNG/zWm/4/Lu75XAOAYBUAAAAASUVORK5CYII=",
"text/plain": [
"PILImage mode=RGB size=149x192"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"im = PILImage.create('data_test/dell 20.jpg')\n",
"im.thumbnail((192,192))\n",
"im"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "ae2bc6ac",
"metadata": {},
"outputs": [],
"source": [
"#|export\n",
"learn = load_learner('export.pkl')"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "6e0bf9da",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"('desktop pc', tensor(0), tensor([9.9071e-01, 8.5827e-03, 7.1094e-04]))"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"learn.predict(im)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "0419ed3a",
"metadata": {},
"outputs": [],
"source": [
"#|export\n",
"categories = ('desktop pc','laptop','mobile phone')\n",
"\n",
"def classify_image(img):\n",
" pred,idx,probs = learn.predict(img)\n",
" return dict(zip(categories, map(float,probs)))"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "762dec00",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'desktop pc': 0.9907063841819763,\n",
" 'laptop': 0.00858269166201353,\n",
" 'mobile phone': 0.0007109376601874828}"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"classify_image(im)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "0518a30a",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/demonhunter/mambaforge/lib/python3.10/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",
" warnings.warn(\n",
"/home/demonhunter/mambaforge/lib/python3.10/site-packages/gradio/deprecation.py:40: UserWarning: `optional` parameter is deprecated, and it has no effect\n",
" warnings.warn(value)\n",
"/home/demonhunter/mambaforge/lib/python3.10/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",
" warnings.warn(\n",
"/home/demonhunter/mambaforge/lib/python3.10/site-packages/gradio/deprecation.py:40: UserWarning: The 'type' parameter has been deprecated. Use the Number component instead.\n",
" warnings.warn(value)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running on local URL: http://127.0.0.1:7861\n",
"\n",
"To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/plain": []
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"text/html": [
"\n",
"<style>\n",
" /* Turns off some styling */\n",
" progress {\n",
" /* gets rid of default border in Firefox and Opera. */\n",
" border: none;\n",
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
" background-size: auto;\n",
" }\n",
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
" }\n",
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
" background: #F44336;\n",
" }\n",
"</style>\n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\n",
"<style>\n",
" /* Turns off some styling */\n",
" progress {\n",
" /* gets rid of default border in Firefox and Opera. */\n",
" border: none;\n",
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
" background-size: auto;\n",
" }\n",
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
" }\n",
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
" background: #F44336;\n",
" }\n",
"</style>\n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#|export\n",
"image = gr.inputs.Image(shape=(192, 192))\n",
"label = gr.outputs.Label()\n",
"examples = ['dell 20.jpg', 'dell inspiron.jpg', 'desktop pc on table.jpg']\n",
"\n",
"intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)\n",
"intf.launch(inline=False)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "0d1e90ce",
"metadata": {},
"source": [
"## end -"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|