Skip to content

Commit f2bf780

Browse files
author
zylo117
committed
add boolean string convertion to make sure head_only works
1 parent bbceb2e commit f2bf780

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ ___
5252

5353
## Update Log
5454

55+
[2020-05-11] add boolean string convertion to make sure head_only works
56+
5557
[2020-05-10] replace nms with batched_nms to further improve mAP by 0.5~0.7, thanks [Laughing-q](https://github.com/Laughing-q).
5658

5759
[2020-05-04] fix coco category id mismatch bug, but it shouldn't affect training on custom dataset.

train.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def get_args():
3737
parser.add_argument('-c', '--compound_coef', type=int, default=0, help='coefficients of efficientdet')
3838
parser.add_argument('-n', '--num_workers', type=int, default=12, help='num_workers of dataloader')
3939
parser.add_argument('--batch_size', type=int, default=12, help='The number of images per batch among all devices')
40-
parser.add_argument('--head_only', type=bool, default=False,
40+
parser.add_argument('--head_only', type=boolean_string, default=False,
4141
help='whether finetunes only the regressor and the classifier, '
4242
'useful in early stage convergence or small/easy dataset')
4343
parser.add_argument('--lr', type=float, default=1e-4)
@@ -56,13 +56,19 @@ def get_args():
5656
parser.add_argument('-w', '--load_weights', type=str, default=None,
5757
help='whether to load weights from a checkpoint, set None to initialize, set \'last\' to load last checkpoint')
5858
parser.add_argument('--saved_path', type=str, default='logs/')
59-
parser.add_argument('--debug', type=bool, default=False, help='whether visualize the predicted boxes of trainging, '
59+
parser.add_argument('--debug', type=boolean_string, default=False, help='whether visualize the predicted boxes of trainging, '
6060
'the output images will be in test/')
6161

6262
args = parser.parse_args()
6363
return args
6464

6565

66+
def boolean_string(s):
67+
if s not in {'False', 'True'}:
68+
raise ValueError('Not a valid boolean string')
69+
return s == 'True'
70+
71+
6672
class ModelWithLoss(nn.Module):
6773
def __init__(self, model, debug=False):
6874
super().__init__()

0 commit comments

Comments
 (0)