-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from Megvii-BaseDetection/add-sche-exps
[Enhance]: Add sche exps.
- Loading branch information
Showing
8 changed files
with
308 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
exps/bev_depth_lss_r50_256x704_128x128_20e_cbgs_2key_da_ema.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Copyright (c) Megvii Inc. All rights reserved. | ||
""" | ||
mAP: 0.3589 | ||
mATE: 0.6119 | ||
mASE: 0.2692 | ||
mAOE: 0.5074 | ||
mAVE: 0.4086 | ||
mAAE: 0.2009 | ||
NDS: 0.4797 | ||
Eval time: 183.3s | ||
Per-class results: | ||
Object Class AP ATE ASE AOE AVE AAE | ||
car 0.559 0.475 0.157 0.112 0.370 0.205 | ||
truck 0.270 0.659 0.196 0.103 0.356 0.181 | ||
bus 0.374 0.651 0.184 0.072 0.846 0.326 | ||
trailer 0.179 0.963 0.227 0.512 0.294 0.127 | ||
construction_vehicle 0.081 0.825 0.481 1.352 0.094 0.345 | ||
pedestrian 0.363 0.690 0.297 0.831 0.491 0.244 | ||
motorcycle 0.354 0.580 0.255 0.545 0.615 0.164 | ||
bicycle 0.301 0.447 0.280 0.920 0.203 0.015 | ||
traffic_cone 0.539 0.435 0.324 nan nan nan | ||
barrier 0.569 0.394 0.293 0.120 nan nan | ||
""" | ||
from argparse import ArgumentParser, Namespace | ||
|
||
import pytorch_lightning as pl | ||
import torch | ||
|
||
from callbacks.ema import EMACallback | ||
from exps.bev_depth_lss_r50_256x704_128x128_20e_cbgs_2key_da import \ | ||
BEVDepthLightningModel as BaseBEVDepthLightningModel | ||
|
||
|
||
class BEVDepthLightningModel(BaseBEVDepthLightningModel): | ||
def __init__(self, **kwargs): | ||
super().__init__(**kwargs) | ||
self.data_use_cbgs = True | ||
|
||
def configure_optimizers(self): | ||
lr = self.basic_lr_per_img * \ | ||
self.batch_size_per_device * self.gpus | ||
optimizer = torch.optim.AdamW(self.model.parameters(), | ||
lr=lr, | ||
weight_decay=1e-2) | ||
return [optimizer] | ||
|
||
|
||
def main(args: Namespace) -> None: | ||
if args.seed is not None: | ||
pl.seed_everything(args.seed) | ||
|
||
model = BEVDepthLightningModel(**vars(args)) | ||
train_dataloader = model.train_dataloader() | ||
ema_callback = EMACallback(len(train_dataloader.dataset) * args.max_epochs) | ||
trainer = pl.Trainer.from_argparse_args(args, callbacks=[ema_callback]) | ||
if args.evaluate: | ||
trainer.test(model, ckpt_path=args.ckpt_path) | ||
else: | ||
trainer.fit(model) | ||
|
||
|
||
def run_cli(): | ||
parent_parser = ArgumentParser(add_help=False) | ||
parent_parser = pl.Trainer.add_argparse_args(parent_parser) | ||
parent_parser.add_argument('-e', | ||
'--evaluate', | ||
dest='evaluate', | ||
action='store_true', | ||
help='evaluate model on validation set') | ||
parent_parser.add_argument('-b', '--batch_size_per_device', type=int) | ||
parent_parser.add_argument('--seed', | ||
type=int, | ||
default=0, | ||
help='seed for initializing training.') | ||
parent_parser.add_argument('--ckpt_path', type=str) | ||
parser = BEVDepthLightningModel.add_model_specific_args(parent_parser) | ||
parser.set_defaults(profiler='simple', | ||
deterministic=False, | ||
max_epochs=20, | ||
accelerator='ddp', | ||
num_sanity_val_steps=0, | ||
gradient_clip_val=5, | ||
limit_val_batches=0, | ||
enable_checkpointing=False, | ||
precision=16, | ||
default_root_dir='./outputs/bev_depth_lss_r50_' | ||
'256x704_128x128_20e_cbgs_2key_da_ema') | ||
args = parser.parse_args() | ||
main(args) | ||
|
||
|
||
if __name__ == '__main__': | ||
run_cli() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# Copyright (c) Megvii Inc. All rights reserved. | ||
""" | ||
mAP: 0.3329 | ||
mATE: 0.6832 | ||
mASE: 0.2761 | ||
mAOE: 0.5446 | ||
mAVE: 0.5258 | ||
mAAE: 0.2259 | ||
NDS: 0.4409 | ||
Per-class results: | ||
Object Class AP ATE ASE AOE AVE AAE | ||
car 0.505 0.531 0.165 0.189 0.618 0.234 | ||
truck 0.274 0.731 0.206 0.211 0.546 0.223 | ||
bus 0.394 0.673 0.219 0.148 1.061 0.274 | ||
trailer 0.174 0.934 0.228 0.544 0.369 0.183 | ||
construction_vehicle 0.079 1.043 0.528 1.162 0.112 0.376 | ||
pedestrian 0.284 0.748 0.294 0.973 0.575 0.297 | ||
motorcycle 0.345 0.633 0.256 0.719 0.667 0.214 | ||
bicycle 0.314 0.544 0.252 0.778 0.259 0.007 | ||
traffic_cone 0.453 0.519 0.335 nan nan nan | ||
barrier 0.506 0.475 0.279 0.178 nan nan | ||
""" | ||
from argparse import ArgumentParser, Namespace | ||
|
||
import pytorch_lightning as pl | ||
|
||
from callbacks.ema import EMACallback | ||
from exps.bev_depth_lss_r50_256x704_128x128_24e_ema import \ | ||
BEVDepthLightningModel as BaseBEVDepthLightningModel | ||
from models.bev_depth import BEVDepth | ||
|
||
|
||
class BEVDepthLightningModel(BaseBEVDepthLightningModel): | ||
def __init__(self, **kwargs): | ||
super().__init__(**kwargs) | ||
self.key_idxes = [-1] | ||
self.head_conf['bev_backbone_conf']['in_channels'] = 80 * ( | ||
len(self.key_idxes) + 1) | ||
self.head_conf['bev_neck_conf']['in_channels'] = [ | ||
80 * (len(self.key_idxes) + 1), 160, 320, 640 | ||
] | ||
self.head_conf['train_cfg']['code_weight'] = [ | ||
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 | ||
] | ||
self.model = BEVDepth(self.backbone_conf, | ||
self.head_conf, | ||
is_train_depth=True) | ||
|
||
|
||
def main(args: Namespace) -> None: | ||
if args.seed is not None: | ||
pl.seed_everything(args.seed) | ||
|
||
model = BEVDepthLightningModel(**vars(args)) | ||
train_dataloader = model.train_dataloader() | ||
ema_callback = EMACallback(len(train_dataloader.dataset) * args.max_epochs) | ||
trainer = pl.Trainer.from_argparse_args(args, callbacks=[ema_callback]) | ||
if args.evaluate: | ||
trainer.test(model, ckpt_path=args.ckpt_path) | ||
else: | ||
trainer.fit(model) | ||
|
||
|
||
def run_cli(): | ||
parent_parser = ArgumentParser(add_help=False) | ||
parent_parser = pl.Trainer.add_argparse_args(parent_parser) | ||
parent_parser.add_argument('-e', | ||
'--evaluate', | ||
dest='evaluate', | ||
action='store_true', | ||
help='evaluate model on validation set') | ||
parent_parser.add_argument('-b', '--batch_size_per_device', type=int) | ||
parent_parser.add_argument('--seed', | ||
type=int, | ||
default=0, | ||
help='seed for initializing training.') | ||
parent_parser.add_argument('--ckpt_path', type=str) | ||
parser = BEVDepthLightningModel.add_model_specific_args(parent_parser) | ||
parser.set_defaults(profiler='simple', | ||
deterministic=False, | ||
max_epochs=24, | ||
accelerator='ddp', | ||
num_sanity_val_steps=0, | ||
gradient_clip_val=5, | ||
limit_val_batches=0, | ||
enable_checkpointing=False, | ||
precision=16, | ||
default_root_dir='./outputs/bev_depth_lss_r50_256x704_' | ||
'128x128_24e_2key_ema') | ||
args = parser.parse_args() | ||
main(args) | ||
|
||
|
||
if __name__ == '__main__': | ||
run_cli() |
Oops, something went wrong.