diff --git a/data/evaluation/ips.json b/data/evaluation/ips.json index b02ccbdb..d7d0e81f 100644 --- a/data/evaluation/ips.json +++ b/data/evaluation/ips.json @@ -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", diff --git a/optimized_ingestion/stages/detection_estimation/__init__.py b/optimized_ingestion/stages/detection_estimation/__init__.py index ee6ba12c..ef3c1aa4 100644 --- a/optimized_ingestion/stages/detection_estimation/__init__.py +++ b/optimized_ingestion/stages/detection_estimation/__init__.py @@ -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}") @@ -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) @@ -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)) @@ -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))): diff --git a/optimized_ingestion/stages/detection_estimation/detection_estimation.py b/optimized_ingestion/stages/detection_estimation/detection_estimation.py index acfb35bd..64985b4e 100644 --- a/optimized_ingestion/stages/detection_estimation/detection_estimation.py +++ b/optimized_ingestion/stages/detection_estimation/detection_estimation.py @@ -42,7 +42,8 @@ trajectory_3d, ) -MAX_SKIP = 5 +# MAX_SKIP = 5 +MAX_SKIP = 1000 @dataclass @@ -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, diff --git a/playground/run-ablation.ipynb b/playground/run-ablation.ipynb index e9607169..ad1d0d7f 100644 --- a/playground/run-ablation.ipynb +++ b/playground/run-ablation.ipynb @@ -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",