Tashi Kuenga Phuntsho commited on
Commit
3e8018c
·
1 Parent(s): 52aa05f

Add requirements for YOLOv5

Browse files
Files changed (3) hide show
  1. app.py +13 -14
  2. requirements.txt +6 -0
  3. yolov5 +1 -0
app.py CHANGED
@@ -1,18 +1,17 @@
1
- from ultralytics import YOLO
2
- import gradio as gr
 
 
3
  from PIL import Image
 
4
 
5
- model = YOLO("best.pt")
6
- def detect_potholes(image):
7
- results = model(image)
8
- annotated_frame = results[0].plot()
9
- return Image.fromarray(annotated_frame)
10
 
11
- iface = gr.Interface(
12
- fn=detect_potholes,
13
- inputs=gr.inputs.Image(type="pil"),
14
- outputs="image",
15
- title="Pothole Detector"
16
- )
17
 
18
- iface.launch()
 
 
 
 
1
+ import torch
2
+ from yolov5.utils.general import non_max_suppression, scale_coords
3
+ from yolov5.utils.plots import plot_boxes
4
+ from yolov5.models.common import DetectMultiBackend
5
  from PIL import Image
6
+ import numpy as np
7
 
8
+ model = torch.hub.load('ultralytics/yolov5', 'custom', path='best.pt')
 
 
 
 
9
 
10
+ def detect(image):
11
+ results = model(image)
12
+ return results
 
 
 
13
 
14
+ # Example inference
15
+ image = Image.open("test.jpg")
16
+ results = detect(image)
17
+ print(results)
requirements.txt CHANGED
@@ -5,3 +5,9 @@ opencv-python
5
  numpy
6
  pillow
7
  gradio
 
 
 
 
 
 
 
5
  numpy
6
  pillow
7
  gradio
8
+ torch
9
+ torchvision
10
+ numpy
11
+ opencv-python
12
+ pillow
13
+ git+https://github.com/ultralytics/yolov5.git
yolov5 ADDED
@@ -0,0 +1 @@
 
 
1
+ Subproject commit de62f93c210aaaffd710f9afe3b43ab624f7a21b