Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data/evaluation/ips.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
"34.72.31.210",
"34.31.173.29",
"34.70.115.134",
"35.239.188.147",
"34.28.144.66",
"34.173.162.143",
"35.202.139.99",
Expand Down
21 changes: 15 additions & 6 deletions optimized_ingestion/stages/detection_estimation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ def _run(self, payload: "Payload"):
next_frame_num = i + 1

det, _, dids = dets[i]
# if objects_count_change(dets, i, i + 5) <= i + 1:
# # will not map segment if cannot skip in the first place
# metadata.append([])
# continue
if new_car(dets, i, i + 5) <= i + 1:
# will not map segment if cannot skip in the first place
metadata.append([])
continue

start_detection_time = time.time()
logger.info(f"current frame num {i}")
Expand All @@ -110,7 +110,7 @@ def _run(self, payload: "Payload"):
fps=current_fps)
total_sample_plan_time.append(time.time() - start_generate_sample_plan)
next_frame_num = next_sample_plan.get_next_frame_num()
# next_frame_num = objects_count_change(dets, i, next_frame_num)
next_frame_num = new_car(dets, i, next_frame_num)
logger.info(f"founded next_frame_num {next_frame_num}")
metadata.append(all_detection_info)

Expand All @@ -121,7 +121,7 @@ def _run(self, payload: "Payload"):

# TODO: ignore the last frame ->
metadata.append([])
skipped_frame_num.append(len(payload.video) - 1)
# skipped_frame_num.append(len(payload.video) - 1)

# times.append([t2 - t1 for t1, t2 in zip(t[:-1], t[1:])])
# logger.info(np.array(times).sum(axis=0))
Expand All @@ -148,6 +148,15 @@ def _run(self, payload: "Payload"):
return keep, {DetectionEstimation.classname(): metadata}


def new_car(dets: "list[D2DMetadatum]", cur: "int", nxt: "int"):
len_det = len(dets[cur][0])
for j in range(cur + 1, min(nxt + 1, len(dets))):
future_det = dets[j][0]
if len(future_det) > len_det:
return j
return nxt


def objects_count_change(dets: "list[D2DMetadatum]", cur: "int", nxt: "int"):
det, _, _ = dets[cur]
for j in range(cur + 1, min(nxt + 1, len(dets))):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
trajectory_3d,
)

MAX_SKIP = 5
# MAX_SKIP = 5
MAX_SKIP = 1000


@dataclass
Expand Down Expand Up @@ -160,7 +161,7 @@ class SamplePlan:
action: "Action | None" = None

def update_next_sample_frame_num(self):
next_sample_frame_num = self.next_frame_num + MAX_SKIP - 1
next_sample_frame_num = min(self.next_frame_num + MAX_SKIP - 1, len(self.video))
assert self.all_detection_info is not None
for detection_info in self.all_detection_info:
# get the frame num of car exits,
Expand Down
4 changes: 2 additions & 2 deletions playground/run-ablation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,11 @@
" }\n",
" print('# of total videos:', len(videos))\n",
"\n",
" names = set(sampled_scenes[:150])\n",
" names = set(sampled_scenes[:80])\n",
" # names = set(sampled_scenes)\n",
" filtered_videos = [\n",
" n for n in videos\n",
" if n[6:10] in names and n.endswith('FRONT')\n",
" if n[6:10] in names and 'FRONT' in n # and n.endswith('FRONT')\n",
" ]\n",
" N = len(filtered_videos)\n",
" print('# of filtered videos:', N)\n",
Expand Down