shivam12119 commited on
Commit
127262b
·
verified ·
1 Parent(s): d6ad5a3

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +44 -0
  2. fire.pt +3 -0
  3. requirements.txt +49 -0
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import streamlit as st
3
+ from PIL import Image
4
+ import io
5
+
6
+ # Load the YOLOv5 model
7
+ model = torch.hub.load('ultralytics/yolov5', 'custom', path='fire.pt') # Load custom model
8
+
9
+ # Streamlit interface
10
+ st.title("YOLOv5 Image Detection")
11
+ st.write("Upload an image to detect objects using YOLOv5")
12
+
13
+ # File uploader for image
14
+ uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
15
+
16
+ if uploaded_file is not None:
17
+ # Convert the uploaded file to a PIL Image
18
+ image = Image.open(uploaded_file)
19
+
20
+ # Run the YOLOv5 model
21
+ results = model(image)
22
+
23
+ # Save the results image
24
+ results_image = results.render()[0] # Render returns a list, we take the first element
25
+
26
+ # Convert the numpy array result to an image
27
+ results_image = Image.fromarray(results_image)
28
+
29
+ # Save to a buffer
30
+ buf = io.BytesIO()
31
+ results_image.save(buf, format='JPEG')
32
+ byte_im = buf.getvalue()
33
+
34
+ # Display the input and output images side by side
35
+ st.image(image, caption='Uploaded Image', use_column_width=True)
36
+ st.image(results_image, caption='Detected Image', use_column_width=True)
37
+
38
+ # Provide a download button for the output image
39
+ st.download_button(
40
+ label="Download Output Image",
41
+ data=byte_im,
42
+ file_name="output.jpg",
43
+ mime="image/jpeg"
44
+ )
fire.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9be73bee589144e12981844167b545c75210aa69d60aae84c1fa1610040b31c4
3
+ size 14443880
requirements.txt ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # YOLOv5 requirements
2
+ # Usage: pip install -r requirements.txt
3
+
4
+ # Base ------------------------------------------------------------------------
5
+ gitpython>=3.1.30
6
+ matplotlib>=3.3
7
+ numpy>=1.23.5
8
+ opencv-python>=4.1.1
9
+ pillow>=10.3.0
10
+ psutil # system resources
11
+ PyYAML>=5.3.1
12
+ requests>=2.32.0
13
+ scipy>=1.4.1
14
+ thop>=0.1.1 # FLOPs computation
15
+ torch>=1.8.0 # see https://pytorch.org/get-started/locally (recommended)
16
+ torchvision>=0.9.0
17
+ tqdm>=4.64.0
18
+ ultralytics>=8.2.34 # https://ultralytics.com
19
+ # protobuf<=3.20.1 # https://github.com/ultralytics/yolov5/issues/8012
20
+
21
+ # Logging ---------------------------------------------------------------------
22
+ # tensorboard>=2.4.1
23
+ # clearml>=1.2.0
24
+ # comet
25
+
26
+ # Plotting --------------------------------------------------------------------
27
+ pandas>=1.1.4
28
+ seaborn>=0.11.0
29
+
30
+ # Export ----------------------------------------------------------------------
31
+ # coremltools>=6.0 # CoreML export
32
+ # onnx>=1.10.0 # ONNX export
33
+ # onnx-simplifier>=0.4.1 # ONNX simplifier
34
+ # nvidia-pyindex # TensorRT export
35
+ # nvidia-tensorrt # TensorRT export
36
+ # scikit-learn<=1.1.2 # CoreML quantization
37
+ # tensorflow>=2.4.0,<=2.13.1 # TF exports (-cpu, -aarch64, -macos)
38
+ # tensorflowjs>=3.9.0 # TF.js export
39
+ # openvino-dev>=2023.0 # OpenVINO export
40
+
41
+ # Deploy ----------------------------------------------------------------------
42
+ setuptools>=70.0.0 # Snyk vulnerability fix
43
+ # tritonclient[all]~=2.24.0
44
+
45
+ # Extras ----------------------------------------------------------------------
46
+ # ipython # interactive notebook
47
+ # mss # screenshots
48
+ # albumentations>=1.0.3
49
+ # pycocotools>=2.0.6 # COCO mAP