From c0e556a7f640d2cc5df92d9ba4d7bac998642ce7 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Sun, 30 Jun 2024 13:32:21 +0200 Subject: [PATCH] fix: get upscale model filepath by calling downloading_upscale_model() ensures the model exists, called in https://github.com/mashb1t/Fooocus/blob/80068a0cd729d6148ac533bf844e1247a0baa9b4/modules/inpaint_worker.py#L162 see https://github.com/mashb1t/Fooocus/discussions/42#discussioncomment-9898976 --- modules/upscaler.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/modules/upscaler.py b/modules/upscaler.py index 974e4f37..de9a143c 100644 --- a/modules/upscaler.py +++ b/modules/upscaler.py @@ -1,13 +1,11 @@ -import os -import torch -import modules.core as core - -from ldm_patched.pfn.architecture.RRDB import RRDBNet as ESRGAN -from ldm_patched.contrib.external_upscale_model import ImageUpscaleWithModel from collections import OrderedDict -from modules.config import path_upscale_models -model_filename = os.path.join(path_upscale_models, 'fooocus_upscaler_s409985e5.bin') +import modules.core as core +import torch +from ldm_patched.contrib.external_upscale_model import ImageUpscaleWithModel +from ldm_patched.pfn.architecture.RRDB import RRDBNet as ESRGAN +from modules.config import downloading_upscale_model + opImageUpscaleWithModel = ImageUpscaleWithModel() model = None @@ -18,6 +16,7 @@ def perform_upscale(img): print(f'Upscaling image with shape {str(img.shape)} ...') if model is None: + model_filename = downloading_upscale_model() sd = torch.load(model_filename) sdo = OrderedDict() for k, v in sd.items():