durgaamma2005 commited on
Commit
68cbabf
1 Parent(s): 9934985

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+ import skimage
4
+ learn = load_learner('fire_smoke_export.pkl')
5
+ labels = learn.dls.vocab
6
+ def predict(img):
7
+ img = PILImage.create(img)
8
+ pred,pred_idx,probs = learn.predict(img)
9
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
10
+
11
+ title = "Fire and Smoke Detector"
12
+ description = "Fire and Smoke classifier created with fastai. Created as a demo for Gradio and HuggingFace Spaces."
13
+ 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>"
14
+ examples = ['Neutral1.jpg']
15
+ interpretation='default'
16
+ enable_queue=True
17
+ 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,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()