Spaces:
Runtime error
Runtime error
use nbdev2, working now
Browse files- app.py +15 -5
- photo-checker.ipynb +18 -18
app.py
CHANGED
@@ -1,20 +1,30 @@
|
|
1 |
-
|
2 |
|
|
|
|
|
|
|
|
|
3 |
from fastai.vision.all import *
|
4 |
-
import gradio as gr
|
5 |
|
|
|
6 |
learn = load_learner('photos.pkl')
|
|
|
|
|
7 |
labels = learn.dls.vocab
|
8 |
|
9 |
-
|
|
|
10 |
img = PILImage.create(img)
|
11 |
-
pred,
|
12 |
return dict(zip(labels, map(float, probs)))
|
13 |
|
|
|
|
|
|
|
14 |
iface = gr.Interface(
|
15 |
title = "Photo Checker",
|
16 |
description = """This project checks which of our family photos are "good" or "bad". We have nearly 80,000 photos, so it's not practical to sort them out by hand. I want to exclude screenshots, photos of computer screens, photos of papers, images with lots of text, and very blurry images. I used this to separate the good photos to use for a random slide show on our TV. The trained model achieves around 99% accuracy on the validation set.""",
|
17 |
-
fn =
|
18 |
inputs = gr.inputs.Image(shape = (512,512)),
|
19 |
outputs = gr.outputs.Label(num_top_classes = 3),
|
20 |
examples = list(map(str, get_image_files('eg'))),
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: photo-checker.ipynb.
|
2 |
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['learn', 'labels', 'iface', 'classify_image']
|
5 |
+
|
6 |
+
# %% photo-checker.ipynb 5
|
7 |
from fastai.vision.all import *
|
|
|
8 |
|
9 |
+
# %% photo-checker.ipynb 36
|
10 |
learn = load_learner('photos.pkl')
|
11 |
+
|
12 |
+
# %% photo-checker.ipynb 58
|
13 |
labels = learn.dls.vocab
|
14 |
|
15 |
+
# %% photo-checker.ipynb 60
|
16 |
+
def classify_image(img):
|
17 |
img = PILImage.create(img)
|
18 |
+
pred,idx,probs = learn.predict(img)
|
19 |
return dict(zip(labels, map(float, probs)))
|
20 |
|
21 |
+
# %% photo-checker.ipynb 61
|
22 |
+
import gradio as gr
|
23 |
+
|
24 |
iface = gr.Interface(
|
25 |
title = "Photo Checker",
|
26 |
description = """This project checks which of our family photos are "good" or "bad". We have nearly 80,000 photos, so it's not practical to sort them out by hand. I want to exclude screenshots, photos of computer screens, photos of papers, images with lots of text, and very blurry images. I used this to separate the good photos to use for a random slide show on our TV. The trained model achieves around 99% accuracy on the validation set.""",
|
27 |
+
fn = classify_image,
|
28 |
inputs = gr.inputs.Image(shape = (512,512)),
|
29 |
outputs = gr.outputs.Label(num_top_classes = 3),
|
30 |
examples = list(map(str, get_image_files('eg'))),
|
photo-checker.ipynb
CHANGED
@@ -36,7 +36,7 @@
|
|
36 |
},
|
37 |
{
|
38 |
"cell_type": "code",
|
39 |
-
"execution_count":
|
40 |
"metadata": {
|
41 |
"tags": []
|
42 |
},
|
@@ -48,7 +48,7 @@
|
|
48 |
},
|
49 |
{
|
50 |
"cell_type": "code",
|
51 |
-
"execution_count":
|
52 |
"metadata": {},
|
53 |
"outputs": [],
|
54 |
"source": [
|
@@ -58,7 +58,7 @@
|
|
58 |
},
|
59 |
{
|
60 |
"cell_type": "code",
|
61 |
-
"execution_count":
|
62 |
"metadata": {
|
63 |
"tags": []
|
64 |
},
|
@@ -1293,28 +1293,28 @@
|
|
1293 |
},
|
1294 |
{
|
1295 |
"cell_type": "code",
|
1296 |
-
"execution_count":
|
1297 |
"metadata": {},
|
1298 |
-
"outputs": [
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
}
|
1309 |
-
],
|
1310 |
"source": [
|
1311 |
"from nbdev.export import nb_export\n",
|
1312 |
-
"nb_export('photo-checker.ipynb')"
|
1313 |
]
|
1314 |
},
|
1315 |
{
|
1316 |
-
"cell_type": "
|
|
|
1317 |
"metadata": {},
|
|
|
1318 |
"source": []
|
1319 |
}
|
1320 |
],
|
|
|
36 |
},
|
37 |
{
|
38 |
"cell_type": "code",
|
39 |
+
"execution_count": 9,
|
40 |
"metadata": {
|
41 |
"tags": []
|
42 |
},
|
|
|
48 |
},
|
49 |
{
|
50 |
"cell_type": "code",
|
51 |
+
"execution_count": 10,
|
52 |
"metadata": {},
|
53 |
"outputs": [],
|
54 |
"source": [
|
|
|
58 |
},
|
59 |
{
|
60 |
"cell_type": "code",
|
61 |
+
"execution_count": 11,
|
62 |
"metadata": {
|
63 |
"tags": []
|
64 |
},
|
|
|
1293 |
},
|
1294 |
{
|
1295 |
"cell_type": "code",
|
1296 |
+
"execution_count": 12,
|
1297 |
"metadata": {},
|
1298 |
+
"outputs": [],
|
1299 |
+
"source": [
|
1300 |
+
"#| default_exp app"
|
1301 |
+
]
|
1302 |
+
},
|
1303 |
+
{
|
1304 |
+
"cell_type": "code",
|
1305 |
+
"execution_count": 13,
|
1306 |
+
"metadata": {},
|
1307 |
+
"outputs": [],
|
|
|
|
|
1308 |
"source": [
|
1309 |
"from nbdev.export import nb_export\n",
|
1310 |
+
"nb_export('photo-checker.ipynb', '.')"
|
1311 |
]
|
1312 |
},
|
1313 |
{
|
1314 |
+
"cell_type": "code",
|
1315 |
+
"execution_count": null,
|
1316 |
"metadata": {},
|
1317 |
+
"outputs": [],
|
1318 |
"source": []
|
1319 |
}
|
1320 |
],
|