Skip to content

Commit b00cee2

Browse files
committed
fix bug where cheese3d feature extraction crashes if pose3d is not there
1 parent 6f7b7b9 commit b00cee2

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

packages/cheese3d/cheese3d/backends/dlc.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,5 +250,4 @@ def train(self, gpu, iterate_dataset: bool = True):
250250
dlc.train_network(config=self.config_path,
251251
gputouse=gpu)
252252
dlc.evaluate_network(config=self.config_path,
253-
gputouse=gpu,
254-
per_keypoint_evaluation=True)
253+
gputouse=gpu)

packages/cheese3d/cheese3d/project.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,9 +607,13 @@ def triangulate(self, session: Optional[str] = None):
607607
if len(exclude_kps) > 0:
608608
rprint("[bold red]Keypoint configuration does not match default Cheese3D keypoints. "
609609
"Some Cheese3D features may not be computed![/bold red]")
610+
rprint("Generating Cheese3d features ...")
610611
for session_dir in sessions_to_process:
611612
if session_dir.is_dir():
612613
landmarks = read_3d_data(session_dir)
614+
if landmarks is None:
615+
rprint(f"[bold red]No landmarks found for {session_dir.name}, skipping![/bold red]")
616+
continue
613617
c3d_features = compute_anatomical_measurements(landmarks, exclude_kps)
614618
# write features to csv
615619
c3d_features_df = pd.DataFrame({

packages/cheese3d/cheese3d/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ def read_3d_data(data_dir: str | Path, extra_cols = None):
185185
to arrays of shape `(time,)`.
186186
"""
187187
files = glob(str(Path(data_dir) / "pose-3d" / "*.csv"))
188+
if len(files) == 0:
189+
return None
188190
data = pd.read_csv(files[0])
189191
cols = data.head() # name of all the columns
190192
landmark_names = np.unique([s.split('_')[0]

0 commit comments

Comments
 (0)