fix revision==fp16 fallback to main

This commit is contained in:
Qing 2024-02-05 21:29:40 +08:00
parent 93f965da40
commit 0eb4f5b86d

View File

@ -983,7 +983,11 @@ def handle_from_pretrained_exceptions(func, **kwargs):
except ValueError as e: except ValueError as e:
if "You are trying to load the model files of the `variant=fp16`" in str(e): if "You are trying to load the model files of the `variant=fp16`" in str(e):
logger.info("variant=fp16 not found, try revision=fp16") logger.info("variant=fp16 not found, try revision=fp16")
try:
return func(**{**kwargs, "variant": None, "revision": "fp16"}) return func(**{**kwargs, "variant": None, "revision": "fp16"})
except Exception as e:
logger.info("revision=fp16 not found, try revision=main")
return func(**{**kwargs, "variant": None, "revision": "main"})
raise e raise e
except OSError as e: except OSError as e:
previous_traceback = traceback.format_exc() previous_traceback = traceback.format_exc()