File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed
apps/99_streamlit_examples/pages Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change 7
7
8
8
9
9
class Processor :
10
- def __init__ (self , model_name ):
10
+ def __init__ (
11
+ self ,
12
+ model_name : str ,
13
+ ):
11
14
self .model = YOLO (model_name )
12
15
13
- def process (self , frame ):
16
+ def process (
17
+ self ,
18
+ frame : cv2 .UMat ,
19
+ confidence : float ,
20
+ ) -> cv2 .UMat :
14
21
results = self .model (
15
22
frame ,
16
- conf = 0.5 ,
23
+ conf = confidence ,
17
24
classes = [0 ],
18
25
)
19
26
output_img = results [0 ].plot (
@@ -27,24 +34,33 @@ def process(self, frame):
27
34
28
35
29
36
with st .sidebar :
37
+ # model_name: https://docs.ultralytics.com/models/yolov8/#supported-tasks-and-modes
30
38
model_name = st .selectbox (
31
39
label = "Select a model" ,
32
40
options = [
33
41
"yolov8n.pt" ,
34
42
"yolov9c.pt" ,
35
43
"yolov10n.pt" ,
36
- # https://docs.ultralytics.com/models/yolov8/#supported-tasks-and-modes
37
44
],
38
45
key = "model_name" ,
39
46
index = 0 ,
40
47
)
48
+ # device: https://docs.opencv.org/4.10.0/d8/dfe/classcv_1_1VideoCapture.html#a5d5f5dacb77bbebdcbfb341e3d4355c1
41
49
device = st .text_input (
42
50
label = "input your video/camera device" ,
43
51
value = "0" ,
44
52
)
45
53
if device .isnumeric ():
46
54
# e.g. "0" -> 0
47
55
device = int (device )
56
+ # confidence: https://docs.ultralytics.com/usage/cfg/#predict-settings
57
+ confidence = st .slider (
58
+ label = "Confidence" ,
59
+ min_value = 0.0 ,
60
+ max_value = 1.0 ,
61
+ value = 0.5 ,
62
+ step = 0.01 ,
63
+ )
48
64
49
65
st .title ("Video processing" )
50
66
@@ -68,6 +84,7 @@ def process(self, frame):
68
84
69
85
processed_frame = processor .process (
70
86
frame = frame ,
87
+ confidence = confidence ,
71
88
)
72
89
73
90
image_loc .image (
You can’t perform that action at this time.
0 commit comments