File size: 908 Bytes
42318b3
 
b094b57
47f3b84
 
b094b57
 
 
 
 
 
 
 
 
42318b3
 
 
 
 
 
 
 
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
#!/usr/bin/env python3

from fastai.vision.all import *
import gradio as gr

learn = load_learner('photos.pkl')
labels = learn.dls.vocab

def predict(img):
    img = PILImage.create(img)
    pred, pred_idx, probs = learn.predict(img)
    return dict(zip(labels, map(float, probs)))

iface = gr.Interface(
    title = "Photo Checker",
    description = "Check if one of our family photos is good or not. It tries to exclude screenshots, photos of computer screens, photos of papers, images with lots of text, and very blurry images. I intend to use this to separate the good photos for a slide show on our TV. It achieves over 99% accuracy based on my testing.",
    fn = predict,
    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()