Spaces:
Sleeping
Sleeping
Trial 2
Browse files- .ipynb_checkpoints/Untitled-checkpoint.ipynb +6 -0
- Untitled.ipynb +239 -0
- app.py +5 -0
.ipynb_checkpoints/Untitled-checkpoint.ipynb
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [],
|
3 |
+
"metadata": {},
|
4 |
+
"nbformat": 4,
|
5 |
+
"nbformat_minor": 5
|
6 |
+
}
|
Untitled.ipynb
ADDED
@@ -0,0 +1,239 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 2,
|
6 |
+
"id": "e5315266",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"import os \n",
|
11 |
+
"os.environ[\"OMP_NUM_THREADS\"] = \"1\""
|
12 |
+
]
|
13 |
+
},
|
14 |
+
{
|
15 |
+
"cell_type": "code",
|
16 |
+
"execution_count": 3,
|
17 |
+
"id": "e9f649d8",
|
18 |
+
"metadata": {},
|
19 |
+
"outputs": [],
|
20 |
+
"source": [
|
21 |
+
"from fastai.vision.all import *"
|
22 |
+
]
|
23 |
+
},
|
24 |
+
{
|
25 |
+
"cell_type": "code",
|
26 |
+
"execution_count": 4,
|
27 |
+
"id": "544abe8f",
|
28 |
+
"metadata": {},
|
29 |
+
"outputs": [
|
30 |
+
{
|
31 |
+
"name": "stderr",
|
32 |
+
"output_type": "stream",
|
33 |
+
"text": [
|
34 |
+
"/Users/danielching/miniforge3/envs/fastai/lib/python3.10/site-packages/fastbook/__init__.py:11: UserWarning: Missing `ipywidgets` - please install it\n",
|
35 |
+
" except ModuleNotFoundError: warn(\"Missing `ipywidgets` - please install it\")\n"
|
36 |
+
]
|
37 |
+
}
|
38 |
+
],
|
39 |
+
"source": [
|
40 |
+
"import fastbook"
|
41 |
+
]
|
42 |
+
},
|
43 |
+
{
|
44 |
+
"cell_type": "code",
|
45 |
+
"execution_count": 5,
|
46 |
+
"id": "e1df0cec",
|
47 |
+
"metadata": {},
|
48 |
+
"outputs": [],
|
49 |
+
"source": [
|
50 |
+
"from fastbook import *"
|
51 |
+
]
|
52 |
+
},
|
53 |
+
{
|
54 |
+
"cell_type": "code",
|
55 |
+
"execution_count": 6,
|
56 |
+
"id": "a837a058",
|
57 |
+
"metadata": {},
|
58 |
+
"outputs": [],
|
59 |
+
"source": [
|
60 |
+
"fastbook.setup_book()"
|
61 |
+
]
|
62 |
+
},
|
63 |
+
{
|
64 |
+
"cell_type": "code",
|
65 |
+
"execution_count": null,
|
66 |
+
"id": "7fb42101",
|
67 |
+
"metadata": {},
|
68 |
+
"outputs": [
|
69 |
+
{
|
70 |
+
"name": "stdout",
|
71 |
+
"output_type": "stream",
|
72 |
+
"text": [
|
73 |
+
"Downloading a new version of this dataset...\n"
|
74 |
+
]
|
75 |
+
},
|
76 |
+
{
|
77 |
+
"data": {
|
78 |
+
"text/html": [
|
79 |
+
"\n",
|
80 |
+
"<style>\n",
|
81 |
+
" /* Turns off some styling */\n",
|
82 |
+
" progress {\n",
|
83 |
+
" /* gets rid of default border in Firefox and Opera. */\n",
|
84 |
+
" border: none;\n",
|
85 |
+
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
86 |
+
" background-size: auto;\n",
|
87 |
+
" }\n",
|
88 |
+
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
|
89 |
+
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
|
90 |
+
" }\n",
|
91 |
+
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
92 |
+
" background: #F44336;\n",
|
93 |
+
" }\n",
|
94 |
+
"</style>\n"
|
95 |
+
],
|
96 |
+
"text/plain": [
|
97 |
+
"<IPython.core.display.HTML object>"
|
98 |
+
]
|
99 |
+
},
|
100 |
+
"metadata": {},
|
101 |
+
"output_type": "display_data"
|
102 |
+
},
|
103 |
+
{
|
104 |
+
"data": {
|
105 |
+
"text/html": [
|
106 |
+
"\n",
|
107 |
+
" <div>\n",
|
108 |
+
" <progress value='811712512' class='' max='811706944' style='width:300px; height:20px; vertical-align: middle;'></progress>\n",
|
109 |
+
" 100.00% [811712512/811706944 01:51<00:00]\n",
|
110 |
+
" </div>\n",
|
111 |
+
" "
|
112 |
+
],
|
113 |
+
"text/plain": [
|
114 |
+
"<IPython.core.display.HTML object>"
|
115 |
+
]
|
116 |
+
},
|
117 |
+
"metadata": {},
|
118 |
+
"output_type": "display_data"
|
119 |
+
},
|
120 |
+
{
|
121 |
+
"name": "stderr",
|
122 |
+
"output_type": "stream",
|
123 |
+
"text": [
|
124 |
+
"/Users/danielching/miniforge3/envs/fastai/lib/python3.10/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",
|
125 |
+
" warnings.warn(\n",
|
126 |
+
"/Users/danielching/miniforge3/envs/fastai/lib/python3.10/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=ResNet34_Weights.IMAGENET1K_V1`. You can also use `weights=ResNet34_Weights.DEFAULT` to get the most up-to-date weights.\n",
|
127 |
+
" warnings.warn(msg)\n",
|
128 |
+
"Downloading: \"https://download.pytorch.org/models/resnet34-b627a593.pth\" to /Users/danielching/.cache/torch/hub/checkpoints/resnet34-b627a593.pth\n",
|
129 |
+
"100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 83.3M/83.3M [00:09<00:00, 8.84MB/s]\n"
|
130 |
+
]
|
131 |
+
},
|
132 |
+
{
|
133 |
+
"data": {
|
134 |
+
"text/html": [
|
135 |
+
"\n",
|
136 |
+
"<style>\n",
|
137 |
+
" /* Turns off some styling */\n",
|
138 |
+
" progress {\n",
|
139 |
+
" /* gets rid of default border in Firefox and Opera. */\n",
|
140 |
+
" border: none;\n",
|
141 |
+
" /* Needs to be in here for Safari polyfill so background images work as expected. */\n",
|
142 |
+
" background-size: auto;\n",
|
143 |
+
" }\n",
|
144 |
+
" progress:not([value]), progress:not([value])::-webkit-progress-bar {\n",
|
145 |
+
" background: repeating-linear-gradient(45deg, #7e7e7e, #7e7e7e 10px, #5c5c5c 10px, #5c5c5c 20px);\n",
|
146 |
+
" }\n",
|
147 |
+
" .progress-bar-interrupted, .progress-bar-interrupted::-webkit-progress-bar {\n",
|
148 |
+
" background: #F44336;\n",
|
149 |
+
" }\n",
|
150 |
+
"</style>\n"
|
151 |
+
],
|
152 |
+
"text/plain": [
|
153 |
+
"<IPython.core.display.HTML object>"
|
154 |
+
]
|
155 |
+
},
|
156 |
+
"metadata": {},
|
157 |
+
"output_type": "display_data"
|
158 |
+
},
|
159 |
+
{
|
160 |
+
"data": {
|
161 |
+
"text/html": [
|
162 |
+
"\n",
|
163 |
+
" <div>\n",
|
164 |
+
" <progress value='0' class='' max='1' style='width:300px; height:20px; vertical-align: middle;'></progress>\n",
|
165 |
+
" 0.00% [0/1 00:00<?]\n",
|
166 |
+
" </div>\n",
|
167 |
+
" \n",
|
168 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
169 |
+
" <thead>\n",
|
170 |
+
" <tr style=\"text-align: left;\">\n",
|
171 |
+
" <th>epoch</th>\n",
|
172 |
+
" <th>train_loss</th>\n",
|
173 |
+
" <th>valid_loss</th>\n",
|
174 |
+
" <th>error_rate</th>\n",
|
175 |
+
" <th>time</th>\n",
|
176 |
+
" </tr>\n",
|
177 |
+
" </thead>\n",
|
178 |
+
" <tbody>\n",
|
179 |
+
" </tbody>\n",
|
180 |
+
"</table><p>\n",
|
181 |
+
"\n",
|
182 |
+
" <div>\n",
|
183 |
+
" <progress value='26' class='' max='92' style='width:300px; height:20px; vertical-align: middle;'></progress>\n",
|
184 |
+
" 28.26% [26/92 04:09<10:33 0.7969]\n",
|
185 |
+
" </div>\n",
|
186 |
+
" "
|
187 |
+
],
|
188 |
+
"text/plain": [
|
189 |
+
"<IPython.core.display.HTML object>"
|
190 |
+
]
|
191 |
+
},
|
192 |
+
"metadata": {},
|
193 |
+
"output_type": "display_data"
|
194 |
+
}
|
195 |
+
],
|
196 |
+
"source": [
|
197 |
+
"from fastai.vision.all import *\n",
|
198 |
+
"path = untar_data(URLs.PETS)/'images'\n",
|
199 |
+
"\n",
|
200 |
+
"def is_cat(x): return x[0].isupper()\n",
|
201 |
+
"dls = ImageDataLoaders.from_name_func(\n",
|
202 |
+
" path, get_image_files(path), valid_pct=0.2, seed=42,\n",
|
203 |
+
" label_func=is_cat, item_tfms=Resize(224))\n",
|
204 |
+
"\n",
|
205 |
+
"learn = vision_learner(dls, resnet34, metrics=error_rate)\n",
|
206 |
+
"learn.fine_tune(1)"
|
207 |
+
]
|
208 |
+
},
|
209 |
+
{
|
210 |
+
"cell_type": "code",
|
211 |
+
"execution_count": null,
|
212 |
+
"id": "cbbe5c41",
|
213 |
+
"metadata": {},
|
214 |
+
"outputs": [],
|
215 |
+
"source": []
|
216 |
+
}
|
217 |
+
],
|
218 |
+
"metadata": {
|
219 |
+
"kernelspec": {
|
220 |
+
"display_name": "Python 3 (ipykernel)",
|
221 |
+
"language": "python",
|
222 |
+
"name": "python3"
|
223 |
+
},
|
224 |
+
"language_info": {
|
225 |
+
"codemirror_mode": {
|
226 |
+
"name": "ipython",
|
227 |
+
"version": 3
|
228 |
+
},
|
229 |
+
"file_extension": ".py",
|
230 |
+
"mimetype": "text/x-python",
|
231 |
+
"name": "python",
|
232 |
+
"nbconvert_exporter": "python",
|
233 |
+
"pygments_lexer": "ipython3",
|
234 |
+
"version": "3.10.4"
|
235 |
+
}
|
236 |
+
},
|
237 |
+
"nbformat": 4,
|
238 |
+
"nbformat_minor": 5
|
239 |
+
}
|
app.py
CHANGED
@@ -1,5 +1,10 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
from fastai.vision.all import *
|
|
|
|
|
|
|
3 |
_all_ = ['is_cat', 'learn', 'classify_image',
|
4 |
'categories', 'image', 'label', 'examples', 'intf']
|
5 |
|
|
|
1 |
import gradio as gr
|
2 |
+
import os
|
3 |
+
import fastai
|
4 |
from fastai.vision.all import *
|
5 |
+
|
6 |
+
|
7 |
+
os.environ["OMP_NUM_THREADS"] = "1"
|
8 |
_all_ = ['is_cat', 'learn', 'classify_image',
|
9 |
'categories', 'image', 'label', 'examples', 'intf']
|
10 |
|