Captcha / app.py
Daniel K.Gunleiksrud
comments
5b6f824
import gradio as gr
from fastai.vision.all import *
#this needs to be included for finding file path for some reason
import pathlib
plt = platform.system()
if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath
learn = load_learner('model.pkl')
categories = ('Flower','Sunflower')
def classify(img):
pred,_,probs = learn.predict(img)
return dict(zip(categories, map(float,probs)))
image = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label()
examples = ['0.PNG','1.PNG','2.PNG','3.PNG','4.PNG','5.PNG','6.PNG','7.PNG','8.PNG','9.PNG']
iface = gr.Interface(fn=classify, inputs=image, outputs=label, examples=examples)
iface.launch()