Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
29570db2
Commit
29570db2
authored
Dec 11, 2019
by
thomwolf
Browse files
allowing from_pretrained to load from url directly
parent
2e2f9fed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
transformers/modeling_tf_utils.py
transformers/modeling_tf_utils.py
+3
-1
transformers/modeling_utils.py
transformers/modeling_utils.py
+5
-2
No files found.
transformers/modeling_tf_utils.py
View file @
29570db2
...
...
@@ -259,8 +259,10 @@ class TFPreTrainedModel(tf.keras.Model):
pretrained_model_name_or_path
))
elif
os
.
path
.
isfile
(
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
:
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
try
:
...
...
transformers/modeling_utils.py
View file @
29570db2
...
...
@@ -365,9 +365,12 @@ class PreTrainedModel(nn.Module):
pretrained_model_name_or_path
))
elif
os
.
path
.
isfile
(
pretrained_model_name_or_path
):
archive_file
=
pretrained_model_name_or_path
else
:
assert
from_tf
,
"Error finding file {}, no file or TF 1.X checkpoint found"
.
format
(
pretrained_model_name_or_path
)
elif
os
.
path
.
isfile
(
pretrained_model_name_or_path
+
".index"
):
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"
else
:
archive_file
=
pretrained_model_name_or_path
# redirect to the cache, if necessary
try
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment