robmarkcole commited on
Commit
e5349d6
1 Parent(s): e126a27

Upload 5 files

Browse files
Files changed (5) hide show
  1. app.py +28 -0
  2. best.pt +3 -0
  3. fire-basket.jpg +0 -0
  4. pan-fire.jpg +0 -0
  5. requirements.txt +20 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Source: https://github.com/AK391/yolov5/blob/master/utils/gradio/demo.py
3
+ """
4
+
5
+ import gradio as gr
6
+ import torch
7
+ from PIL import Image
8
+
9
+ model = torch.hub.load('ultralytics/yolov5', 'custom', 'best.pt') # force_reload=True to update
10
+
11
+
12
+ def yolo(im, size=640):
13
+ g = (size / max(im.size)) # gain
14
+ im = im.resize((int(x * g) for x in im.size), Image.ANTIALIAS) # resize
15
+ results = model(im) # inference
16
+ results.render() # updates results.ims with boxes and labels
17
+ return Image.fromarray(results.ims[0])
18
+
19
+
20
+ inputs = gr.inputs.Image(type='pil', label="Original Image")
21
+ outputs = gr.outputs.Image(type="pil", label="Output Image")
22
+
23
+ title = "YOLOv5"
24
+ description = "YOLOv5 demo for fire detection. Upload an image or click an example image to use."
25
+ article = "See https://github.com/robmarkcole/fire-detection-from-images"
26
+ examples = [['pan-fire.jpg'], ['fire-basket.jpg']]
27
+ gr.Interface(yolo, inputs, outputs, title=title, description=description, article=article, examples=examples).launch(
28
+ debug=True)
best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7abb1d7c7e8caece6282a8f0e3d5731fc21153e01e968f8a29f703c423f8d8fb
3
+ size 14744462
fire-basket.jpg ADDED
pan-fire.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ gradio
2
+ pandas
3
+
4
+ # YOLOv5 requirements
5
+ matplotlib>=3.2.2
6
+ numpy>=1.18.5
7
+ opencv-python>=4.1.1
8
+ Pillow>=7.1.2
9
+ PyYAML>=5.3.1
10
+ requests>=2.23.0
11
+ scipy>=1.4.1
12
+ torch>=1.7.0
13
+ torchvision>=0.8.1
14
+ tqdm>=4.64.0
15
+ seaborn>=0.11.0
16
+
17
+ # Extras --------------------------------------
18
+ ipython # interactive notebook
19
+ psutil # system utilization
20
+ thop>=0.1.1 # FLOPs computation