first_model / app.py
Jambulat Soltomuradow
fix 3
e44a7bb
raw
history blame contribute delete
642 Bytes
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)