mirror of
https://github.com/serengil/deepface.git
synced 2025-06-07 12:05:22 +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)
|
gdown.download(source_url, f"{target_file}.{compress_type}", quiet=False)
|
||||||
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
exception_msg = (
|
raise ValueError(
|
||||||
f"⛓️💥 Exception while downloading {file_name} from {source_url}. "
|
f"⛓️💥 An exception occurred while downloading {file_name} from {source_url}. "
|
||||||
f"You may consider to download it manually to {target_file}."
|
f"Consider downloading it manually to {target_file}."
|
||||||
)
|
) from err
|
||||||
logger.error(exception_msg)
|
|
||||||
raise ValueError(exception_msg) from err
|
|
||||||
|
|
||||||
# uncompress downloaded file
|
# uncompress downloaded file
|
||||||
if compress_type == "zip":
|
if compress_type == "zip":
|
||||||
@ -85,8 +83,10 @@ def load_model_weights(model: Sequential, weight_file: str) -> Sequential:
|
|||||||
model.load_weights(weight_file)
|
model.load_weights(weight_file)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Exception while loading pre-trained weights from {weight_file}."
|
f"An exception occurred while loading the pre-trained weights from {weight_file}."
|
||||||
"Possible reason is broken file during downloading weights."
|
"This might have happened due to an interruption during the download."
|
||||||
"You may consider to delete it manually."
|
"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
|
) from err
|
||||||
return model
|
return model
|
||||||
|
@ -40,7 +40,10 @@ def test_loading_broken_weights():
|
|||||||
model.add(Dense(units=10, activation="softmax")) # Output layer with 10 classes
|
model.add(Dense(units=10, activation="softmax")) # Output layer with 10 classes
|
||||||
|
|
||||||
# vgg's weights cannot be loaded to this model
|
# 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)
|
model = weight_utils.load_model_weights(model=model, weight_file=weight_file)
|
||||||
|
|
||||||
logger.info("✅ test loading broken weight file is done")
|
logger.info("✅ test loading broken weight file is done")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user