| import gradio as gr | |
| from fastai.vision.all import * | |
| import numpy as np | |
| import pathlib | |
| plt = platform.system() | |
| if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath | |
| learn = load_learner('dense_model.pkl') | |
| def classify_image(img): | |
| img = np.array(img) | |
| pred, idx, probs = learn.predict(img) | |
| return pred | |
| image = gr.inputs.Image(shape=(224,224)) | |
| label = gr.outputs.Label() | |
| intf = gr.Interface(fn=classify_image, inputs=image, outputs=label) | |
| intf.launch(inline=False) |