Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
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
novelai-storage
Stable Diffusion Webui
Commits
17cce456
Commit
17cce456
authored
Apr 29, 2023
by
AUTOMATIC1111
Committed by
GitHub
Apr 29, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8948 from hitomi/master
Fix --realesrgan-models-path and --ldsr-models-path not working
parents
f2af6dad
2ba42bfb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
9 deletions
+25
-9
extensions-builtin/LDSR/scripts/ldsr_model.py
extensions-builtin/LDSR/scripts/ldsr_model.py
+13
-7
modules/realesrgan_model.py
modules/realesrgan_model.py
+12
-2
No files found.
extensions-builtin/LDSR/scripts/ldsr_model.py
View file @
17cce456
...
@@ -25,22 +25,28 @@ class UpscalerLDSR(Upscaler):
...
@@ -25,22 +25,28 @@ class UpscalerLDSR(Upscaler):
yaml_path
=
os
.
path
.
join
(
self
.
model_path
,
"project.yaml"
)
yaml_path
=
os
.
path
.
join
(
self
.
model_path
,
"project.yaml"
)
old_model_path
=
os
.
path
.
join
(
self
.
model_path
,
"model.pth"
)
old_model_path
=
os
.
path
.
join
(
self
.
model_path
,
"model.pth"
)
new_model_path
=
os
.
path
.
join
(
self
.
model_path
,
"model.ckpt"
)
new_model_path
=
os
.
path
.
join
(
self
.
model_path
,
"model.ckpt"
)
safetensors_model_path
=
os
.
path
.
join
(
self
.
model_path
,
"model.safetensors"
)
local_model_paths
=
self
.
find_models
(
ext_filter
=
[
".ckpt"
,
".safetensors"
])
local_ckpt_path
=
next
(
iter
([
local_model
for
local_model
in
local_model_paths
if
local_model
.
endswith
(
"model.ckpt"
)]),
None
)
local_safetensors_path
=
next
(
iter
([
local_model
for
local_model
in
local_model_paths
if
local_model
.
endswith
(
"model.safetensors"
)]),
None
)
local_yaml_path
=
next
(
iter
([
local_model
for
local_model
in
local_model_paths
if
local_model
.
endswith
(
"project.yaml"
)]),
None
)
if
os
.
path
.
exists
(
yaml_path
):
if
os
.
path
.
exists
(
yaml_path
):
statinfo
=
os
.
stat
(
yaml_path
)
statinfo
=
os
.
stat
(
yaml_path
)
if
statinfo
.
st_size
>=
10485760
:
if
statinfo
.
st_size
>=
10485760
:
print
(
"Removing invalid LDSR YAML file."
)
print
(
"Removing invalid LDSR YAML file."
)
os
.
remove
(
yaml_path
)
os
.
remove
(
yaml_path
)
if
os
.
path
.
exists
(
old_model_path
):
if
os
.
path
.
exists
(
old_model_path
):
print
(
"Renaming model from model.pth to model.ckpt"
)
print
(
"Renaming model from model.pth to model.ckpt"
)
os
.
rename
(
old_model_path
,
new_model_path
)
os
.
rename
(
old_model_path
,
new_model_path
)
if
os
.
path
.
exists
(
safetensors_model_path
):
model
=
safetensors_model_path
if
local_safetensors_path
is
not
None
and
os
.
path
.
exists
(
local_safetensors_path
):
model
=
local_safetensors_path
else
:
else
:
model
=
load_file_from_url
(
url
=
self
.
model_url
,
model_dir
=
self
.
model_path
,
model
=
local_ckpt_path
if
local_ckpt_path
is
not
None
else
load_file_from_url
(
url
=
self
.
model_url
,
model_dir
=
self
.
model_path
,
file_name
=
"model.ckpt"
,
progress
=
True
)
file_name
=
"model.ckpt"
,
progress
=
True
)
yaml
=
load_file_from_url
(
url
=
self
.
yaml_url
,
model_dir
=
self
.
model_path
,
yaml
=
local_yaml_path
if
local_yaml_path
is
not
None
else
load_file_from_url
(
url
=
self
.
yaml_url
,
model_dir
=
self
.
model_path
,
file_name
=
"project.yaml"
,
progress
=
True
)
file_name
=
"project.yaml"
,
progress
=
True
)
try
:
try
:
return
LDSR
(
model
,
yaml
)
return
LDSR
(
model
,
yaml
)
...
...
modules/realesrgan_model.py
View file @
17cce456
...
@@ -9,7 +9,7 @@ from realesrgan import RealESRGANer
...
@@ -9,7 +9,7 @@ from realesrgan import RealESRGANer
from
modules.upscaler
import
Upscaler
,
UpscalerData
from
modules.upscaler
import
Upscaler
,
UpscalerData
from
modules.shared
import
cmd_opts
,
opts
from
modules.shared
import
cmd_opts
,
opts
from
modules
import
modelloader
class
UpscalerRealESRGAN
(
Upscaler
):
class
UpscalerRealESRGAN
(
Upscaler
):
def
__init__
(
self
,
path
):
def
__init__
(
self
,
path
):
...
@@ -23,7 +23,15 @@ class UpscalerRealESRGAN(Upscaler):
...
@@ -23,7 +23,15 @@ class UpscalerRealESRGAN(Upscaler):
self
.
enable
=
True
self
.
enable
=
True
self
.
scalers
=
[]
self
.
scalers
=
[]
scalers
=
self
.
load_models
(
path
)
scalers
=
self
.
load_models
(
path
)
local_model_paths
=
self
.
find_models
(
ext_filter
=
[
".pth"
])
for
scaler
in
scalers
:
for
scaler
in
scalers
:
if
scaler
.
local_data_path
.
startswith
(
"http"
):
filename
=
modelloader
.
friendly_name
(
scaler
.
local_data_path
)
local
=
next
(
iter
([
local_model
for
local_model
in
local_model_paths
if
local_model
.
endswith
(
filename
+
'.pth'
)]),
None
)
if
local
:
scaler
.
local_data_path
=
local
if
scaler
.
name
in
opts
.
realesrgan_enabled_models
:
if
scaler
.
name
in
opts
.
realesrgan_enabled_models
:
self
.
scalers
.
append
(
scaler
)
self
.
scalers
.
append
(
scaler
)
...
@@ -64,7 +72,9 @@ class UpscalerRealESRGAN(Upscaler):
...
@@ -64,7 +72,9 @@ class UpscalerRealESRGAN(Upscaler):
print
(
f
"Unable to find model info: {path}"
)
print
(
f
"Unable to find model info: {path}"
)
return
None
return
None
info
.
local_data_path
=
load_file_from_url
(
url
=
info
.
data_path
,
model_dir
=
self
.
model_path
,
progress
=
True
)
if
info
.
local_data_path
.
startswith
(
"http"
):
info
.
local_data_path
=
load_file_from_url
(
url
=
info
.
data_path
,
model_dir
=
self
.
model_path
,
progress
=
True
)
return
info
return
info
except
Exception
as
e
:
except
Exception
as
e
:
print
(
f
"Error making Real-ESRGAN models list: {e}"
,
file
=
sys
.
stderr
)
print
(
f
"Error making Real-ESRGAN models list: {e}"
,
file
=
sys
.
stderr
)
...
...
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