File size: 1,292 Bytes
ce417d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
576618b
ce417d0
 
576618b
ce417d0
 
 
 
 
 
 
 
 
576618b
ce417d0
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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)