def main():
parser = get_parser()
try:
args = parser.parse_args()
except:
sys.exit(0)
# if environment logging variable not set, make silent
if args.debug == False:
os.environ['MESSAGELEVEL'] = "CRITICAL"
# Tell the user what is going to be used, in case is incorrect
from logman import bot
from predict_image import Model
from utils import get_image, write_json
print("\n*** Starting Bone Age Prediction ****")
# Get the gender
is_male = True
if args.gender == "F":
is_male = False
# If the user has not provided an image, use an example
image = args.image
if image == None:
print("No image selected, will use provided example...")
from utils import select_example_image
image = select_example_image(start=0,end=9)
is_male = True # all examples male
# Print parameters for user
bot.logger.debug("is_male: %s", is_male)
bot.logger.debug("image: %s", image)
bot.logger.debug("height: %s", args.height)
bot.logger.debug("width: %s", args.width)
# Get the array of data (uint8) - H/W should be set to 256
image_path = image
image = get_image(image_path=image,
warped_height=args.height,
warped_width=args.width)
print("Building model, please wait.")
model = Model()
result = model.get_result(image=image,
image_path=image_path,
is_male=is_male)
print('Predicted Age : %d Months' %result['predicted_age'])
print('Weighted Prediction : %f Months' %result['predicted_weight'])
if args.output != None:
output = write_json(json_object=result,
filename=args.output)
bot.logger.debug('Result written to %s',args.output)
评论列表
文章目录