print("\n Time taken to load Images: %s " % (time.time() - start_time)) print("\n Test Dataset Shape: {shape}".format(shape=np.shape(depth_dataset))) # ### Importing the Model from Mobile_model import Model model = Model().cuda() model = nn.DataParallel(model) # Import the Pre-trained Model model.load_state_dict(torch.load(pretrained_path)) print("\n Loaded MobileNet U-Net Weights successfully\n") model.eval() # ### Model Variables (state_dict) # print("\n\nModel's state_dict:\n\n") # for param_tensor in model.state_dict(): # print(param_tensor, "\t", model.state_dict()[param_tensor].size()) # ## Generating Depth Images start_time = time.time() for i, sample_batched1 in enumerate(train_loader): input_image = torch.autograd.Variable(sample_batched1['image'].cuda())
help='Image size of network input') parser.add_argument('--data_dir', default='comarision_datasets\input', type=str, help='Data path') parser.add_argument( '--result_dir', default='demo_results', type=str, help='Directory for saving results, default: demo_results') parser.add_argument('--gpu_id', default=0, type=int, help='GPU id, default:0') args = parser.parse_args() if not os.path.exists(args.result_dir): os.makedirs(args.result_dir) gpu_id = args.gpu_id torch.cuda.device(gpu_id) net = Model().cuda() net.load_state_dict(torch.load('weights_model.pth')) net.eval() print('Begin to test ...') with torch.no_grad(): demo(net, args) print('Finished!')