Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
DiffBIR_pytorch
Commits
99e31e28
Unverified
Commit
99e31e28
authored
Sep 16, 2023
by
0x3f3f3f3fun
Committed by
GitHub
Sep 16, 2023
Browse files
Merge pull request #40 from MasahideOkada/fix-output-path
fixed output path structure
parents
6436ad1c
56987fa1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
inference_face.py
inference_face.py
+8
-6
No files found.
inference_face.py
View file @
99e31e28
...
...
@@ -144,7 +144,7 @@ def main() -> None:
bg_upsampler
=
set_realesrgan
(
args
.
bg_tile
,
args
.
device
,
bg_upscale
)
else
:
bg_upsampler
=
None
for
file_path
in
list_image_files
(
args
.
input
,
follow_links
=
True
):
# read image
lq
=
Image
.
open
(
file_path
).
convert
(
"RGB"
)
...
...
@@ -167,10 +167,12 @@ def main() -> None:
face_helper
.
get_face_landmarks_5
(
only_center_face
=
args
.
only_center_face
,
resize
=
640
,
eye_dist_threshold
=
5
)
face_helper
.
align_warp_face
()
cropped_face_dir
=
os
.
path
.
join
(
args
.
output
,
'cropped_faces'
)
restored_face_dir
=
os
.
path
.
join
(
args
.
output
,
'restored_faces'
)
restored_img_dir
=
os
.
path
.
join
(
args
.
output
,
'restored_imgs'
)
_
,
img_basename
,
_
=
get_file_name_parts
(
file_path
)
parent_dir
,
img_basename
,
_
=
get_file_name_parts
(
file_path
)
rel_parent_dir
=
os
.
path
.
relpath
(
parent_dir
,
args
.
input
)
output_parent_dir
=
os
.
path
.
join
(
args
.
output
,
rel_parent_dir
)
cropped_face_dir
=
os
.
path
.
join
(
output_parent_dir
,
'cropped_faces'
)
restored_face_dir
=
os
.
path
.
join
(
output_parent_dir
,
'restored_faces'
)
restored_img_dir
=
os
.
path
.
join
(
output_parent_dir
,
'restored_imgs'
)
if
not
args
.
has_aligned
:
os
.
makedirs
(
cropped_face_dir
,
exist_ok
=
True
)
os
.
makedirs
(
restored_img_dir
,
exist_ok
=
True
)
...
...
@@ -252,7 +254,7 @@ def main() -> None:
restored_img
=
restored_img
[:
lq_resized
.
height
,
:
lq_resized
.
width
,
:]
# save restored image
Image
.
fromarray
(
restored_img
).
resize
(
lq
.
size
,
Image
.
LANCZOS
).
convert
(
"RGB"
).
save
(
restored_img_path
)
print
(
f
"Face image
{
basename
}
saved to
{
args
.
output
}
"
)
print
(
f
"Face image
{
basename
}
saved to
{
output
_parent_dir
}
"
)
if
__name__
==
"__main__"
:
...
...
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