Skip to content

Commit ec8dad0

Browse files
committed
updated default args to streamline use
1 parent c15017a commit ec8dad0

1 file changed

Lines changed: 29 additions & 23 deletions

File tree

partinet/__init__.py

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ def train_common_args(f):
4444
f = click.option('--resume-ckpt', type=str, default='', help='checkpoint to resume from')(f)
4545
f = click.option('--resume', is_flag=True, help='resume most recent training')(f)
4646
f = click.option('--rect', is_flag=True, help='rectangular training')(f)
47-
f = click.option('--img-size', nargs=2, type=int, default=[640, 640], help='[train, test] image sizes', show_default=True)(f)
47+
f = click.option('--img-size', nargs=2, type=int, default=[1280, 1280], help='[train, test] image sizes', show_default=True)(f)
4848
f = click.option('--batch-size', type=int, default=16, help='total batch size for all GPUs', show_default=True)(f)
4949
f = click.option('--epochs', type=int, default=300, show_default=True)(f)
5050
f = click.option('--hyp', type=click.Choice(["scratch.p5", "scratch.p6", "finetune.dynamic.adam"]), default='scratch.p5', help='hyperparameters path', show_default=True)(f)
5151
f = click.option('--data', type=str, default='data/coco.yaml', help='data.yaml path', show_default=True)(f)
5252
f = click.option('--weight', type=str, help='initial weights path', required=True)(f)
53-
f = click.option('--backbone-detector', type=click.Choice(DYNAMICDET_AVAILABLE_MODELS, case_sensitive=False), help='The choice of backbone to be used.', default="yolov7", show_default=True)(f)
53+
f = click.option('--backbone-detector', type=click.Choice(DYNAMICDET_AVAILABLE_MODELS, case_sensitive=False), help='The choice of backbone to be used.', default="yolov7-w6", show_default=True)(f)
5454

5555
return f
5656

@@ -60,19 +60,25 @@ def main():
6060
pass
6161

6262
@main.command()
63-
@click.option("--labels", type=str, required=True, help="Path to the labels directory")
64-
@click.option("--images", type=str, required=True, help="Path to the images directory")
65-
@click.option("--output", type=str, required=True, help="Path to the output directory")
66-
def split(labels, images, output):
67-
click.echo("Splitting micrographs for training and validation...")
63+
@click.option("--star", type=str, required=True, help="Path to input STAR file (or labels directory if using --split-only)")
64+
@click.option("--images", type=str, required=True, help="Path to directory containing micrograph images")
65+
@click.option("--output", type=str, required=True, help="Path to output directory for organized train/val data")
66+
@click.option("--class-id", type=int, default=0, help="Class ID to assign to all particles (default: 0)")
67+
@click.option("--test-size", type=float, default=0.25, help="Proportion of dataset to use for validation (default: 0.25)")
68+
@click.option("--split-only", is_flag=True, help="Skip STAR conversion and only split existing labels")
69+
def split(star, images, output, class_id, test_size, split_only):
70+
if split_only:
71+
click.echo("Splitting existing labels into training and validation sets...")
72+
else:
73+
click.echo("Converting STAR file to YOLO format and splitting for training...")
6874
import partinet.process_utils.split_train
69-
partinet.process_utils.split_train.main(labels, images, output)
75+
partinet.process_utils.split_train.main(star, images, output, class_id, test_size, split_only)
7076

7177
@main.command()
7278
@click.option("--labels", type=str, required=True, help="Path to the labels directory")
7379
@click.option("--images", type=str, required=True, help="Path to the images directory")
7480
@click.option("--output", type=str, required=True, help="Path to the output STAR file")
75-
@click.option("--conf", type=float, default=0.0, help="Minimum confidence threshold from predictions")
81+
@click.option("--conf", type=float, default=0.1, help="Minimum confidence threshold from predictions")
7682
def star(labels, images, output,conf):
7783
click.echo("Generating STAR file...")
7884
import partinet.process_utils.star_file
@@ -100,7 +106,7 @@ def train():
100106
def step1(**params):
101107

102108
# dump params to terminal
103-
click.echo("Performing DynamicDet training step 1 with config:\n ", nl=False)
109+
click.echo("Performing PartiNet training step 1 with config:\n ", nl=False)
104110
params["img_size"] = list(params["img_size"])
105111
print_params(params)
106112

@@ -116,7 +122,7 @@ def step1(**params):
116122
@train_common_args
117123
def step2(**params):
118124

119-
click.echo("Performing DynamicDet training step 2 with config:\n ", nl=False)
125+
click.echo("Performing PartiNet training step 2 with config:\n ", nl=False)
120126
params["img_size"] = list(params["img_size"])
121127
print_params(params)
122128

@@ -129,13 +135,13 @@ def step2(**params):
129135
partinet.DynamicDet.train_step2.main(opt)
130136

131137
@main.command()
132-
@click.option('--backbone-detector', type=click.Choice(DYNAMICDET_AVAILABLE_MODELS, case_sensitive=False), help='The choice of backbone to be used.', default="yolov7", show_default=True)
138+
@click.option('--backbone-detector', type=click.Choice(DYNAMICDET_AVAILABLE_MODELS, case_sensitive=False), help='The choice of backbone to be used.', default="yolov7-w6", show_default=True)
133139
@click.option('--weight', type=str, help='model.pt path(s)', required=True)
134140
@click.option('--source', type=str, default='inference/images', help='source', show_default=True) # file/folder, 0 for webcam
135-
@click.option('--num-classes', type=int, default=80, help='number of classes', show_default=True)
136-
@click.option('--img-size', type=int, default=640, help='inference size (pixels)', show_default=True)
137-
@click.option('--conf-thres', type=float, default=0.25, help='object confidence threshold', show_default=True)
138-
@click.option('--iou-thres', type=float, default=0.45, help='IOU threshold for NMS', show_default=True)
141+
@click.option('--num-classes', type=int, default=1, help='number of classes', show_default=True)
142+
@click.option('--img-size', type=int, default=1280, help='inference size (pixels)', show_default=True)
143+
@click.option('--conf-thres', type=float, default=0.1, help='object confidence threshold', show_default=True)
144+
@click.option('--iou-thres', type=float, default=0.2, help='IOU threshold for NMS', show_default=True)
139145
@click.option('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu', show_default=True)
140146
@click.option('--view-img', is_flag=True, help='display results')
141147
@click.option('--save-txt', is_flag=True, help='save results to *.txt')
@@ -156,7 +162,7 @@ def detect(**params):
156162
# "all classes"
157163
params["classes"] = params["classes"] or None
158164

159-
click.echo("Performing DynamicDet detection with config:\n ", nl=False)
165+
click.echo("Performing PartiNet particle detection with config:\n ", nl=False)
160166
print_params(params)
161167

162168
import argparse
@@ -167,13 +173,13 @@ def detect(**params):
167173
partinet.DynamicDet.detect.detect(opt)
168174

169175
@main.command()
170-
@click.option('--backbone-detector', type=click.Choice(["yolov7", "yolov7-w6", "yolov7x"], case_sensitive=False), help='The choice of backbone to be used.', default="yolov7", show_default=True)
176+
@click.option('--backbone-detector', type=click.Choice(["yolov7", "yolov7-w6", "yolov7x"], case_sensitive=False), help='The choice of backbone to be used.', default="yolov7-w6", show_default=True)
171177
@click.option('--weight', type=str, help='model.pt path(s)', required=True)
172178
@click.option('--data', type=str, default='data/coco.yaml', help='data.yaml path', show_default=True)
173179
@click.option('--batch-size', type=int, default=1, help='total batch size for all GPUs', show_default=True)
174-
@click.option('--img-size', type=int, default=640, help='validation image size (pixels)', show_default=True)
175-
@click.option('--conf-thres', type=float, default=0.001, help='object confidence threshold', show_default=True)
176-
@click.option('--iou-thres', type=float, default=0.65, help='IOU threshold for NMS', show_default=True)
180+
@click.option('--img-size', type=int, default=1280, help='validation image size (pixels)', show_default=True)
181+
@click.option('--conf-thres', type=float, default=0.3, help='object confidence threshold', show_default=True)
182+
@click.option('--iou-thres', type=float, default=0.5, help='IOU threshold for NMS', show_default=True)
177183
@click.option('--task', type=click.Choice(["train", "val", "test"]), default="test", help='train, val, test, speed or study', show_default=True)
178184
@click.option('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu', show_default=True)
179185
@click.option('--single-cls', is_flag=True, help='train multi-class data as single-class') # Might not be needed if always doing single class
@@ -191,7 +197,7 @@ def detect(**params):
191197
@click.option('--save-results', is_flag=True, help='save results')
192198
def test(**params):
193199

194-
click.echo("Performing DynamicDet test with config:\n ", nl=False)
200+
click.echo("Performing PartiNet test with config:\n ", nl=False)
195201
print_params(params)
196202

197203
import argparse
@@ -202,4 +208,4 @@ def test(**params):
202208
partinet.DynamicDet.test.main(opt)
203209

204210
if __name__ == "__main__":
205-
main()
211+
main()

0 commit comments

Comments
 (0)