Spaces:
Sleeping
Sleeping
File size: 642 Bytes
ef1e94f 3c4e08b 9dc6159 3c4e08b 9dc6159 e44a7bb ef1e94f 486706b ef1e94f 486706b ef1e94f 2accce7 ef1e94f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | from fastai.vision.all import *
import gradio as gr
import os
os.environ["OMP_NUM_THREADS"] = "1"
os.environ["MKL_NUM_THREADS"] = "1"
learn = load_learner('model.pkl', cpu=True)
learn.model.eval()
categories = ('damaged', 'intact')
def classify_image(img):
img = PILImage.create(img)
pred, idx, probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
image = gr.Image(width=192, height=192, type="pil")
label = gr.Label()
examples = ['por.jpeg', 'dam.jpeg', 'damm.jpeg']
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, cache_examples=False)
intf.launch(inline=False) |