def _init_inputs(self): original_noises = create_augmentations( torch_to_np( get_noise(self.input_depth, 'noise', (self.images[0].shape[1], self.images[0].shape[2]), var=1 / 10.).type(torch.cuda.FloatTensor).detach())) self.image_net_inputs = [ np_to_torch(original_noise).type(torch.cuda.FloatTensor).detach() for original_noise in original_noises ] original_noises = create_augmentations( torch_to_np( get_noise(self.input_depth, 'noise', (self.images[0].shape[1], self.images[0].shape[2]), var=1 / 10.).type(torch.cuda.FloatTensor).detach())) self.mask_net_inputs = [ np_to_torch(original_noise).type(torch.cuda.FloatTensor).detach() for original_noise in original_noises ] if self._is_learning_ambient(): self.ambient_net_input = get_noise( self.input_depth, 'meshgrid', (self.images[0].shape[1], self.images[0].shape[2])).type( torch.cuda.FloatTensor).detach()
def _init_noise(self): input_type = 'noise' # self.left_net_inputs = self.images_torch self.clean_nets_inputs = [] for image_idx in range(len(self.images)): original_noise = get_noise( self.input_depth, input_type, (self.images_torch[image_idx][0].shape[2], self.images_torch[image_idx][0].shape[3])).type( torch.cuda.FloatTensor).detach() augmentations = create_augmentations(torch_to_np(original_noise)) self.clean_nets_inputs.append([ np_to_torch(aug).type(torch.cuda.FloatTensor).detach() for aug in augmentations ]) original_noise = get_noise(self.input_depth, input_type, (self.images_torch[0][0].shape[2], self.images_torch[0][0].shape[3])).type( torch.cuda.FloatTensor).detach() augmentations = create_augmentations(torch_to_np(original_noise)) self.mask_net_input = [ np_to_torch(aug).type(torch.cuda.FloatTensor).detach() for aug in augmentations ] original_noise = get_noise(self.input_depth, input_type, (self.images_torch[0][0].shape[2], self.images_torch[0][0].shape[3])).type( torch.cuda.FloatTensor).detach() augmentations = create_augmentations(torch_to_np(original_noise)) self.watermark_net_input = [ np_to_torch(aug).type(torch.cuda.FloatTensor).detach() for aug in augmentations ]
def _init_noise(self): input_type = 'noise' # self.left_net_inputs = self.images_torch clean_net_inputs = create_augmentations( torch_to_np( get_noise(self.input_depth, input_type, (self.image_torchs[0].shape[2], self.image_torchs[0].shape[3])).type( torch.cuda.FloatTensor).detach())) self.clean_net_inputs = [ np_to_torch(clean_net_input).type(torch.cuda.FloatTensor).detach() for clean_net_input in clean_net_inputs ] watermark_net_inputs = create_augmentations( torch_to_np( get_noise(self.input_depth, input_type, (self.image_torchs[0].shape[2], self.image_torchs[0].shape[3])).type( torch.cuda.FloatTensor).detach())) self.watermark_net_inputs = [ np_to_torch(clean_net_input).type(torch.cuda.FloatTensor).detach() for clean_net_input in watermark_net_inputs ] mask_net_inputs = create_augmentations( torch_to_np( get_noise(self.input_depth, input_type, (self.image_torchs[0].shape[2], self.image_torchs[0].shape[3])).type( torch.cuda.FloatTensor).detach())) self.mask_net_inputs = [ np_to_torch(clean_net_input).type(torch.cuda.FloatTensor).detach() for clean_net_input in mask_net_inputs ]
def _init_noise(self): input_type = 'noise' self.net_input1 = get_noise( self.input_depth, input_type, (self.image_torch1.shape[2], self.image_torch1.shape[3])).type( torch.cuda.FloatTensor).detach() self.net_input2 = get_noise( self.input_depth, input_type, (self.image_torch2.shape[2], self.image_torch2.shape[3])).type( torch.cuda.FloatTensor).detach()
def _init_noise(self): input_type = 'noise' # self.left_net_inputs = self.images_torch self.left_net_inputs = [get_noise(self.input_depth, input_type, (image.shape[2], image.shape[3])).type(torch.cuda.FloatTensor).detach() for image in self.images_torch] self.right_net_inputs = self.left_net_inputs input_type = 'noise' self.mask_net_inputs = [get_noise(self.input_depth, input_type, (image.shape[2], image.shape[3])).type(torch.cuda.FloatTensor).detach() for image in self.images_torch]
def _init_noise(self): """this is network input get 2 channel uniform loss """ input_type = 'noise' # self.left_net_inputs = self.images_torch self.left_net_inputs = [get_noise(self.input_depth, input_type, (image.shape[2], image.shape[3])).type(torch.cuda.FloatTensor).detach() for image in self.images_torch] self.right_net_inputs = self.left_net_inputs self.mask_net_inputs = [get_noise(self.input_depth, input_type, (image.shape[2], image.shape[3])).type(torch.cuda.FloatTensor).detach() for image in self.images_torch]
def _init_noise(self): input_type = 'noise' # self.left_net_inputs = self.images_torch self.clean_net_input = get_noise( self.input_depth, input_type, (self.image_torch.shape[2], self.image_torch.shape[3])).type( torch.cuda.FloatTensor).detach() self.watermark_net_input = get_noise( self.input_depth, input_type, (self.image_torch.shape[2], self.image_torch.shape[3])).type( torch.cuda.FloatTensor).detach() self.mask_net_input = get_noise( self.input_depth, input_type, (self.image_torch.shape[2], self.image_torch.shape[3])).type( torch.cuda.FloatTensor).detach()
def _init_inputs(self): self.image_net_input = get_noise( self.input_depth, 'noise', (self.image.shape[1], self.image.shape[2]), var=1 / 10.).type(torch.cuda.FloatTensor).detach() self.mask_net_input = self.image_net_input
def _init_inputs(self): input_type = 'noise' # input_type = 'meshgrid' data_type = torch.cuda.FloatTensor self.reflection_net_input = get_noise(self.input_depth, input_type, (self.video.shape[2], self.video.shape[3])).type(data_type).detach() self.transmission_net_input = get_video_noise(self.input_depth, input_type, self.video.shape[0], (self.video_torch.shape[2], self.video_torch.shape[3])).type(data_type).detach()
def _init_inputs(self): input_type = 'noise' # input_type = 'meshgrid' data_type = torch.cuda.FloatTensor self.reflection_net_inputs = [ get_noise( self.input_depth, input_type, (image.shape[2], image.shape[3])).type(data_type).detach() for image in self.images_torch ] self.transmission_net_inputs = [ get_noise( self.input_depth, input_type, (image.shape[2], image.shape[3])).type(data_type).detach() for image in self.images_torch ] if isinstance(self.kernel, np.ndarray): self.blur_kernel = FixedBlurLayer(self.kernel)
def _init_noise(self): input_type = 'noise' # self.left_net_inputs = self.images_torch self.clean_nets_inputs = [ get_noise(self.input_depth, input_type, (image.shape[2], image.shape[3])).type( torch.cuda.FloatTensor).detach() for image in self.images_torch ] self.mask_net_input = get_noise(self.input_depth, input_type, (self.images_torch[0].shape[2], self.images_torch[0].shape[3])).type( torch.cuda.FloatTensor).detach() self.watermark_net_input = get_noise( self.input_depth, input_type, (self.images_torch[0].shape[2], self.images_torch[0].shape[3]), var=1 / 100.).type(torch.cuda.FloatTensor).detach()
def _init_inputs(self): data_type = torch.cuda.FloatTensor origin_noise = torch_to_np( get_noise( self.input_depth, self.input_type, (self.images_torch[0].shape[2], self.images_torch[0].shape[3])).type(data_type).detach()) self.reflection_net_inputs = [ np_to_torch(aug).type(data_type).detach() for aug in create_augmentations(origin_noise) ] origin_noise = torch_to_np( get_noise( self.input_depth, self.input_type, (self.images_torch[0].shape[2], self.images_torch[0].shape[3])).type(data_type).detach()) self.transmission_net_inputs = [ np_to_torch(aug).type(data_type).detach() for aug in create_augmentations(origin_noise) ]
def _init_inputs(self): input_type = 'noise' # input_type = 'meshgrid' data_type = torch.cuda.FloatTensor self.reflection_net_input = get_noise( self.input_depth, input_type, (self.image1.shape[1], self.image1.shape[2])).type(data_type).detach() self.alpha_net1_input = get_noise( self.input_depth, input_type, (self.image1.shape[1], self.image1.shape[2])).type(data_type).detach() self.alpha_net2_input = get_noise( self.input_depth, input_type, (self.image1.shape[1], self.image1.shape[2])).type(data_type).detach() self.transmission_net_input = get_noise( self.input_depth, input_type, (self.image1.shape[1], self.image1.shape[2])).type(data_type).detach()
torch.backends.cudnn.enabled = True torch.backends.cudnn.benchmark = True data_type = torch.cuda.FloatTensor input_type = 'noise' # input_type = 'meshgrid' pad = 'reflection' optimize_over = 'net' image1_torch = np_to_torch(image1).type(data_type) image2_torch = np_to_torch(image2).type(data_type) image_torch = np_to_torch(image).type(data_type) input_depth = 3 image_net_input = get_noise( input_depth, input_type, (image.shape[1], image.shape[2])).type(data_type).detach() learning_rate = 0.001 optimizer = 'adam' reg_noise_std = 1. / 30. num_iter = 500 loss_function = torch.nn.L1Loss().type(data_type) # SAME TILL NOW # image_net_input = image1_torch # image_net = skip(