Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -42,22 +42,22 @@ SUBSAMPLE = 2
|
|
42 |
def stream_object_detection(video, conf_threshold):
|
43 |
cap = cv2.VideoCapture(video)
|
44 |
|
45 |
-
fps = int(cap.get(cv2.CAP_PROP_FPS))
|
46 |
|
47 |
iterating = True
|
48 |
-
desired_fps = fps // SUBSAMPLE
|
49 |
-
batch = []
|
50 |
-
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) // 2
|
51 |
-
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) // 2
|
52 |
-
n_frames = 0
|
53 |
|
54 |
while iterating:
|
55 |
iterating, frame = cap.read()
|
56 |
frame = cv2.resize( frame, (0,0), fx=0.5, fy=0.5)
|
57 |
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
58 |
-
if n_frames % SUBSAMPLE == 0:
|
59 |
-
|
60 |
-
if len(batch) ==
|
61 |
inputs = image_processor(images=batch, return_tensors="pt").to("cuda")
|
62 |
|
63 |
print(f"starting batch of size {len(batch)}")
|
|
|
42 |
def stream_object_detection(video, conf_threshold):
|
43 |
cap = cv2.VideoCapture(video)
|
44 |
|
45 |
+
#fps = int(cap.get(cv2.CAP_PROP_FPS))
|
46 |
|
47 |
iterating = True
|
48 |
+
#desired_fps = fps // SUBSAMPLE
|
49 |
+
#batch = []
|
50 |
+
#width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) // 2
|
51 |
+
#height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) // 2
|
52 |
+
#n_frames = 0
|
53 |
|
54 |
while iterating:
|
55 |
iterating, frame = cap.read()
|
56 |
frame = cv2.resize( frame, (0,0), fx=0.5, fy=0.5)
|
57 |
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
58 |
+
#if n_frames % SUBSAMPLE == 0:
|
59 |
+
batch.append(frame)
|
60 |
+
if len(batch) == fps:
|
61 |
inputs = image_processor(images=batch, return_tensors="pt").to("cuda")
|
62 |
|
63 |
print(f"starting batch of size {len(batch)}")
|