MeghanaM4 commited on
Commit
795c3c9
1 Parent(s): 34c94d2

Delete catvsdog.ipynb

Browse files
Files changed (1) hide show
  1. catvsdog.ipynb +0 -329
catvsdog.ipynb DELETED
@@ -1,329 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": 1,
6
- "metadata": {
7
- "_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19",
8
- "_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5",
9
- "execution": {
10
- "iopub.execute_input": "2024-11-07T16:42:00.042481Z",
11
- "iopub.status.busy": "2024-11-07T16:42:00.042038Z",
12
- "iopub.status.idle": "2024-11-07T16:42:00.536812Z",
13
- "shell.execute_reply": "2024-11-07T16:42:00.535349Z",
14
- "shell.execute_reply.started": "2024-11-07T16:42:00.042436Z"
15
- },
16
- "trusted": true
17
- },
18
- "outputs": [
19
- {
20
- "name": "stdout",
21
- "output_type": "stream",
22
- "text": [
23
- "/kaggle/input/cvd1/pytorch/default/1/model.pkl\n",
24
- "/kaggle/input/dog-jpeg/dog.jpeg\n"
25
- ]
26
- }
27
- ],
28
- "source": [
29
- "# This Python 3 environment comes with many helpful analytics libraries installed\n",
30
- "# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n",
31
- "# For example, here's several helpful packages to load\n",
32
- "\n",
33
- "import numpy as np # linear algebra\n",
34
- "import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n",
35
- "\n",
36
- "# Input data files are available in the read-only \"../input/\" directory\n",
37
- "# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n",
38
- "\n",
39
- "import os\n",
40
- "for dirname, _, filenames in os.walk('/kaggle/input'):\n",
41
- " for filename in filenames:\n",
42
- " print(os.path.join(dirname, filename))\n",
43
- "\n",
44
- "# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n",
45
- "# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session"
46
- ]
47
- },
48
- {
49
- "cell_type": "code",
50
- "execution_count": 2,
51
- "metadata": {
52
- "execution": {
53
- "iopub.execute_input": "2024-11-07T16:42:00.539921Z",
54
- "iopub.status.busy": "2024-11-07T16:42:00.539246Z",
55
- "iopub.status.idle": "2024-11-07T16:42:00.546035Z",
56
- "shell.execute_reply": "2024-11-07T16:42:00.544485Z",
57
- "shell.execute_reply.started": "2024-11-07T16:42:00.539864Z"
58
- },
59
- "trusted": true
60
- },
61
- "outputs": [],
62
- "source": [
63
- "#|default.exp app"
64
- ]
65
- },
66
- {
67
- "cell_type": "code",
68
- "execution_count": 3,
69
- "metadata": {
70
- "_kg_hide-input": true,
71
- "execution": {
72
- "iopub.execute_input": "2024-11-07T16:42:00.548268Z",
73
- "iopub.status.busy": "2024-11-07T16:42:00.547765Z",
74
- "iopub.status.idle": "2024-11-07T16:42:40.346973Z",
75
- "shell.execute_reply": "2024-11-07T16:42:40.345786Z",
76
- "shell.execute_reply.started": "2024-11-07T16:42:00.548214Z"
77
- },
78
- "trusted": true
79
- },
80
- "outputs": [
81
- {
82
- "name": "stdout",
83
- "output_type": "stream",
84
- "text": [
85
- "Collecting gradio\n",
86
- " Downloading gradio-5.5.0-py3-none-any.whl.metadata (16 kB)\n",
87
- "Requirement already satisfied: aiofiles<24.0,>=22.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (22.1.0)\n",
88
- "Requirement already satisfied: anyio<5.0,>=3.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (4.4.0)\n",
89
- "Collecting fastapi<1.0,>=0.115.2 (from gradio)\n",
90
- " Downloading fastapi-0.115.4-py3-none-any.whl.metadata (27 kB)\n",
91
- "Collecting ffmpy (from gradio)\n",
92
- " Downloading ffmpy-0.4.0-py3-none-any.whl.metadata (2.9 kB)\n",
93
- "Collecting gradio-client==1.4.2 (from gradio)\n",
94
- " Downloading gradio_client-1.4.2-py3-none-any.whl.metadata (7.1 kB)\n",
95
- "Requirement already satisfied: httpx>=0.24.1 in /opt/conda/lib/python3.10/site-packages (from gradio) (0.27.0)\n",
96
- "Collecting huggingface-hub>=0.25.1 (from gradio)\n",
97
- " Downloading huggingface_hub-0.26.2-py3-none-any.whl.metadata (13 kB)\n",
98
- "Requirement already satisfied: jinja2<4.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (3.1.4)\n",
99
- "Requirement already satisfied: markupsafe~=2.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (2.1.5)\n",
100
- "Requirement already satisfied: numpy<3.0,>=1.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (1.26.4)\n",
101
- "Requirement already satisfied: orjson~=3.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (3.10.4)\n",
102
- "Requirement already satisfied: packaging in /opt/conda/lib/python3.10/site-packages (from gradio) (21.3)\n",
103
- "Requirement already satisfied: pandas<3.0,>=1.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (2.2.2)\n",
104
- "Requirement already satisfied: pillow<12.0,>=8.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (9.5.0)\n",
105
- "Requirement already satisfied: pydantic>=2.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (2.8.2)\n",
106
- "Requirement already satisfied: pydub in /opt/conda/lib/python3.10/site-packages (from gradio) (0.25.1)\n",
107
- "Collecting python-multipart==0.0.12 (from gradio)\n",
108
- " Downloading python_multipart-0.0.12-py3-none-any.whl.metadata (1.9 kB)\n",
109
- "Requirement already satisfied: pyyaml<7.0,>=5.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (6.0.2)\n",
110
- "Collecting ruff>=0.2.2 (from gradio)\n",
111
- " Downloading ruff-0.7.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (25 kB)\n",
112
- "Collecting safehttpx<1.0,>=0.1.1 (from gradio)\n",
113
- " Downloading safehttpx-0.1.1-py3-none-any.whl.metadata (4.1 kB)\n",
114
- "Collecting semantic-version~=2.0 (from gradio)\n",
115
- " Downloading semantic_version-2.10.0-py2.py3-none-any.whl.metadata (9.7 kB)\n",
116
- "Collecting starlette<1.0,>=0.40.0 (from gradio)\n",
117
- " Downloading starlette-0.41.2-py3-none-any.whl.metadata (6.0 kB)\n",
118
- "Collecting tomlkit==0.12.0 (from gradio)\n",
119
- " Downloading tomlkit-0.12.0-py3-none-any.whl.metadata (2.7 kB)\n",
120
- "Requirement already satisfied: typer<1.0,>=0.12 in /opt/conda/lib/python3.10/site-packages (from gradio) (0.12.3)\n",
121
- "Requirement already satisfied: typing-extensions~=4.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (4.12.2)\n",
122
- "Requirement already satisfied: uvicorn>=0.14.0 in /opt/conda/lib/python3.10/site-packages (from gradio) (0.30.1)\n",
123
- "Requirement already satisfied: fsspec in /opt/conda/lib/python3.10/site-packages (from gradio-client==1.4.2->gradio) (2024.6.1)\n",
124
- "Requirement already satisfied: websockets<13.0,>=10.0 in /opt/conda/lib/python3.10/site-packages (from gradio-client==1.4.2->gradio) (12.0)\n",
125
- "Requirement already satisfied: idna>=2.8 in /opt/conda/lib/python3.10/site-packages (from anyio<5.0,>=3.0->gradio) (3.7)\n",
126
- "Requirement already satisfied: sniffio>=1.1 in /opt/conda/lib/python3.10/site-packages (from anyio<5.0,>=3.0->gradio) (1.3.1)\n",
127
- "Requirement already satisfied: exceptiongroup>=1.0.2 in /opt/conda/lib/python3.10/site-packages (from anyio<5.0,>=3.0->gradio) (1.2.0)\n",
128
- "Requirement already satisfied: certifi in /opt/conda/lib/python3.10/site-packages (from httpx>=0.24.1->gradio) (2024.7.4)\n",
129
- "Requirement already satisfied: httpcore==1.* in /opt/conda/lib/python3.10/site-packages (from httpx>=0.24.1->gradio) (1.0.5)\n",
130
- "Requirement already satisfied: h11<0.15,>=0.13 in /opt/conda/lib/python3.10/site-packages (from httpcore==1.*->httpx>=0.24.1->gradio) (0.14.0)\n",
131
- "Requirement already satisfied: filelock in /opt/conda/lib/python3.10/site-packages (from huggingface-hub>=0.25.1->gradio) (3.15.1)\n",
132
- "Requirement already satisfied: requests in /opt/conda/lib/python3.10/site-packages (from huggingface-hub>=0.25.1->gradio) (2.32.3)\n",
133
- "Requirement already satisfied: tqdm>=4.42.1 in /opt/conda/lib/python3.10/site-packages (from huggingface-hub>=0.25.1->gradio) (4.66.4)\n",
134
- "Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /opt/conda/lib/python3.10/site-packages (from packaging->gradio) (3.1.2)\n",
135
- "Requirement already satisfied: python-dateutil>=2.8.2 in /opt/conda/lib/python3.10/site-packages (from pandas<3.0,>=1.0->gradio) (2.9.0.post0)\n",
136
- "Requirement already satisfied: pytz>=2020.1 in /opt/conda/lib/python3.10/site-packages (from pandas<3.0,>=1.0->gradio) (2024.1)\n",
137
- "Requirement already satisfied: tzdata>=2022.7 in /opt/conda/lib/python3.10/site-packages (from pandas<3.0,>=1.0->gradio) (2024.1)\n",
138
- "Requirement already satisfied: annotated-types>=0.4.0 in /opt/conda/lib/python3.10/site-packages (from pydantic>=2.0->gradio) (0.7.0)\n",
139
- "Requirement already satisfied: pydantic-core==2.20.1 in /opt/conda/lib/python3.10/site-packages (from pydantic>=2.0->gradio) (2.20.1)\n",
140
- "Requirement already satisfied: click>=8.0.0 in /opt/conda/lib/python3.10/site-packages (from typer<1.0,>=0.12->gradio) (8.1.7)\n",
141
- "Requirement already satisfied: shellingham>=1.3.0 in /opt/conda/lib/python3.10/site-packages (from typer<1.0,>=0.12->gradio) (1.5.4)\n",
142
- "Requirement already satisfied: rich>=10.11.0 in /opt/conda/lib/python3.10/site-packages (from typer<1.0,>=0.12->gradio) (13.7.1)\n",
143
- "Requirement already satisfied: six>=1.5 in /opt/conda/lib/python3.10/site-packages (from python-dateutil>=2.8.2->pandas<3.0,>=1.0->gradio) (1.16.0)\n",
144
- "Requirement already satisfied: markdown-it-py>=2.2.0 in /opt/conda/lib/python3.10/site-packages (from rich>=10.11.0->typer<1.0,>=0.12->gradio) (3.0.0)\n",
145
- "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /opt/conda/lib/python3.10/site-packages (from rich>=10.11.0->typer<1.0,>=0.12->gradio) (2.18.0)\n",
146
- "Requirement already satisfied: charset-normalizer<4,>=2 in /opt/conda/lib/python3.10/site-packages (from requests->huggingface-hub>=0.25.1->gradio) (3.3.2)\n",
147
- "Requirement already satisfied: urllib3<3,>=1.21.1 in /opt/conda/lib/python3.10/site-packages (from requests->huggingface-hub>=0.25.1->gradio) (1.26.18)\n",
148
- "Requirement already satisfied: mdurl~=0.1 in /opt/conda/lib/python3.10/site-packages (from markdown-it-py>=2.2.0->rich>=10.11.0->typer<1.0,>=0.12->gradio) (0.1.2)\n",
149
- "Downloading gradio-5.5.0-py3-none-any.whl (56.7 MB)\n",
150
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m56.7/56.7 MB\u001b[0m \u001b[31m23.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m:00:01\u001b[0m00:01\u001b[0m\n",
151
- "\u001b[?25hDownloading gradio_client-1.4.2-py3-none-any.whl (319 kB)\n",
152
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m319.8/319.8 kB\u001b[0m \u001b[31m16.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
153
- "\u001b[?25hDownloading python_multipart-0.0.12-py3-none-any.whl (23 kB)\n",
154
- "Downloading tomlkit-0.12.0-py3-none-any.whl (37 kB)\n",
155
- "Downloading fastapi-0.115.4-py3-none-any.whl (94 kB)\n",
156
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m94.7/94.7 kB\u001b[0m \u001b[31m5.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
157
- "\u001b[?25hDownloading huggingface_hub-0.26.2-py3-none-any.whl (447 kB)\n",
158
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m447.5/447.5 kB\u001b[0m \u001b[31m22.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
159
- "\u001b[?25hDownloading ruff-0.7.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.0 MB)\n",
160
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m11.0/11.0 MB\u001b[0m \u001b[31m73.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m:00:01\u001b[0m0:01\u001b[0m\n",
161
- "\u001b[?25hDownloading safehttpx-0.1.1-py3-none-any.whl (8.4 kB)\n",
162
- "Downloading semantic_version-2.10.0-py2.py3-none-any.whl (15 kB)\n",
163
- "Downloading starlette-0.41.2-py3-none-any.whl (73 kB)\n",
164
- "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m73.3/73.3 kB\u001b[0m \u001b[31m4.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
165
- "\u001b[?25hDownloading ffmpy-0.4.0-py3-none-any.whl (5.8 kB)\n",
166
- "Installing collected packages: tomlkit, semantic-version, ruff, python-multipart, ffmpy, starlette, huggingface-hub, safehttpx, gradio-client, fastapi, gradio\n",
167
- " Attempting uninstall: tomlkit\n",
168
- " Found existing installation: tomlkit 0.13.2\n",
169
- " Uninstalling tomlkit-0.13.2:\n",
170
- " Successfully uninstalled tomlkit-0.13.2\n",
171
- " Attempting uninstall: python-multipart\n",
172
- " Found existing installation: python-multipart 0.0.9\n",
173
- " Uninstalling python-multipart-0.0.9:\n",
174
- " Successfully uninstalled python-multipart-0.0.9\n",
175
- " Attempting uninstall: starlette\n",
176
- " Found existing installation: starlette 0.37.2\n",
177
- " Uninstalling starlette-0.37.2:\n",
178
- " Successfully uninstalled starlette-0.37.2\n",
179
- " Attempting uninstall: huggingface-hub\n",
180
- " Found existing installation: huggingface-hub 0.24.6\n",
181
- " Uninstalling huggingface-hub-0.24.6:\n",
182
- " Successfully uninstalled huggingface-hub-0.24.6\n",
183
- " Attempting uninstall: fastapi\n",
184
- " Found existing installation: fastapi 0.111.0\n",
185
- " Uninstalling fastapi-0.111.0:\n",
186
- " Successfully uninstalled fastapi-0.111.0\n",
187
- "Successfully installed fastapi-0.115.4 ffmpy-0.4.0 gradio-5.5.0 gradio-client-1.4.2 huggingface-hub-0.26.2 python-multipart-0.0.12 ruff-0.7.2 safehttpx-0.1.1 semantic-version-2.10.0 starlette-0.41.2 tomlkit-0.12.0\n"
188
- ]
189
- }
190
- ],
191
- "source": [
192
- "#|export\n",
193
- "from fastai.vision.all import *\n",
194
- "!pip install gradio\n",
195
- "import gradio as gr\n",
196
- "\n",
197
- "share = True\n",
198
- "def is_cat(x): return x[0].isupper()"
199
- ]
200
- },
201
- {
202
- "cell_type": "code",
203
- "execution_count": 4,
204
- "metadata": {
205
- "execution": {
206
- "iopub.execute_input": "2024-11-07T16:42:40.351150Z",
207
- "iopub.status.busy": "2024-11-07T16:42:40.350198Z",
208
- "iopub.status.idle": "2024-11-07T16:42:40.780869Z",
209
- "shell.execute_reply": "2024-11-07T16:42:40.779627Z",
210
- "shell.execute_reply.started": "2024-11-07T16:42:40.351085Z"
211
- },
212
- "trusted": true
213
- },
214
- "outputs": [],
215
- "source": [
216
- "#|export\n",
217
- "learn = load_learner('/kaggle/input/cvd1/pytorch/default/1/model.pkl')"
218
- ]
219
- },
220
- {
221
- "cell_type": "code",
222
- "execution_count": 5,
223
- "metadata": {
224
- "execution": {
225
- "iopub.execute_input": "2024-11-07T16:42:40.782674Z",
226
- "iopub.status.busy": "2024-11-07T16:42:40.782252Z",
227
- "iopub.status.idle": "2024-11-07T16:42:40.789359Z",
228
- "shell.execute_reply": "2024-11-07T16:42:40.787980Z",
229
- "shell.execute_reply.started": "2024-11-07T16:42:40.782632Z"
230
- },
231
- "trusted": true
232
- },
233
- "outputs": [],
234
- "source": [
235
- "#|export\n",
236
- "categories = ('Dog', 'Cat')\n",
237
- "\n",
238
- "def classify_image(img):\n",
239
- " pred,idx,probs = learn.predict(img)\n",
240
- " return dict(zip(categories, map(float, probs)))"
241
- ]
242
- },
243
- {
244
- "cell_type": "code",
245
- "execution_count": 6,
246
- "metadata": {
247
- "execution": {
248
- "iopub.execute_input": "2024-11-07T16:42:40.791441Z",
249
- "iopub.status.busy": "2024-11-07T16:42:40.791006Z",
250
- "iopub.status.idle": "2024-11-07T16:42:42.246846Z",
251
- "shell.execute_reply": "2024-11-07T16:42:42.245632Z",
252
- "shell.execute_reply.started": "2024-11-07T16:42:40.791400Z"
253
- },
254
- "trusted": true
255
- },
256
- "outputs": [
257
- {
258
- "name": "stdout",
259
- "output_type": "stream",
260
- "text": [
261
- "* Running on local URL: http://127.0.0.1:7860\n",
262
- "* Running on public URL: https://f0396da6689b4b4b39.gradio.live\n",
263
- "\n",
264
- "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from the terminal in the working directory to deploy to Hugging Face Spaces (https://huggingface.co/spaces)\n"
265
- ]
266
- },
267
- {
268
- "data": {
269
- "text/plain": []
270
- },
271
- "execution_count": 6,
272
- "metadata": {},
273
- "output_type": "execute_result"
274
- }
275
- ],
276
- "source": [
277
- "#|export\n",
278
- "image = \"image\"\n",
279
- "label = \"label\"\n",
280
- "\n",
281
- "intf = gr.Interface(fn=classify_image, inputs=image, outputs=label)\n",
282
- "intf.launch(inline=False, share = True)"
283
- ]
284
- }
285
- ],
286
- "metadata": {
287
- "kaggle": {
288
- "accelerator": "none",
289
- "dataSources": [
290
- {
291
- "datasetId": 5660894,
292
- "sourceId": 9340954,
293
- "sourceType": "datasetVersion"
294
- },
295
- {
296
- "isSourceIdPinned": true,
297
- "modelId": 157980,
298
- "modelInstanceId": 135253,
299
- "sourceId": 159107,
300
- "sourceType": "modelInstanceVersion"
301
- }
302
- ],
303
- "dockerImageVersionId": 30761,
304
- "isGpuEnabled": false,
305
- "isInternetEnabled": true,
306
- "language": "python",
307
- "sourceType": "notebook"
308
- },
309
- "kernelspec": {
310
- "display_name": "Python 3",
311
- "language": "python",
312
- "name": "python3"
313
- },
314
- "language_info": {
315
- "codemirror_mode": {
316
- "name": "ipython",
317
- "version": 3
318
- },
319
- "file_extension": ".py",
320
- "mimetype": "text/x-python",
321
- "name": "python",
322
- "nbconvert_exporter": "python",
323
- "pygments_lexer": "ipython3",
324
- "version": "3.10.14"
325
- }
326
- },
327
- "nbformat": 4,
328
- "nbformat_minor": 4
329
- }