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
c0ca6348
Commit
c0ca6348
authored
Dec 31, 2023
by
Aarni Koskela
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
load_spandrel_model: always return a model descriptor
parent
3be90740
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
10 deletions
+13
-10
modules/modelloader.py
modules/modelloader.py
+13
-10
No files found.
modules/modelloader.py
View file @
c0ca6348
from
__future__
import
annotations
import
importlib
import
logging
import
os
import
importlib
from
typing
import
TYPE_CHECKING
from
urllib.parse
import
urlparse
import
torch
...
...
@@ -10,6 +11,8 @@ import torch
from
modules
import
shared
from
modules.upscaler
import
Upscaler
,
UpscalerLanczos
,
UpscalerNearest
,
UpscalerNone
if
TYPE_CHECKING
:
import
spandrel
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -142,17 +145,17 @@ def load_spandrel_model(
half
:
bool
=
False
,
dtype
:
str
|
None
=
None
,
expected_architecture
:
str
|
None
=
None
,
):
)
->
spandrel
.
ModelDescriptor
:
import
spandrel
model
=
spandrel
.
ModelLoader
(
device
=
device
)
.
load_from_file
(
path
)
if
expected_architecture
and
model
.
architecture
!=
expected_architecture
:
model
_descriptor
=
spandrel
.
ModelLoader
(
device
=
device
)
.
load_from_file
(
path
)
if
expected_architecture
and
model
_descriptor
.
architecture
!=
expected_architecture
:
logger
.
warning
(
f
"Model {path!r} is not a {expected_architecture!r} model (got {model.architecture!r})"
,
f
"Model {path!r} is not a {expected_architecture!r} model (got {model
_descriptor
.architecture!r})"
,
)
if
half
:
model
=
model
.
model
.
half
()
model
_descriptor
.
model
.
half
()
if
dtype
:
model
=
model
.
model
.
to
(
dtype
=
dtype
)
model
.
eval
()
logger
.
debug
(
"Loaded
%
s from
%
s (device=
%
s, half=
%
s, dtype=
%
s)"
,
model
,
path
,
device
,
half
,
dtype
)
return
model
model
_descriptor
.
model
.
to
(
dtype
=
dtype
)
model
_descriptor
.
model
.
eval
()
logger
.
debug
(
"Loaded
%
s from
%
s (device=
%
s, half=
%
s, dtype=
%
s)"
,
model
_descriptor
,
path
,
device
,
half
,
dtype
)
return
model
_descriptor
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