File size: 1,256 Bytes
45fe99a
42318b3
45fe99a
 
 
 
b094b57
47f3b84
45fe99a
b094b57
45fe99a
 
b094b57
 
45fe99a
 
15d5167
45fe99a
15d5167
b094b57
45fe99a
 
 
b094b57
15d5167
 
45fe99a
15d5167
 
 
 
 
b094b57
47f3b84
 
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
# AUTOGENERATED! DO NOT EDIT! File to edit: photo-checker.ipynb.

# %% auto 0
__all__ = ['learn', 'labels', 'iface', 'classify_image']

# %% photo-checker.ipynb 5
from fastai.vision.all import *

# %% photo-checker.ipynb 36
learn = load_learner('photos.pkl')

# %% photo-checker.ipynb 58
labels = learn.dls.vocab

# %% photo-checker.ipynb 60
def classify_image(img):
	img = PILImage.create(img)
	pred,idx,probs = learn.predict(img)
	return dict(zip(labels, map(float, probs)))

# %% photo-checker.ipynb 61
import gradio as gr

iface = gr.Interface(
	title = "Photo Checker",
	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.""",
	fn = classify_image,
	inputs = gr.inputs.Image(shape = (512,512)),
	outputs = gr.outputs.Label(num_top_classes = 3),
	examples = list(map(str, get_image_files('eg'))),
	interpretation='default',
	enable_queue=True,
)

iface.launch()