Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,9 +6,8 @@ def inference(path:str, threshold:float=0.6):
|
|
6 |
print("trying inference with path", path)
|
7 |
if path is None:
|
8 |
return None,0
|
9 |
-
model = YOLO('
|
10 |
-
|
11 |
-
outputs = model.predict(source=path, classes= [0], show=False, conf=threshold) # new API with Ultralytics 8.0.43. Accepts 'show', 'classes', 'stream', 'conf' (default is 0.25)
|
12 |
image = cv2.imread(path)
|
13 |
counter = 0
|
14 |
for output in outputs: # mono item batch
|
@@ -33,9 +32,9 @@ def inference(path:str, threshold:float=0.6):
|
|
33 |
gr.Interface(
|
34 |
fn = inference,
|
35 |
inputs = [ gr.components.Image(type="filepath", label="Input"), gr.Slider(minimum=0.5, maximum=0.9, step=0.05, value=0.7, label="Confidence threshold") ],
|
36 |
-
outputs = [ gr.components.Image(type="numpy", label="Output"), gr.Label(label="
|
37 |
title="Person detection with YOLO v8",
|
38 |
description="Person detection, you can tweak the corresponding confidence threshold. Good results even when face not visible. New API since Ultralytics 8.0.43.",
|
39 |
-
examples=[ ['
|
40 |
allow_flagging="never"
|
41 |
).launch(debug=True, enable_queue=True)
|
|
|
6 |
print("trying inference with path", path)
|
7 |
if path is None:
|
8 |
return None,0
|
9 |
+
model = YOLO('yolo8n_small.pt') # Caution new API since Ultralytics 8.0.43
|
10 |
+
outputs = model.predict(source=path, show=False, conf=threshold) # new API with Ultralytics 8.0.43. Accepts 'show', 'classes', 'stream', 'conf' (default is 0.25)
|
|
|
11 |
image = cv2.imread(path)
|
12 |
counter = 0
|
13 |
for output in outputs: # mono item batch
|
|
|
32 |
gr.Interface(
|
33 |
fn = inference,
|
34 |
inputs = [ gr.components.Image(type="filepath", label="Input"), gr.Slider(minimum=0.5, maximum=0.9, step=0.05, value=0.7, label="Confidence threshold") ],
|
35 |
+
outputs = [ gr.components.Image(type="numpy", label="Output"), gr.Label(label="Number of legos detected for given confidence threshold") ],
|
36 |
title="Person detection with YOLO v8",
|
37 |
description="Person detection, you can tweak the corresponding confidence threshold. Good results even when face not visible. New API since Ultralytics 8.0.43.",
|
38 |
+
examples=[ ['sample1.jpg'], ['sample2.jpg']],
|
39 |
allow_flagging="never"
|
40 |
).launch(debug=True, enable_queue=True)
|