CoolFace
Apppublic

mvsrujan/Severity_Classifier

sourceHugging Faceapache-2.0updated 4y agoView on Hugging Face
0likes
app.py16 linesDownload Raw Back to root
1from fastai.vision.all import *2 3learn = load_learner('sev_model.pkl')4labels = learn.dls.vocab5def predict(img):6    img = PILImage.create(img)7    pred,pred_idx,probs = learn.predict(img)8    return {labels[i]: float(probs[i]) for i in range(len(labels))}9 10title = "Damage Severity Classifier"11description = "<p style='text-align: center'>Classifies Damage in images as Mild and Severe. Fine-tuned Resnet-50. Built using Fastai."12examples = ['ex1.jfif', 'ex2.jfif', 'ex3.jfif', 'ex4.png', 'ex5.jfif', 'ex6.jfif', 'ex7.png', 'ex8.jfif', 'ex9.jfif', 'ex10.jfif']13 14 15import gradio as gr16gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=2), title=title, description=description, examples = examples).launch()