Spaces:
Runtime error
Runtime error
Commit
·
56d287e
1
Parent(s):
7d72abd
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,17 +2,10 @@ import gradio as gr
|
|
| 2 |
|
| 3 |
from ultralytics import YOLO
|
| 4 |
model = YOLO('./best.pt') # load your custom trained model
|
| 5 |
-
|
| 6 |
import torch
|
| 7 |
-
from ultralyticsplus import render_result
|
|
|
|
| 8 |
|
| 9 |
-
torch.hub.download_url_to_file(
|
| 10 |
-
'https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Ftexashafts.com%2Fwp-content%2Fuploads%2F2016%2F04%2Fconstruction-worker.jpg',
|
| 11 |
-
'one.jpg')
|
| 12 |
-
torch.hub.download_url_to_file(
|
| 13 |
-
'https://www.pearsonkoutcherlaw.com/wp-content/uploads/2020/06/Construction-Workers.jpg', 'two.jpg')
|
| 14 |
-
torch.hub.download_url_to_file(
|
| 15 |
-
'https://nssgroup.com/wp-content/uploads/2019/02/Building-maintenance-blog.jpg', 'three.jpg')
|
| 16 |
|
| 17 |
|
| 18 |
def yoloV8_func(image: gr.Image = None,
|
|
@@ -44,7 +37,7 @@ def yoloV8_func(image: gr.Image = None,
|
|
| 44 |
print("Probability:", box.conf)
|
| 45 |
|
| 46 |
# Render the output image with bounding boxes around detected objects
|
| 47 |
-
render =
|
| 48 |
return render
|
| 49 |
|
| 50 |
|
|
@@ -57,7 +50,7 @@ inputs = [
|
|
| 57 |
|
| 58 |
outputs = gr.Image(type="filepath", label="Output Image")
|
| 59 |
|
| 60 |
-
title = "YOLOv8 101: Custom Object Detection on
|
| 61 |
|
| 62 |
examples = [['img1.jpg', 640, 0.5, 0.7],
|
| 63 |
['img2.jpg', 800, 0.5, 0.6],
|
|
@@ -73,4 +66,5 @@ yolo_app = gr.Interface(
|
|
| 73 |
)
|
| 74 |
|
| 75 |
# Launch the Gradio interface in debug mode with queue enabled
|
| 76 |
-
yolo_app.launch(debug=True
|
|
|
|
|
|
| 2 |
|
| 3 |
from ultralytics import YOLO
|
| 4 |
model = YOLO('./best.pt') # load your custom trained model
|
|
|
|
| 5 |
import torch
|
| 6 |
+
#from ultralyticsplus import render_result
|
| 7 |
+
from render import custom_render_result
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
def yoloV8_func(image: gr.Image = None,
|
|
|
|
| 37 |
print("Probability:", box.conf)
|
| 38 |
|
| 39 |
# Render the output image with bounding boxes around detected objects
|
| 40 |
+
render = custom_render_result(model=model, image=image, result=results[0])
|
| 41 |
return render
|
| 42 |
|
| 43 |
|
|
|
|
| 50 |
|
| 51 |
outputs = gr.Image(type="filepath", label="Output Image")
|
| 52 |
|
| 53 |
+
title = "YOLOv8 101: Custom Object Detection on meter"
|
| 54 |
|
| 55 |
examples = [['img1.jpg', 640, 0.5, 0.7],
|
| 56 |
['img2.jpg', 800, 0.5, 0.6],
|
|
|
|
| 66 |
)
|
| 67 |
|
| 68 |
# Launch the Gradio interface in debug mode with queue enabled
|
| 69 |
+
yolo_app.launch(debug=True).queue()
|
| 70 |
+
|