def __init__(self, image=None, layer_ids=None, layer_weights=None, lambda_loss=1e-2, k=3, s=1, semantic_style_image=None, semantic_content_image=None, gamma=None, gamma_scale=0.4): '''Create PatchStyle. Kwargs ------ image : image Style image to be matched. layer_ids : list Optional list of raw network layers to compute feature losses at. If None defaults to [6,8,10]. layer_weights : list Optional weights for each layer loss. If None uniform weights are applied. lambda_loss : scalar Lagrange multiplier strengthness for this loss vs. other losses. k : number Kernel size s : number Stride semantic_style_image : image Semantic map of style semantic_content_image : image Semantic map of content gamma : list, scalar Optional gamma factor for channel concatenation per layer. If None, auto-tunes gamma per layer. gamma_scale : scale Weights the auto-tuned gamma factor. ''' super(SemanticStyle, self).__init__(image=image, layer_ids=layer_ids, layer_weights=layer_weights, lambda_loss=lambda_loss, k=k, s=s) self.semantic_style_image = to_np(semantic_style_image) self.semantic_content_image = to_np(semantic_content_image) self.gamma = gamma self.gamma_scale = gamma_scale
def __init__(self, image=None, layer_ids=None, layer_weights=None, lambda_loss=1e4): '''Create GramStyle. Kwargs ------ image : image Style image to be matched. layer_ids : list Optional list of raw network layers to compute feature losses at. If None defaults to [6,8,10]. layer_weights : list Optional weights for each layer loss. If None uniform weights are applied. lambda_loss : scalar Lagrange multiplier strengthness for this loss vs. other losses. ''' if layer_ids is None: layer_ids = [6, 8, 10] super(GramStyle, self).__init__(layer_ids, lambda_loss) self.layer_weights = layer_weights self.image = to_np(image)
def __init__(self, image=None, layer_id=8, lambda_loss=1e-3): '''Create Content loss provider. Kwargs ------ image : image Style image to be matched. layer_id : number Layer index to compute feature losses at. lambda_loss : scalar Lagrange multiplier strengthness for this loss vs. other losses. ''' super(Content, self).__init__([layer_id], lambda_loss) if image is not None: self.image = to_np(image) else: self.image = None