checkpoint_path and argparse error happend

398 Views Asked by At
def main(params):
    # load the checkpoint
    checkpoint_path = params['checkpoint_path']
    max_images = params['max_images']

    print ('loading checkpoint %s' % (checkpoint_path, ))
    checkpoint = pickle.load(open(checkpoint_path, 'rb'))
    checkpoint_params = checkpoint['params']
    dataset = checkpoint_params['dataset']
    model = checkpoint['model']
   dump_folder = params['dump_folder']
   ...
   ...
   ...
if __name__ == "__main__":
  parser = argparse.ArgumentParser()
  parser.add_argument('checkpoint_path', type=str, help='the input checkpoint')
  parser.add_argument('-b', '--beam_size', type=int, default=1, help='beam size in inference. 1 
  indicates greedy per-word max procedure. Good value is approx 20 or so, and more = better.')
  parser.add_argument('--result_struct_filename', type=str, default='result_struct.json', 
  help='filename of the result struct to save')
  parser.add_argument('-m', '--max_images', type=int, default=-1, help='max images to use')
  parser.add_argument('-d', '--dump_folder', type=str, default="", help='dump the relevant images to 
  a separate folder with this name?')

  args = parser.parse_args()
  params = vars(args) # convert to ordinary dict
  print ('parsed parameters:')
  print (json.dumps(params, indent = 2))
  main(params)

enter image description here

I fix parser.add_argument('-checkpoint_path', type=str, help='the input checkpoint') and next problem showed up in checkpoint_path = params['checkpoint_path'].

I tried to putting a file like D:\neuraltalk\cv\model_checkpoint_flickr8k_DESKTOP-4PPS67A_baseline_26.76.p but it doesn't work...

please help me

1

There are 1 best solutions below

0
On

I solve this problem on my own.

just changed a line of code

checkpoint_path = 'D:\\neuraltalk\cv\\model_checkpoint_flickr8k_DESKTOP-4PPS67A_baseline_17.10.p'