Spaces:
Sleeping
Sleeping
| 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) | |