Skip to content

Commit

Permalink
Bump Spandrel to 0.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
akx committed Jul 4, 2024
1 parent a30b19d commit 5b8ed8b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 1 addition & 3 deletions modules/gfpgan_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ def load_net(self) -> torch.Module:
ext_filter=['.pth'],
):
if 'GFPGAN' in os.path.basename(model_path):
model = modelloader.load_spandrel_model(
return modelloader.load_spandrel_model(
model_path,
device=self.get_device(),
expected_architecture='GFPGAN',
).model
model.different_w = True # see https://github.com/chaiNNer-org/spandrel/pull/81
return model
raise ValueError("No GFPGAN model found")

def restore(self, np_image):
Expand Down
7 changes: 4 additions & 3 deletions modules/modelloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,10 @@ def load_spandrel_model(
) -> spandrel.ModelDescriptor:
import spandrel
model_descriptor = spandrel.ModelLoader(device=device).load_from_file(str(path))
if expected_architecture and model_descriptor.architecture != expected_architecture:
arch = model_descriptor.architecture
if expected_architecture and arch.name != expected_architecture:
logger.warning(
f"Model {path!r} is not a {expected_architecture!r} model (got {model_descriptor.architecture!r})",
f"Model {path!r} is not a {expected_architecture!r} model (got {arch.name!r})",
)
half = False
if prefer_half:
Expand All @@ -166,6 +167,6 @@ def load_spandrel_model(
model_descriptor.model.eval()
logger.debug(
"Loaded %s from %s (device=%s, half=%s, dtype=%s)",
model_descriptor, path, device, half, dtype,
arch, path, device, half, dtype,
)
return model_descriptor
2 changes: 1 addition & 1 deletion requirements_versions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pytorch_lightning==1.9.4
resize-right==0.0.2
safetensors==0.4.2
scikit-image==0.21.0
spandrel==0.1.6
spandrel==0.3.4
tomesd==0.1.3
torch
torchdiffeq==0.2.3
Expand Down

0 comments on commit 5b8ed8b

Please sign in to comment.