Skip to content

Commit

Permalink
fix: sorted order needed to make start/end filtering work
Browse files Browse the repository at this point in the history
  • Loading branch information
danellecline committed Apr 30, 2024
1 parent f344865 commit 9caea73
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions sdcat/cluster/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ def run_cluster(det_dir, save_dir, device, config_ini, alpha, cluster_selection_
err(f'Found {df["image_path"].isnull().sum()} detections with no image_path')
return

# Sort the dataframe by image_path to make sure the images are in order for start_image and end_image filtering
df = df.sort_values(by='image_path')

# If start_image is set, find the index of the start_image in the list of images
if start_image:
start_image = Path(start_image)
Expand Down
4 changes: 2 additions & 2 deletions sdcat/detect/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ def run_detect(show: bool, image_dir: str, save_dir: str, model: str,
save_path_det_filtered.mkdir(parents=True, exist_ok=True)
save_path_viz.mkdir(parents=True, exist_ok=True)

# Run on all images recursively
# Run on all images recursively. Sort the dataframe by image_path to make sure the images are in order for start_image and end_image filtering
# Find all valid images
images = [file for file in images_path.rglob('*')
images = [file for file in sorted(images_path.rglob('*'))
if file.as_posix().endswith(('jpeg', 'png', 'jpg', 'JPEG', 'PNG', 'JPG', 'tif', 'tiff'))]

# If start_image is set, find the index of the start_image in the list of images
Expand Down

0 comments on commit 9caea73

Please sign in to comment.