Skip to content

Commit 7e4e689

Browse files
authored
Merge pull request #12 from WEHI-ResearchComputing/add-configs
Package configs into partinet
2 parents a672eb6 + ebc0ae0 commit 7e4e689

4 files changed

Lines changed: 128 additions & 112 deletions

File tree

README.md

Lines changed: 121 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -110,49 +110,55 @@ partinet train step1 --help
110110
Usage: partinet train step1 [OPTIONS]
111111
112112
Options:
113-
--cfg TEXT model.yaml path [required]
114-
--weight TEXT initial weights path [required]
115-
--data TEXT data.yaml path [default: data/coco.yaml]
116-
--hyp TEXT hyperparameters path [default:
117-
hyp/hyp.scratch.p5.yaml]
118-
--epochs INTEGER [default: 300]
119-
--batch-size INTEGER total batch size for all GPUs [default: 16]
120-
--img-size INTEGER... [train, test] image sizes [default: 640, 640]
121-
--rect rectangular training
122-
--resume resume most recent training
123-
--resume-ckpt TEXT checkpoint to resume from
124-
--nosave only save final checkpoint
125-
--notest only test final epoch
126-
--noautoanchor disable autoanchor check
127-
--bucket TEXT gsutil bucket
128-
--cache-images cache images for faster training
129-
--image-weights use weighted image selection for training
130-
--device TEXT cuda device, i.e. 0 or 0,1,2,3 or cpu
131-
--multi-scale vary img-size +/- 50%%
132-
--single-cls train multi-class data as single-class
133-
--adam use torch.optim.Adam() optimizer
134-
--sync-bn use SyncBatchNorm, only available in DDP mode
135-
--local_rank INTEGER DDP parameter, do not modify [default: -1]
136-
--workers INTEGER maximum number of dataloader workers [default: 8]
137-
--project TEXT save to project/name [default: runs/train]
138-
--entity TEXT W&B entity
139-
--name TEXT save to project/name [default: exp]
140-
--exist-ok existing project/name ok, do not increment
141-
--quad quad dataloader
142-
--label-smoothing FLOAT Label smoothing epsilon [default: 0.0]
143-
--upload_dataset Upload dataset as W&B artifact table
144-
--bbox_interval INTEGER Set bounding-box image logging interval for W&B
145-
[default: -1]
146-
--save_period INTEGER Log model after every "save_period" epoch
147-
[default: -1]
148-
--artifact_alias TEXT version of dataset artifact to be used [default:
149-
latest]
150-
--freeze INTEGER Freeze layers: backbone of yolov7=50, first3=0 1 2
151-
[default: 0]
152-
--v5-metric assume maximum recall as 1.0 in AP calculation
153-
--single-backbone train single backbone model
154-
--linear-lr linear LR
155-
--help Show this message and exit.
113+
--backbone-detector [yolov7|yolov7-w6|yolov7x]
114+
The choice of backbone to be used.
115+
[default: yolov7]
116+
--weight TEXT initial weights path [required]
117+
--data TEXT data.yaml path [default: data/coco.yaml]
118+
--hyp [scratch.p5|scratch.p6|finetune.dynamic.adam]
119+
hyperparameters path [default: scratch.p5]
120+
--epochs INTEGER [default: 300]
121+
--batch-size INTEGER total batch size for all GPUs [default: 16]
122+
--img-size INTEGER... [train, test] image sizes [default: 640,
123+
640]
124+
--rect rectangular training
125+
--resume resume most recent training
126+
--resume-ckpt TEXT checkpoint to resume from
127+
--nosave only save final checkpoint
128+
--notest only test final epoch
129+
--noautoanchor disable autoanchor check
130+
--bucket TEXT gsutil bucket
131+
--cache-images cache images for faster training
132+
--image-weights use weighted image selection for training
133+
--device TEXT cuda device, i.e. 0 or 0,1,2,3 or cpu
134+
--multi-scale vary img-size +/- 50%%
135+
--single-cls train multi-class data as single-class
136+
--adam use torch.optim.Adam() optimizer
137+
--sync-bn use SyncBatchNorm, only available in DDP
138+
mode
139+
--local_rank INTEGER DDP parameter, do not modify [default: -1]
140+
--workers INTEGER maximum number of dataloader workers
141+
[default: 8]
142+
--project TEXT save to project/name [default: runs/train]
143+
--entity TEXT W&B entity
144+
--name TEXT save to project/name [default: exp]
145+
--exist-ok existing project/name ok, do not increment
146+
--quad quad dataloader
147+
--label-smoothing FLOAT Label smoothing epsilon [default: 0.0]
148+
--upload_dataset Upload dataset as W&B artifact table
149+
--bbox_interval INTEGER Set bounding-box image logging interval for
150+
W&B [default: -1]
151+
--save_period INTEGER Log model after every "save_period" epoch
152+
[default: -1]
153+
--artifact_alias TEXT version of dataset artifact to be used
154+
[default: latest]
155+
--freeze INTEGER Freeze layers: backbone of yolov7=50,
156+
first3=0 1 2 [default: 0]
157+
--v5-metric assume maximum recall as 1.0 in AP
158+
calculation
159+
--single-backbone train single backbone model
160+
--linear-lr linear LR
161+
--help Show this message and exit.
156162
```
157163

158164
TODO: more details...
@@ -170,84 +176,91 @@ subsubcommand.
170176
Usage: partinet train step2 [OPTIONS]
171177
172178
Options:
173-
--cfg TEXT model.yaml path [required]
174-
--weight TEXT initial weights path [required]
175-
--data TEXT data.yaml path [default: data/coco.yaml]
176-
--hyp TEXT hyperparameters path [default:
177-
hyp/hyp.scratch.p5.yaml]
178-
--epochs INTEGER [default: 300]
179-
--batch-size INTEGER total batch size for all GPUs [default: 16]
180-
--img-size INTEGER... [train, test] image sizes [default: 640, 640]
181-
--rect rectangular training
182-
--resume resume most recent training
183-
--resume-ckpt TEXT checkpoint to resume from
184-
--nosave only save final checkpoint
185-
--notest only test final epoch
186-
--noautoanchor disable autoanchor check
187-
--bucket TEXT gsutil bucket
188-
--cache-images cache images for faster training
189-
--image-weights use weighted image selection for training
190-
--device TEXT cuda device, i.e. 0 or 0,1,2,3 or cpu
191-
--multi-scale vary img-size +/- 50%%
192-
--single-cls train multi-class data as single-class
193-
--adam use torch.optim.Adam() optimizer
194-
--sync-bn use SyncBatchNorm, only available in DDP mode
195-
--local_rank INTEGER DDP parameter, do not modify [default: -1]
196-
--workers INTEGER maximum number of dataloader workers [default: 8]
197-
--project TEXT save to project/name [default: runs/train]
198-
--entity TEXT W&B entity
199-
--name TEXT save to project/name [default: exp]
200-
--exist-ok existing project/name ok, do not increment
201-
--quad quad dataloader
202-
--label-smoothing FLOAT Label smoothing epsilon [default: 0.0]
203-
--upload_dataset Upload dataset as W&B artifact table
204-
--bbox_interval INTEGER Set bounding-box image logging interval for W&B
205-
[default: -1]
206-
--save_period INTEGER Log model after every "save_period" epoch
207-
[default: -1]
208-
--artifact_alias TEXT version of dataset artifact to be used [default:
209-
latest]
210-
--freeze INTEGER Freeze layers: backbone of yolov7=50, first3=0 1 2
211-
[default: 0]
212-
--v5-metric assume maximum recall as 1.0 in AP calculation
213-
--help Show this message and exit.
179+
--backbone-detector [yolov7|yolov7-w6|yolov7x]
180+
The choice of backbone to be used.
181+
[default: yolov7]
182+
--weight TEXT initial weights path [required]
183+
--data TEXT data.yaml path [default: data/coco.yaml]
184+
--hyp [scratch.p5|scratch.p6|finetune.dynamic.adam]
185+
hyperparameters path [default: scratch.p5]
186+
--epochs INTEGER [default: 300]
187+
--batch-size INTEGER total batch size for all GPUs [default: 16]
188+
--img-size INTEGER... [train, test] image sizes [default: 640,
189+
640]
190+
--rect rectangular training
191+
--resume resume most recent training
192+
--resume-ckpt TEXT checkpoint to resume from
193+
--nosave only save final checkpoint
194+
--notest only test final epoch
195+
--noautoanchor disable autoanchor check
196+
--bucket TEXT gsutil bucket
197+
--cache-images cache images for faster training
198+
--image-weights use weighted image selection for training
199+
--device TEXT cuda device, i.e. 0 or 0,1,2,3 or cpu
200+
--multi-scale vary img-size +/- 50%%
201+
--single-cls train multi-class data as single-class
202+
--adam use torch.optim.Adam() optimizer
203+
--sync-bn use SyncBatchNorm, only available in DDP
204+
mode
205+
--local_rank INTEGER DDP parameter, do not modify [default: -1]
206+
--workers INTEGER maximum number of dataloader workers
207+
[default: 8]
208+
--project TEXT save to project/name [default: runs/train]
209+
--entity TEXT W&B entity
210+
--name TEXT save to project/name [default: exp]
211+
--exist-ok existing project/name ok, do not increment
212+
--quad quad dataloader
213+
--label-smoothing FLOAT Label smoothing epsilon [default: 0.0]
214+
--upload_dataset Upload dataset as W&B artifact table
215+
--bbox_interval INTEGER Set bounding-box image logging interval for
216+
W&B [default: -1]
217+
--save_period INTEGER Log model after every "save_period" epoch
218+
[default: -1]
219+
--artifact_alias TEXT version of dataset artifact to be used
220+
[default: latest]
221+
--freeze INTEGER Freeze layers: backbone of yolov7=50,
222+
first3=0 1 2 [default: 0]
223+
--v5-metric assume maximum recall as 1.0 in AP
224+
calculation
225+
--help Show this message and exit.
214226
```
215227

216228
TODO: more details...
217229
Example
218230
```bash
219-
partinet train step2 --cfg partinet/DynamicDet/cfg/dy-yolov7-step2.yaml --weight /path/to/runs/train/train-step1-300epochs/weights/last.pt --workers 4 --device 0 --batch-size 1 --epochs 10 --img-size 640 640 --adam --data /path/to/cryo_training_all.yaml --hyp partinet/DynamicDet/hyp/hyp.finetune.dynamic.adam.yaml --name train_step2
231+
partinet train step2 --backbone-detector yolov7 --weight /path/to/runs/train/train-step1-300epochs/weights/last.pt --workers 4 --device 0 --batch-size 1 --epochs 10 --img-size 640 640 --adam --data /path/to/cryo_training_all.yaml --hyp finetune.dynamic.adam --name train_step2
220232
```
221233
## Detection
222234

223235
```bash
224236
partinet detect --help
225237
```
226238
```
227-
Usage: partinet detect [OPTIONS]
228-
229239
Options:
230-
--cfg TEXT model.yaml path [required]
231-
--weight TEXT model.pt path(s) [required]
232-
--source TEXT source [default: inference/images]
233-
--num-classes INTEGER number of classes [default: 80]
234-
--img-size INTEGER inference size (pixels) [default: 640]
235-
--conf-thres FLOAT object confidence threshold [default: 0.25]
236-
--iou-thres FLOAT IOU threshold for NMS [default: 0.45]
237-
--device TEXT cuda device, i.e. 0 or 0,1,2,3 or cpu
238-
--view-img display results
239-
--save-txt save results to *.txt
240-
--save-conf save confidences in --save-txt labels
241-
--nosave do not save images/videos
242-
--classes INTEGER filter by class: --classes 0, or --classes 0
243-
--classes 2 --classes 3
244-
--agnostic-nms class-agnostic NMS
245-
--augment augmented inference
246-
--project TEXT save results to project/name [default: runs/detect]
247-
--name TEXT save results to project/name [default: exp]
248-
--exist-ok existing project/name ok, do not increment
249-
--dy-thres FLOAT dynamic thres [default: 0.5]
250-
--help Show this message and exit.
240+
--backbone-detector [yolov7|yolov7-w6|yolov7x]
241+
The choice of backbone to be used.
242+
[default: yolov7]
243+
--weight TEXT model.pt path(s) [required]
244+
--source TEXT source [default: inference/images]
245+
--num-classes INTEGER number of classes [default: 80]
246+
--img-size INTEGER inference size (pixels) [default: 640]
247+
--conf-thres FLOAT object confidence threshold [default: 0.25]
248+
--iou-thres FLOAT IOU threshold for NMS [default: 0.45]
249+
--device TEXT cuda device, i.e. 0 or 0,1,2,3 or cpu
250+
--view-img display results
251+
--save-txt save results to *.txt
252+
--save-conf save confidences in --save-txt labels
253+
--nosave do not save images/videos
254+
--classes INTEGER filter by class: --classes 0, or --classes 0
255+
--classes 2 --classes 3
256+
--agnostic-nms class-agnostic NMS
257+
--augment augmented inference
258+
--project TEXT save results to project/name [default:
259+
runs/detect]
260+
--name TEXT save results to project/name [default: exp]
261+
--exist-ok existing project/name ok, do not increment
262+
--dy-thres FLOAT dynamic thres [default: 0.5]
263+
--help Show this message and exit.
251264
```
252265

253266
TODO: more details...

partinet/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ def train_common_args(f):
4545
f = click.option('--img-size', nargs=2, type=int, default=[640, 640], help='[train, test] image sizes', show_default=True)(f)
4646
f = click.option('--batch-size', type=int, default=16, help='total batch size for all GPUs', show_default=True)(f)
4747
f = click.option('--epochs', type=int, default=300, show_default=True)(f)
48-
f = click.option('--hyp', type=str, default='hyp/hyp.scratch.p5.yaml', help='hyperparameters path', show_default=True)(f)
48+
f = click.option('--hyp', type=click.Choice(["scratch.p5", "scratch.p6", "finetune.dynamic.adam"]), default='scratch.p5', help='hyperparameters path', show_default=True)(f)
4949
f = click.option('--data', type=str, default='data/coco.yaml', help='data.yaml path', show_default=True)(f)
5050
f = click.option('--weight', type=str, help='initial weights path', required=True)(f)
51-
f = click.option('--cfg', type=str, help='model.yaml path', required=True)(f)
51+
f = 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)(f)
5252

5353
return f
5454

@@ -102,7 +102,7 @@ def step2(**params):
102102
partinet.DynamicDet.train_step2.main(opt)
103103

104104
@main.command()
105-
@click.option('--cfg', type=str, help='model.yaml path', required=True)
105+
@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)
106106
@click.option('--weight', type=str, help='model.pt path(s)', required=True)
107107
@click.option('--source', type=str, default='inference/images', help='source', show_default=True) # file/folder, 0 for webcam
108108
@click.option('--num-classes', type=int, default=80, help='number of classes', show_default=True)

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ build-backend = "setuptools.build_meta"
5151
where = ["."]
5252
include = ["partinet*"]
5353

54+
[tool.setuptools.package-data]
55+
"*" = ["dy-*.yaml", "hyp.*.yaml"]
56+
5457
[tool.setuptools.dynamic]
5558
version = {attr = "partinet.__version__"}
5659

0 commit comments

Comments
 (0)