FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
stable-diffusion-webui/scripts/postprocessing_codeformer.py at master · dmkwon/stable-diffusion-webui · GitHub
dmkwon
/
stable-diffusion-webui
Public
forked from
AUTOMATIC1111/stable-diffusion-webui
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
stable-diffusion-webui
/
scripts
/
postprocessing_codeformer.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
36 lines (27 loc) · 1.53 KB
Breadcrumbs
stable-diffusion-webui
/
scripts
/
postprocessing_codeformer.py
Copy path
File metadata and controls
36 lines (27 loc) · 1.53 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from
PIL
import
Image
import
numpy
as
np
from
modules
import
scripts_postprocessing
,
codeformer_model
,
ui_components
import
gradio
as
gr
class
ScriptPostprocessingCodeFormer
(
scripts_postprocessing
.
ScriptPostprocessing
):
name
=
"CodeFormer"
order
=
3000
def
ui
(
self
):
with
ui_components
.
InputAccordion
(
False
,
label
=
"CodeFormer"
)
as
enable
:
with
gr
.
Row
():
codeformer_visibility
=
gr
.
Slider
(
minimum
=
0.0
,
maximum
=
1.0
,
step
=
0.001
,
label
=
"Visibility"
,
value
=
1.0
,
elem_id
=
"extras_codeformer_visibility"
)
codeformer_weight
=
gr
.
Slider
(
minimum
=
0.0
,
maximum
=
1.0
,
step
=
0.001
,
label
=
"Weight (0 = maximum effect, 1 = minimum effect)"
,
value
=
0
,
elem_id
=
"extras_codeformer_weight"
)
return
{
"enable"
:
enable
,
"codeformer_visibility"
:
codeformer_visibility
,
"codeformer_weight"
:
codeformer_weight
,
}
def
process
(
self
,
pp
:
scripts_postprocessing
.
PostprocessedImage
,
enable
,
codeformer_visibility
,
codeformer_weight
):
if
codeformer_visibility
==
0
or
not
enable
:
return
restored_img
=
codeformer_model
.
codeformer
.
restore
(
np
.
array
(
pp
.
image
,
dtype
=
np
.
uint8
),
w
=
codeformer_weight
)
res
=
Image
.
fromarray
(
restored_img
)
if
codeformer_visibility
<
1.0
:
res
=
Image
.
blend
(
pp
.
image
,
res
,
codeformer_visibility
)
pp
.
image
=
res
pp
.
info
[
"CodeFormer visibility"
]
=
round
(
codeformer_visibility
,
3
)
pp
.
info
[
"CodeFormer weight"
]
=
round
(
codeformer_weight
,
3
)
Back
|
FazBrowse Home
|
New Git URL