Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
FML Project
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Meet Narendra
FML Project
Commits
fd47d3e3
You need to sign in or sign up before continuing.
Commit
fd47d3e3
authored
Sep 05, 2022
by
Meet Narendra
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Loss and preprocessor
parent
d5a9e675
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
0 deletions
+78
-0
1508.06576/loss.py
1508.06576/loss.py
+43
-0
1508.06576/preprocess.py
1508.06576/preprocess.py
+11
-0
1508.06576/style_transfer.py
1508.06576/style_transfer.py
+24
-0
No files found.
1508.06576/loss.py
0 → 100644
View file @
fd47d3e3
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
1508.06576/preprocess.py
0 → 100644
View file @
fd47d3e3
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
1508.06576/style_transfer.py
View file @
fd47d3e3
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment