bonosa commited on
Commit
053cb21
·
1 Parent(s): 7c1fd8f
Files changed (7) hide show
  1. app.py +56 -0
  2. best.pt +3 -0
  3. pothole1.jpg +0 -0
  4. pothole2.jpg +0 -0
  5. pothole3.jpg +0 -0
  6. pothole4.jpg +0 -0
  7. requirements.txt +47 -0
app.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import cv2
3
+
4
+ from ultralytics import YOLO
5
+
6
+ model = YOLO('best.pt')
7
+ path = [['pothole1.jpg'], ['pothole2.jpg'], ['pothole3.jpg'],['pothole4.jpg']]
8
+
9
+ import cv2
10
+
11
+ def resize_image(image_path):
12
+ # Read the image using OpenCV
13
+ img = cv2.imread(image_path)
14
+
15
+ # Resize the image to 512x512
16
+ resized_img = cv2.resize(img, (512, 512), interpolation = cv2.INTER_LINEAR)
17
+
18
+ return resized_img
19
+
20
+
21
+ def prediction1(image_path):
22
+ #image = resize_image(image_path)
23
+ image = cv2.imread(image_path)
24
+ outputs = model.predict(source=image_path)
25
+ results = outputs[0].cpu().numpy()
26
+ for i, det in enumerate(results.boxes.xyxy):
27
+ cv2.rectangle(
28
+ image,
29
+ (int(det[0]), int(det[1])),
30
+ (int(det[2]), int(det[3])),
31
+ color=(0,255, 0),
32
+ thickness=1,
33
+ lineType=cv2.LINE_AA,
34
+ )
35
+ return cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
36
+
37
+ inputs_image = [
38
+ gr.components.Image(type="filepath", label="Input Image"),
39
+ ]
40
+ outputs_image = [
41
+ gr.components.Image(type="numpy", label="Output Image"),
42
+ ]
43
+ interface_image = gr.Interface(
44
+ fn=prediction1,
45
+ inputs=inputs_image,
46
+ outputs=outputs_image,
47
+ title="Pothole detection",
48
+ description="Detects potholes in images",
49
+ #cache_examples=True,
50
+ examples=path
51
+
52
+ )
53
+
54
+
55
+
56
+ interface_image.launch()
best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ce9a23590d666fcca004d3a2330f3e30b229bbe9df0dbf4b0fd390c20fbe67fe
3
+ size 6233272
pothole1.jpg ADDED
pothole2.jpg ADDED
pothole3.jpg ADDED
pothole4.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ultralytics requirements
2
+ # Usage: pip install -r requirements.txt
3
+
4
+ # Base ----------------------------------------
5
+ hydra-core>=1.2.0
6
+ matplotlib>=3.2.2
7
+ numpy>=1.18.5
8
+ opencv-python>=4.1.1
9
+ Pillow>=7.1.2
10
+ PyYAML>=5.3.1
11
+ requests>=2.23.0
12
+ scipy>=1.4.1
13
+ torch>=1.7.0
14
+ torchvision>=0.8.1
15
+ tqdm>=4.64.0
16
+ ultralytics
17
+
18
+ # Logging -------------------------------------
19
+ tensorboard>=2.4.1
20
+ # clearml
21
+ # comet
22
+
23
+ # Plotting ------------------------------------
24
+ pandas>=1.1.4
25
+ seaborn>=0.11.0
26
+
27
+ # Export --------------------------------------
28
+ # coremltools>=6.0 # CoreML export
29
+ # onnx>=1.12.0 # ONNX export
30
+ # onnx-simplifier>=0.4.1 # ONNX simplifier
31
+ # nvidia-pyindex # TensorRT export
32
+ # nvidia-tensorrt # TensorRT export
33
+ # scikit-learn==0.19.2 # CoreML quantization
34
+ # tensorflow>=2.4.1 # TF exports (-cpu, -aarch64, -macos)
35
+ # tensorflowjs>=3.9.0 # TF.js export
36
+ # openvino-dev # OpenVINO export
37
+
38
+ # Extras --------------------------------------
39
+ ipython # interactive notebook
40
+ psutil # system utilization
41
+ thop>=0.1.1 # FLOPs computation
42
+ # albumentations>=1.0.3
43
+ # pycocotools>=2.0.6 # COCO mAP
44
+ # roboflow
45
+
46
+ # HUB -----------------------------------------
47
+ GitPython>=3.1.24