import platform import pathlib plt = platform.system() pathlib.WindowsPath = pathlib.PosixPath import requests # AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb. # %% auto 0 __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'interface', 'classify_image'] # %% app.ipynb 1 from fastai.vision.all import * import PIL.Image PIL.Image.MAX_IMAGE_PIXELS = None from PIL import Image import gradio as gr # %% app.ipynb 2 learn = load_learner('DentalModel.pkl') # %% app.ipynb 3 categories=('Back bridge', 'Complete prosthesis missing all teeth', 'Extraction of root remnants or a tilted wisdom tooth', 'Normal', 'Partial prosthesis (removable) missing 3 or more teeth located next to each other', 'Reprocessing', 'Rotten pulp (periapical lesion) is black around the apex and the decay extends to the nerve', 'The caries restoration did not reach the nerve of the tooth', 'The pulp is not rotten, there is no black around the apex, only the decay has reached the nerve') def classify_image(img): pred,indx,probs=learn.predict(img) return dict(zip(categories,map(float,probs))) # %% app.ipynb 4 image=gr.inputs.Image(shape=(512,512)) label=gr.outputs.Label() interface=gr.Interface(fn=classify_image, inputs=image ,outputs=label) interface.launch(inline=False)