auto delete wrong model

This commit is contained in:
Qing 2023-02-26 16:36:19 +08:00
parent 8e9909261e
commit 79b20af3f2

View File

@ -70,10 +70,16 @@ def ceil_modulo(x, mod):
def handle_error(model_path, model_md5, e): def handle_error(model_path, model_md5, e):
_md5 = md5sum(model_path) _md5 = md5sum(model_path)
if _md5 != model_md5: if _md5 != model_md5:
try:
os.remove(model_path)
logger.error( logger.error(
f"Model md5: {_md5}, expected: {model_md5}, please delete {model_path} and restart lama-cleaner." f"Model md5: {_md5}, expected md5: {model_md5}, wrong model deleted. Please restart lama-cleaner."
f"If you still have errors, please try download model manually first https://lama-cleaner-docs.vercel.app/install/download_model_manually.\n" f"If you still have errors, please try download model manually first https://lama-cleaner-docs.vercel.app/install/download_model_manually.\n"
) )
except:
logger.error(
f"Model md5: {_md5}, expected md5: {model_md5}, please delete {model_path} and restart lama-cleaner."
)
else: else:
logger.error( logger.error(
f"Failed to load model {model_path}," f"Failed to load model {model_path},"