File size: 881 Bytes
03d3c63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4a563e7
510c8df
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from fastai.vision.all import *
from huggingface_hub import from_pretrained_fastai

import pathlib
plt = platform.system()
if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath

learn = from_pretrained_fastai(repo_id = "KathrynMercer/BoneClassifier")

labels = learn.dls.vocab
def predict(img):
    img = PILImage.create(img)
    pred,pred_idx,probs = learn.predict(img)
    return {labels[i].title(): float(probs[i]) for i in range(len(labels))}

gr.Interface(fn=predict, 
             inputs='image', 
             outputs='label',
             title = 'Human vs Nonhuman Long Bone Classifier',
             description = 'A computer vision classifier to determine if an image of a long bone is more likely human or non-human origin. Use at your own risk.',
             examples = [r'test human femur - Swedish History Museum.jpg'],).launch(share=True)