Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,16 +3,12 @@ import torch
|
|
| 3 |
import yolov7
|
| 4 |
|
| 5 |
|
| 6 |
-
# Images
|
| 7 |
-
#torch.hub.download_url_to_file('https://raw.githubusercontent.com/nihalbaig0/BD-Vehicle-Detection/main/images/bondor_to_kodomtoli.jpg', 'bondor_to_kodomtoli.jpg')
|
| 8 |
-
#torch.hub.download_url_to_file('https://raw.githubusercontent.com/nihalbaig0/BD-Vehicle-Detection/main/images/lamabazar_to_versitygate.jpg', 'lamabazar_to_versitygate.jpg')
|
| 9 |
-
|
| 10 |
def yolov7_inference(
|
| 11 |
-
image
|
| 12 |
-
model_path
|
| 13 |
-
image_size
|
| 14 |
-
conf_threshold
|
| 15 |
-
iou_threshold
|
| 16 |
):
|
| 17 |
"""
|
| 18 |
YOLOv7 inference function
|
|
@@ -34,31 +30,28 @@ def yolov7_inference(
|
|
| 34 |
|
| 35 |
|
| 36 |
inputs = [
|
| 37 |
-
gr.
|
| 38 |
-
gr.
|
| 39 |
choices=[
|
| 40 |
"nihalbaig/yolov7",
|
| 41 |
-
|
| 42 |
],
|
| 43 |
-
|
| 44 |
label="Model",
|
| 45 |
),
|
| 46 |
-
gr.
|
| 47 |
-
gr.
|
| 48 |
-
gr.
|
| 49 |
]
|
| 50 |
|
| 51 |
-
outputs = gr.
|
| 52 |
title = "Project-350: BD Vehicle Detection for Autonomous Vehicle"
|
| 53 |
|
| 54 |
-
#examples = [['bondor_to_kodomtoli.jpg', 'nihalbaig0/yolov7', 640, 0.25, 0.45], ['lamabazar_to_versitygate.jpg', 'nihalbaig0/yolov7', 640, 0.25, 0.45]]
|
| 55 |
demo_app = gr.Interface(
|
| 56 |
fn=yolov7_inference,
|
| 57 |
inputs=inputs,
|
| 58 |
outputs=outputs,
|
| 59 |
title=title,
|
| 60 |
-
#examples=examples,
|
| 61 |
cache_examples=True,
|
| 62 |
-
theme=
|
| 63 |
)
|
| 64 |
-
demo_app.launch(debug=True,
|
|
|
|
| 3 |
import yolov7
|
| 4 |
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
def yolov7_inference(
|
| 7 |
+
image,
|
| 8 |
+
model_path,
|
| 9 |
+
image_size,
|
| 10 |
+
conf_threshold,
|
| 11 |
+
iou_threshold,
|
| 12 |
):
|
| 13 |
"""
|
| 14 |
YOLOv7 inference function
|
|
|
|
| 30 |
|
| 31 |
|
| 32 |
inputs = [
|
| 33 |
+
gr.Image(type="pil", label="Input Image"),
|
| 34 |
+
gr.Dropdown(
|
| 35 |
choices=[
|
| 36 |
"nihalbaig/yolov7",
|
|
|
|
| 37 |
],
|
| 38 |
+
value="nihalbaig0/yolov7",
|
| 39 |
label="Model",
|
| 40 |
),
|
| 41 |
+
gr.Slider(minimum=320, maximum=1280, value=640, step=32, label="Image Size"),
|
| 42 |
+
gr.Slider(minimum=0.0, maximum=1.0, value=0.25, step=0.05, label="Confidence Threshold"),
|
| 43 |
+
gr.Slider(minimum=0.0, maximum=1.0, value=0.45, step=0.05, label="IOU Threshold"),
|
| 44 |
]
|
| 45 |
|
| 46 |
+
outputs = gr.Image(type="filepath", label="Output Image")
|
| 47 |
title = "Project-350: BD Vehicle Detection for Autonomous Vehicle"
|
| 48 |
|
|
|
|
| 49 |
demo_app = gr.Interface(
|
| 50 |
fn=yolov7_inference,
|
| 51 |
inputs=inputs,
|
| 52 |
outputs=outputs,
|
| 53 |
title=title,
|
|
|
|
| 54 |
cache_examples=True,
|
| 55 |
+
theme="dark",
|
| 56 |
)
|
| 57 |
+
demo_app.launch(debug=True, queue=True)
|