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
4ff6ba78
Commit
4ff6ba78
authored
Sep 06, 2022
by
Meet Narendra
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fmaps Loss Preprc
parent
fd47d3e3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
2 deletions
+50
-2
1508.06576/feature_maps.py
1508.06576/feature_maps.py
+16
-0
1508.06576/loss.py
1508.06576/loss.py
+2
-1
1508.06576/preprocess.py
1508.06576/preprocess.py
+32
-1
No files found.
1508.06576/feature_maps.py
View file @
4ff6ba78
...
...
@@ -32,6 +32,22 @@ class FeatureMaps:
LOGGER
.
error
(
"Could not fetch layer "
+
str
(
layer
))
return
weights
def
get_fmaps
(
self
,
img
,
layer
=
[
0
,
5
,
10
,
19
,
28
]):
'''
Function which will pass the image through the model and get the respective fmaps
@params
img: numpy image f64
layer: list
'''
fmaps
=
[]
layer_num
=
0
for
layer_i
in
self
.
model
.
features
:
img
=
layer_i
(
img
)
if
layer_num
in
layer
:
fmaps
.
append
(
img
)
layer_num
+=
1
return
fmaps
if
__name__
==
"__main__"
:
fmap
=
FeatureMaps
()
model
=
fmap
.
get_model
()
...
...
1508.06576/loss.py
View file @
4ff6ba78
...
...
@@ -10,11 +10,12 @@ class Loss:
@params
F: 2D numpy array
P: 2D numpy array
Author: @meetdoshi
'''
l2_norm_sq
=
None
try
:
diff
=
F
-
P
l2_norm_sq
=
np
.
sum
(
diff
*
diff
)
l2_norm_sq
=
np
.
sum
(
diff
*
*
2
)
except
Exception
as
e
:
LOGGER
.
error
(
"Error computing loss"
,
e
)
return
l2_norm_sq
/
2.0
...
...
1508.06576/preprocess.py
View file @
4ff6ba78
from
distutils.log
import
Log
from
logger
import
Logger
import
numpy
as
np
LOGGER
=
Logger
()
.
logger
()
class
Preprocessor
:
@
staticmethod
def
subtract_mean
(
img
):
'''
Function to subtract mean values of RGB channels computed over whole ImageNet dataset
@params
img: 3d numpy array
'''
mean
=
np
.
reshape
([
103.939
,
116.779
,
123.68
],(
1
,
1
,
3
))
#b,g,r
return
img
-
mean
@
staticmethod
def
reshape_img
(
img
):
'''
Function to reshpae image in 224x224xnum_of_channels shape
@params
img: 3d numpy array
'''
@
staticmethod
def
process
(
img
):
'''
Function to preprocess the image
@params
'''
\ No newline at end of file
img: 2d numpy a[103.939, 116.779, 123.68]rray
'''
if
__name__
==
"__main__"
:
prec
=
Preprocessor
()
img
=
np
.
zeros
(
shape
=
(
4
,
4
,
3
))
print
(
img
.
shape
)
for
i
in
range
(
img
.
shape
[
2
]):
print
(
img
[:,:,
i
])
img
=
prec
.
subtract_mean
(
img
)
for
i
in
range
(
img
.
shape
[
2
]):
print
(
img
[:,:,
i
])
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