Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
6709739a
Commit
6709739a
authored
Dec 11, 2019
by
thomwolf
Committed by
Morgan Funtowicz
Dec 11, 2019
Browse files
allowing from_pretrained to load from url directly
parent
c2827379
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 @
6709739a
...
@@ -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
:
...
...
transformers/modeling_utils.py
View file @
6709739a
...
@@ -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
:
...
...
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