Skip to content

Commit

Permalink
generalize LP project uploading (#116)
Browse files Browse the repository at this point in the history
* generalize LP project upload functions

* clean whitespace
  • Loading branch information
themattinthehatt authored Nov 20, 2024
1 parent bbfc405 commit edfe0e5
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lightning_pose_app/ui/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,22 @@ def find_top_level_dir(initial_path, target_file_name=None, target_dir=None):
csv_file = os.path.join(self.proj_dir_abs, COLLECTED_DATA_FILENAME)
df = pd.read_csv(csv_file, header=[0, 1, 2], index_col=0)
frames = np.array(df.index)
vids = np.unique([f.split('/')[1] for f in frames])
# find separator; data may have been labeled on windows
if len(frames[0].split('/')) == 1 and len(frames[0].split('\\')) == 3:
# no '/' in relative path, labeled on windows, structure is fine though
sep = '\\'
elif len(frames[0].split('/')) == 3:
# labeled on linux
sep = '/'
else:
raise RuntimeError(
f"Could not determine relative path structure in CollectedData.csv file. "
f"The relative path should be of the form 'labeled-data/<video_name>/<img>.png; "
f"You have {frames[0]}"
)
vids = np.unique([f.split(sep)[1] for f in frames])
for vid in vids:
frames_to_label = np.array([f.split('/')[2] for f in frames if f.split('/')[1] in vid])
frames_to_label = np.array([f.split(sep)[2] for f in frames if f.split(sep)[1] == vid])
save_dir = os.path.join(
self.proj_dir_abs, LABELED_DATA_DIR, vid, SELECTED_FRAMES_FILENAME)
_logger.debug(f"Saving selected frames to {save_dir}")
Expand Down

0 comments on commit edfe0e5

Please sign in to comment.