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
6e4afc45
Commit
6e4afc45
authored
Sep 28, 2022
by
Meet Narendra
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified preprocess and added device
parent
529337f9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
9 deletions
+11
-9
1508.06576/feature_maps.py
1508.06576/feature_maps.py
+1
-0
1508.06576/preprocess.py
1508.06576/preprocess.py
+10
-9
No files found.
1508.06576/feature_maps.py
View file @
6e4afc45
...
...
@@ -2,6 +2,7 @@ import torch
from
logger
import
Logger
LOGGER
=
Logger
()
.
logger
()
LOGGER
.
info
(
"Started Feature Maps"
)
device
=
torch
.
device
(
"cuda"
if
(
torch
.
cude
.
is_available
())
else
'cpu'
)
#Author: @meetdoshi
class
FeatureMaps
:
def
__init__
(
self
,
arch
=
"vgg19"
):
...
...
1508.06576/preprocess.py
View file @
6e4afc45
from
os
import
device_encoding
from
logger
import
Logger
from
torch
import
transforms
import
torch
import
torchvision.transforms
as
transforms
from
PIL
import
Image
import
numpy
as
np
LOGGER
=
Logger
()
.
logger
()
device
=
torch
.
device
(
"cuda"
if
(
torch
.
cude
.
is_available
())
else
'cpu'
)
#Author: @meetdoshi
class
Preprocessor
:
@
staticmethod
...
...
@@ -34,7 +37,8 @@ class Preprocessor:
'''
loader
=
transforms
.
Compose
([
transforms
.
ToTensor
(),
transforms
.
Resize
([
224
,
224
]),
transforms
.
Normalize
(
mean
=
[
0.485
,
0.456
,
0.406
],
std
=
[
0.229
,
0.224
,
0.225
],),])
img
=
loader
(
img
)
.
unsqueeze
(
0
)
return
img
assert
img
.
shape
==
(
1
,
3
,
224
,
224
)
return
img
.
to
(
device
,
torch
.
float
)
@
staticmethod
...
...
@@ -46,15 +50,12 @@ class Preprocessor:
'''
img
=
Preprocessor
.
load_image
(
path
)
img
=
Preprocessor
.
reshape_img
(
img
)
img
=
Preprocessor
.
subtract_mean
(
img
)
#
img = Preprocessor.subtract_mean(img)
return
img
'''
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
])
img = prec.process('test/sem8.jpeg')
'''
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