Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
animegan2-pytorch
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
git
animegan2-pytorch
Commits
37a9fb00
Commit
37a9fb00
authored
Apr 06, 2023
by
mac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
C
parent
2b8bff84
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
6 deletions
+10
-6
model.py
model.py
+4
-1
test.py
test.py
+2
-2
testVideo.py
testVideo.py
+4
-3
No files found.
model.py
View file @
37a9fb00
...
...
@@ -87,7 +87,9 @@ class Generator(nn.Module):
nn
.
Tanh
()
)
def
forward
(
self
,
input
,
align_corners
=
True
):
def
forward
(
self
,
inputTensor
,
align_corners
=
True
):
input
=
inputTensor
.
unsqueeze
(
0
)
*
2
-
1
out
=
self
.
block_a
(
input
)
half_size
=
out
.
size
()[
-
2
:]
out
=
self
.
block_b
(
out
)
...
...
@@ -106,5 +108,6 @@ class Generator(nn.Module):
out
=
self
.
block_e
(
out
)
out
=
self
.
out_layer
(
out
)
out
=
out
.
squeeze
(
0
)
.
clip
(
-
1
,
1
)
*
0.5
+
0.5
return
out
\ No newline at end of file
test.py
View file @
37a9fb00
...
...
@@ -44,9 +44,9 @@ def test(args):
image
=
load_image
(
os
.
path
.
join
(
args
.
input_dir
,
image_name
),
args
.
x32
)
with
torch
.
no_grad
():
image
=
to_tensor
(
image
)
.
unsqueeze
(
0
)
*
2
-
1
image
=
to_tensor
(
image
)
#
.unsqueeze(0) * 2 - 1
out
=
net
(
image
.
to
(
device
),
args
.
upsample_align
)
.
cpu
()
out
=
out
.
squeeze
(
0
)
.
clip
(
-
1
,
1
)
*
0.5
+
0.5
#
out = out.squeeze(0).clip(-1, 1) * 0.5 + 0.5
out
=
to_pil_image
(
out
)
out
.
save
(
os
.
path
.
join
(
args
.
output_dir
,
image_name
))
...
...
testVideo.py
View file @
37a9fb00
...
...
@@ -108,11 +108,12 @@ def img2Comix(args,net,device,image):
#print('>>img_2_x32 size=', image.shape)
with
torch
.
no_grad
():
#print('----------torch.no_grad() handle')
#变成tensor数据后,形状变为CxHxW
image
=
to_tensor
(
image
)
.
unsqueeze
(
0
)
*
2
-
1
#变成tensor数据后,形状变为CxHxW
移到model内部
#
image = to_tensor(image).unsqueeze(0) * 2 - 1
#print('upsample_align=',args.upsample_align)
out
=
net
(
image
.
to
(
device
),
args
.
upsample_align
)
.
cpu
()
out
=
out
.
squeeze
(
0
)
.
clip
(
-
1
,
1
)
*
0.5
+
0.5
#移到模型内部
#out = out.squeeze(0).clip(-1, 1) * 0.5 + 0.5
# out = to_pil_image(out)
out
=
(
out
)
.
numpy
()
...
...
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