Commit fd47d3e3 authored by Meet Narendra's avatar Meet Narendra 💬

Loss and preprocessor

parent d5a9e675
import numpy as np
from logger import Logger
LOGGER = Logger().logger()
class Loss:
@staticmethod
def content_loss(F,P):
'''
Function to compute content loss between two feature representations at a particular layer
@params
F: 2D numpy array
P: 2D numpy array
'''
l2_norm_sq = None
try:
diff = F-P
l2_norm_sq = np.sum(diff*diff)
except Exception as e:
LOGGER.error("Error computing loss",e)
return l2_norm_sq/2.0
@staticmethod
def gram_matrix(F):
'''
Function to compute the gram matrix of a feature representation at a layer
'''
@staticmethod
def style_loss(F,A):
'''
Function to compute style loss between two feature representations at multiple layers
@params
'''
@staticmethod
def total_loss(alpha,beta,cont_fmap_real,cont_fmap_noise,style_fmap_real,style_fmap_noise):
'''
Function which computes total loss and returns it
@params
'''
\ No newline at end of file
from distutils.log import Log
from logger import Logger
LOGGER = Logger().logger()
class Preprocessor:
@staticmethod
def process(img):
'''
Function to preprocess the image
@params
'''
\ No newline at end of file
import os
import numpy as np
import time
import torch
import argparse
from logger import Logger
LOGGER = Logger().logger()
LOGGER.info("Started Style Transfer")
class StyleTransfer:
'''
Style Transfer Base Class
'''
def __init__(self) -> None:
pass
@staticmethod
def pipepline():
'''
Pipeline for style transfer
@params: None
'''
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment