File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 12
12
from PIL import ImageColor
13
13
from pip ._internal .operations import freeze
14
14
import torch
15
+ from tqdm import tqdm
16
+
15
17
# torch import needs to switch order with "from pip._internal.operations import freeze" because of crash
16
18
# see https://github.com/pytorch/pytorch/issues/140914
17
19
@@ -91,6 +93,7 @@ def benchmark(
91
93
device : str ,
92
94
single_animal : bool ,
93
95
save_dir = None ,
96
+ n_frames = 1000 ,
94
97
precision : str = "FP32" ,
95
98
display = True ,
96
99
pcutoff = 0.5 ,
@@ -122,6 +125,8 @@ def benchmark(
122
125
save_dir : str, optional
123
126
Directory to save output data and labeled video.
124
127
If not specified, will use the directory of video_path, by default None
128
+ n_frames : int, optional
129
+ Number of frames to run inference on, by default 1000
125
130
precision : str, optional, default='FP32'
126
131
Precision type for the model ('FP32' or 'FP16').
127
132
display : bool, optional, default=True
@@ -203,7 +208,14 @@ def benchmark(
203
208
poses , times = [], []
204
209
frame_index = 0
205
210
206
- while True :
211
+ total_n_frames = cap .get (cv2 .CAP_PROP_FRAME_COUNT )
212
+ n_frames = int (
213
+ n_frames
214
+ if (n_frames > 0 ) and n_frames < total_n_frames
215
+ else total_n_frames
216
+ )
217
+ iterator = range (n_frames ) if display else tqdm (range (n_frames ))
218
+ for i in iterator :
207
219
ret , frame = cap .read ()
208
220
if not ret :
209
221
break
You can’t perform that action at this time.
0 commit comments