Spaces:
Runtime error
Runtime error
replace app.py
Browse files
app.py
CHANGED
@@ -6,29 +6,31 @@ import torch
|
|
6 |
|
7 |
def yolov7_inference(
|
8 |
image: gr.inputs.Image = None,
|
9 |
-
|
10 |
):
|
11 |
|
12 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
13 |
path = 'y7-prdef.pt'
|
14 |
model = torch.hub.load("WongKinYiu/yolov7","custom",f"{path}")
|
15 |
-
|
16 |
results = model([image], size=640)
|
17 |
return results.render()[0]
|
18 |
|
19 |
|
20 |
inputs = [
|
21 |
gr.inputs.Image(type="pil", label="Input Image"),
|
|
|
22 |
]
|
23 |
|
24 |
-
|
25 |
demo_app = gr.Interface(
|
26 |
fn=yolov7_inference,
|
27 |
inputs=inputs,
|
28 |
outputs=gr.outputs.Image(type="filepath", label="Output Image"),
|
29 |
-
title="
|
30 |
-
|
|
|
|
|
31 |
cache_examples=True,
|
32 |
)
|
33 |
-
demo_app.launch(debug=
|
34 |
|
|
|
6 |
|
7 |
def yolov7_inference(
|
8 |
image: gr.inputs.Image = None,
|
9 |
+
conf_threshold: gr.inputs.Slider = 0.50,
|
10 |
):
|
11 |
|
12 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
13 |
path = 'y7-prdef.pt'
|
14 |
model = torch.hub.load("WongKinYiu/yolov7","custom",f"{path}")
|
15 |
+
model.conf = conf_threshold
|
16 |
results = model([image], size=640)
|
17 |
return results.render()[0]
|
18 |
|
19 |
|
20 |
inputs = [
|
21 |
gr.inputs.Image(type="pil", label="Input Image"),
|
22 |
+
gr.inputs.Slider(minimum=0.0, maximum=1.0, default=0.50, step=0.05, label="Confidence Threshold"),
|
23 |
]
|
24 |
|
|
|
25 |
demo_app = gr.Interface(
|
26 |
fn=yolov7_inference,
|
27 |
inputs=inputs,
|
28 |
outputs=gr.outputs.Image(type="filepath", label="Output Image"),
|
29 |
+
title="Detection of jar lid defects (Yolov7)",
|
30 |
+
description = "App detecting jar lids that are damaged (deformation, hole, scratch) versus intact. | Ruthger Righart ",
|
31 |
+
article = "<p style='text-align: center'><a href='https://www.rrighart.com' target='_blank'>Webpage</a></p> <p style='text-align: center'><a href='https://www.kaggle.com/code/rrighart/detection-of-product-defects-using-yolov7' target='_blank'>Kaggle</a></p>",
|
32 |
+
examples=[['t1.JPG', 0.50]],
|
33 |
cache_examples=True,
|
34 |
)
|
35 |
+
demo_app.launch(debug=False, enable_queue=True)
|
36 |
|