"...git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "076602bdc4b186e715538f437f2bce4b1ee5020e"
Commit 6709739a authored by thomwolf's avatar thomwolf Committed by Morgan Funtowicz
Browse files

allowing from_pretrained to load from url directly

parent c2827379
...@@ -265,8 +265,10 @@ class TFPreTrainedModel(tf.keras.Model): ...@@ -265,8 +265,10 @@ class TFPreTrainedModel(tf.keras.Model):
pretrained_model_name_or_path)) pretrained_model_name_or_path))
elif os.path.isfile(pretrained_model_name_or_path): elif os.path.isfile(pretrained_model_name_or_path):
archive_file = pretrained_model_name_or_path archive_file = pretrained_model_name_or_path
elif os.path.isfile(pretrained_model_name_or_path + ".index"):
archive_file = pretrained_model_name_or_path + ".index"
else: else:
raise EnvironmentError("Error file {} not found".format(pretrained_model_name_or_path)) archive_file = pretrained_model_name_or_path
# redirect to the cache, if necessary # redirect to the cache, if necessary
try: try:
......
...@@ -364,9 +364,12 @@ class PreTrainedModel(nn.Module): ...@@ -364,9 +364,12 @@ class PreTrainedModel(nn.Module):
pretrained_model_name_or_path)) pretrained_model_name_or_path))
elif os.path.isfile(pretrained_model_name_or_path): elif os.path.isfile(pretrained_model_name_or_path):
archive_file = pretrained_model_name_or_path archive_file = pretrained_model_name_or_path
else: elif os.path.isfile(pretrained_model_name_or_path + ".index"):
assert from_tf, "Error finding file {}, no file or TF 1.X checkpoint found".format(pretrained_model_name_or_path) assert from_tf, "We found a TensorFlow checkpoint at {}, please set from_tf to True to load from this checkpoint".format(
pretrained_model_name_or_path + ".index")
archive_file = pretrained_model_name_or_path + ".index" archive_file = pretrained_model_name_or_path + ".index"
else:
archive_file = pretrained_model_name_or_path
# redirect to the cache, if necessary # redirect to the cache, if necessary
try: try:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment