Skip to content

Commit

Permalink
feat: New features for clustering
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernanda Lecaros Saavedra authored and Fernanda Lecaros Saavedra committed Apr 23, 2024
1 parent e63bb73 commit b74d1b1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions sdcat/cluster/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
@click.option('--det-dir', help='Input folder(s) with raw detection results', multiple=True)
@click.option('--save-dir', help='Output directory to save clustered detection results')
@click.option('--device', help='Device to use.', type=int)
def run_cluster(det_dir, save_dir, device, config_ini):
@click.option('--alpha', help='Alpha is a parameter that controls the linkage.', type=float, default=0.92)
@click.option('--cluster_selection_epsilon', help='Epsilon is a parameter that controls the linkage', type=float, default=0.0)
@click.option('--min_cluster_size', help='The minimum number of samples in a group for that group to be considered a cluster', type=int, default=2)

def run_cluster(det_dir, save_dir, device, config_ini, alpha, cluster_selection_epsilon, min_cluster_size):
config = cfg.Config(config_ini)
max_area = int(config('cluster', 'max_area'))
min_area = int(config('cluster', 'min_area'))
Expand All @@ -36,9 +40,6 @@ def run_cluster(det_dir, save_dir, device, config_ini):
longitude = float(config('cluster', 'longitude'))
min_score = float(config('cluster', 'min_score'))
min_similarity = float(config('cluster', 'min_similarity'))
alpha = float(config('cluster', 'alpha'))
cluster_selection_epsilon = float(config('cluster', 'cluster_selection_epsilon'))
min_cluster_size = int(config('cluster', 'min_cluster_size'))
model = config('cluster', 'model')

if device:
Expand Down
2 changes: 1 addition & 1 deletion sdcat/cluster/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def crop_square_image(row, square_dim: int):

if Path(row.crop_path).exists(): # If the crop already exists, skip it
return

print("Image widht ", row.image_width)
x1 = int(row.image_width * row.x)
y1 = int(row.image_height * row.y)
x2 = int(row.image_width * row.xx)
Expand Down
2 changes: 2 additions & 0 deletions sdcat/detect/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,9 @@ def run_detect(show: bool, image_dir: str, save_dir: str, model: str,
df_combined['w'] = (df_combined['xx'] - df_combined['x'])
df_combined['h'] = (df_combined['xy'] - df_combined['y'])

# Save DataFrame to CSV file including image_width and image_height columns
df_combined.to_csv(pred_out_csv.as_posix(), index=False, header=True)

info(f'Found {len(pred_list)} total localizations in {f} with {len(df_combined)} after NMS')
info(f'Slice width: {slice_size_width} height: {slice_size_height}')

Expand Down

0 comments on commit b74d1b1

Please sign in to comment.