MCPcopy Index your code
hub / github.com/drinkingcoder/NeuralMarker / run

Function run

evaluation_DVL.py:462–651  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

460 return result
461
462def run():
463 args = get_eval_args()
464
465 H, W = args.img_shape
466 if args.blend_type == 'L':
467 if args.source_id == -1:
468 raise FileExistsError('no source image id specified.')
469
470 # ============== Environ Setting ================
471 print('gpu id:', os.environ["CUDA_VISIBLE_DEVICES"])
472
473 # ============== Path Setting ===================
474 print('\n===> Path Config')
475 # marker / scene images root
476 marker_root = os.path.join(args.root, 'marker')
477 if args.folder != "" :
478 scene_root = os.path.join(args.root, args.folder)
479 args.save_root = os.path.join(args.save_root, args.folder)
480 else:
481 assert args.blend_type in ['D','V','L']
482 scene_root = os.path.join(args.root, args.blend_type)
483 args.save_root = os.path.join(args.save_root, args.blend_type)
484 assert os.path.exists(scene_root) and os.path.exists(marker_root)
485 print(f"Loading marker from: {marker_root}")
486 print(f"Loading scene image from: {scene_root}")
487 # save root
488 if args.save:
489 time = datetime.datetime.now()
490 suffix = datetime.datetime.strftime(time, '%m%d%H')
491 if args.with_mask:
492 args.save_root = os.path.join(args.save_root, args.blend_method+'_mask_'+suffix)
493 else:
494 args.save_root = os.path.join(args.save_root, args.blend_method+'_'+suffix)
495 os.makedirs(args.save_root, exist_ok=True)
496 print('Save image to: '+args.save_root)
497
498 # =============== Data Loading ===================
499 print('\n===> Data Loading')
500 blend_type = {'D':'deformation', 'V':'viewpoint', 'L':'light'}
501 if H > W:
502 H, W = W, H #keep H < W
503 scene_images = []
504 marker_images = []
505 for id in tqdm(range(args.start_img_id, args.start_img_id+args.img_num), desc='Loading Image', total=args.img_num):
506 scene_image = []
507 for i in range(args.start_scene_id, args.start_scene_id+args.scn_num):
508 scene_path = os.path.join(scene_root, str(id).zfill(4) + "_" + blend_type[args.blend_type] + "_"+str(i)+".jpg")
509 scene = io.imread(scene_path)
510 ## numpy shape(height, width); cv size (width, height)
511 if scene.shape[0] > scene.shape[1]: # origin H > origin W
512 scene = cv2.resize(scene, (H, W))
513 else: # origin H < origin W
514 scene = cv2.resize(scene, (W, H))
515 scene_image.append(scene)
516 scene_images.append(scene_image)
517
518 marker_path = os.path.join(marker_root, str(id).zfill(4) + ".jpg")
519 marker_image = io.imread(marker_path)

Callers 1

evaluation_DVL.pyFile · 0.85

Calls 4

get_eval_argsFunction · 0.90
get_twins_argsFunction · 0.90
Flow_estimatorClass · 0.90
evalFunction · 0.85

Tested by

no test coverage detected