fire_detector / app.py
durgaamma2005's picture
Update app.py
a7a7756
import gradio as gr
from fastai.vision.all import *
import skimage
learn = load_learner('fire_smoke_export.pkl')
labels = learn.dls.vocab
def predict(img):
img = PILImage.create(img)
pred,pred_idx,probs = learn.predict(img)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
title = "Fire and Smoke Detector"
description = "Fire and Smoke classifier created with fastai. Created as a demo for Gradio and HuggingFace Spaces. Fire accidents are not uncommon and has catastrophic impact on the company both interms of social and financial terms. This application can be deployed on device and can work as 24X365 surveillance. This app classify an image into three classes. 1. Fire, 2. Smoke, 3. Neutral. Try your hand and check. For any general purpose, model file can be copied and used for the stated purpose"
article="<p style='text-align: center'><a href='https://github.com/mldurga/projects/blob/master/Fire_smoke_detector.ipynb' target='_blank'>Blog post</a></p>"
interpretation='default'
examples = ['Neutral2.jpeg','smoke1.jpeg','smoke2.jpeg','fire1.png']
enable_queue=True
gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article,interpretation=interpretation,examples=examples,enable_queue=enable_queue).launch()