2018-10-20 04:11:20 +00:00
import argparse
2019-04-01 11:06:09 +00:00
def str2floatarr ( v ) :
if type ( v ) == str :
try :
return [ float ( v ) for v in v . split ( ' , ' ) ]
except :
raise argparse . ArgumentTypeError ( ' Integers seperated by commas expected. ' )
else :
raise argparse . ArgumentTypeError ( ' Integers seperated by commas expected. ' )
2018-10-20 04:11:20 +00:00
def str2bool ( v ) :
if v . lower ( ) in ( ' yes ' , ' true ' , ' t ' , ' y ' , ' 1 ' , True ) :
return True
elif v . lower ( ) in ( ' no ' , ' false ' , ' f ' , ' n ' , ' 0 ' , False ) :
return False
else :
raise argparse . ArgumentTypeError ( ' Boolean value expected. ' )
def get_args ( ) :
parser = argparse . ArgumentParser ( description = ' ' )
#Input output folders settings
2018-10-21 03:46:56 +00:00
parser . add_argument ( ' --decensor_input_path ' , dest = ' decensor_input_path ' , default = ' ./decensor_input/ ' , help = ' input images with censored regions colored green to be decensored by decensor.py path ' )
parser . add_argument ( ' --decensor_input_original_path ' , dest = ' decensor_input_original_path ' , default = ' ./decensor_input_original/ ' , help = ' input images with no modifications to be decensored by decensor.py path ' )
2018-10-20 04:11:20 +00:00
parser . add_argument ( ' --decensor_output_path ' , dest = ' decensor_output_path ' , default = ' ./decensor_output/ ' , help = ' output images generated from running decensor.py path ' )
#Decensor settings
2019-04-01 11:06:09 +00:00
parser . add_argument ( ' --mask_color ' , dest = ' mask_color ' , default = [ 0 , 255 , 0 ] , type = str2floatarr , help = ' rgb color of the mask, comma seperated. ' )
2018-10-20 04:11:20 +00:00
parser . add_argument ( ' --is_mosaic ' , dest = ' is_mosaic ' , default = ' False ' , type = str2bool , help = ' true if image has mosaic censoring, false otherwise ' )
2019-07-21 20:06:08 +00:00
#Misc settings
parser . add_argument ( ' --autoclose ' , dest = ' autoclose ' , default = ' False ' , type = str2bool , help = ' true will close the program when it finishes ' )
2018-10-20 04:11:20 +00:00
args = parser . parse_args ( )
return args
if __name__ == ' __main__ ' :
2019-07-21 20:06:08 +00:00
get_args ( )