sswam commited on
Commit
7e19958
1 Parent(s): 45fe99a

add old/app.py, without using nbdev

Browse files
Files changed (1) hide show
  1. old/app.py +25 -0
old/app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
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
+ def predict(img):
10
+ img = PILImage.create(img)
11
+ pred, pred_idx, probs = learn.predict(img)
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 = predict,
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'))),
21
+ interpretation='default',
22
+ enable_queue=True,
23
+ )
24
+
25
+ iface.launch()