@@ -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+
6672class ModelWithLoss (nn .Module ):
6773 def __init__ (self , model , debug = False ):
6874 super ().__init__ ()
0 commit comments