Spaces:
Runtime error
Runtime error
#!/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() | |