From 6f4ce6679358f8fb6a882b1b69029fab49464ccf Mon Sep 17 00:00:00 2001 From: Qing Date: Mon, 8 Jan 2024 23:43:20 +0800 Subject: [PATCH] handle MaxRetryError --- iopaint/model/utils.py | 8 ++++++++ iopaint/model_manager.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/iopaint/model/utils.py b/iopaint/model/utils.py index 99a4404..1292390 100644 --- a/iopaint/model/utils.py +++ b/iopaint/model/utils.py @@ -984,5 +984,13 @@ def handle_from_pretrained_exceptions(func, **kwargs): if "RevisionNotFoundError: 404 Client Error." in previous_traceback: logger.info("revision=fp16 not found, try revision=main") return func(**{**kwargs, "variant": None, "revision": "main"}) + elif "Max retries exceeded" in previous_traceback: + logger.exception( + "Fetching model from HuggingFace failed. " + "If this is your first time downloading the model, you may need to set up proxy in terminal." + "If the model has already been downloaded, you can add --local-files-only when starting." + ) + exit(-1) + raise e except Exception as e: raise e diff --git a/iopaint/model_manager.py b/iopaint/model_manager.py index b009320..006fc0c 100644 --- a/iopaint/model_manager.py +++ b/iopaint/model_manager.py @@ -39,7 +39,7 @@ class ModelManager: logger.info(f"Loading model: {name}") if name not in self.available_models: raise NotImplementedError( - f"Unsupported model: {name}. Available models: {self.available_models.keys()}" + f"Unsupported model: {name}. Available models: {list(self.available_models.keys())}" ) model_info = self.available_models[name]