mirror of
https://github.com/serengil/deepface.git
synced 2025-06-06 11:35:21 +00:00
exception messages updated
This commit is contained in:
parent
2feb703f96
commit
a80d3e8d27
@ -49,12 +49,10 @@ def download_weights_if_necessary(
|
||||
gdown.download(source_url, f"{target_file}.{compress_type}", quiet=False)
|
||||
|
||||
except Exception as err:
|
||||
exception_msg = (
|
||||
f"⛓️💥 Exception while downloading {file_name} from {source_url}. "
|
||||
f"You may consider to download it manually to {target_file}."
|
||||
)
|
||||
logger.error(exception_msg)
|
||||
raise ValueError(exception_msg) from err
|
||||
raise ValueError(
|
||||
f"⛓️💥 An exception occurred while downloading {file_name} from {source_url}. "
|
||||
f"Consider downloading it manually to {target_file}."
|
||||
) from err
|
||||
|
||||
# uncompress downloaded file
|
||||
if compress_type == "zip":
|
||||
@ -85,8 +83,10 @@ def load_model_weights(model: Sequential, weight_file: str) -> Sequential:
|
||||
model.load_weights(weight_file)
|
||||
except Exception as err:
|
||||
raise ValueError(
|
||||
f"Exception while loading pre-trained weights from {weight_file}."
|
||||
"Possible reason is broken file during downloading weights."
|
||||
"You may consider to delete it manually."
|
||||
f"An exception occurred while loading the pre-trained weights from {weight_file}."
|
||||
"This might have happened due to an interruption during the download."
|
||||
"You may want to delete it and allow DeepFace to download it again during the next run."
|
||||
"If the issue persists, consider downloading the file directly from the source "
|
||||
"and copying it to the target folder."
|
||||
) from err
|
||||
return model
|
||||
|
@ -40,7 +40,10 @@ def test_loading_broken_weights():
|
||||
model.add(Dense(units=10, activation="softmax")) # Output layer with 10 classes
|
||||
|
||||
# vgg's weights cannot be loaded to this model
|
||||
with pytest.raises(ValueError, match="Exception while loading pre-trained weights from"):
|
||||
with pytest.raises(
|
||||
ValueError,
|
||||
match="An exception occurred while loading the pre-trained weights from"
|
||||
):
|
||||
model = weight_utils.load_model_weights(model=model, weight_file=weight_file)
|
||||
|
||||
logger.info("✅ test loading broken weight file is done")
|
||||
|
Loading…
x
Reference in New Issue
Block a user