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
3dd030d2
Unverified
Commit
3dd030d2
authored
Aug 29, 2023
by
zspo
Committed by
GitHub
Aug 29, 2023
Browse files
fix register (#25779)
parent
dc0c1029
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
10 deletions
+10
-10
src/transformers/models/auto/configuration_auto.py
src/transformers/models/auto/configuration_auto.py
+2
-2
src/transformers/models/auto/feature_extraction_auto.py
src/transformers/models/auto/feature_extraction_auto.py
+2
-2
src/transformers/models/auto/image_processing_auto.py
src/transformers/models/auto/image_processing_auto.py
+2
-2
src/transformers/models/auto/processing_auto.py
src/transformers/models/auto/processing_auto.py
+2
-2
src/transformers/models/auto/tokenization_auto.py
src/transformers/models/auto/tokenization_auto.py
+2
-2
No files found.
src/transformers/models/auto/configuration_auto.py
View file @
3dd030d2
...
...
@@ -1046,7 +1046,7 @@ class AutoConfig:
)
@
staticmethod
def
register
(
model_type
,
config
):
def
register
(
model_type
,
config
,
exist_ok
=
False
):
"""
Register a new configuration for this class.
...
...
@@ -1060,4 +1060,4 @@ class AutoConfig:
f
"you passed (config has
{
config
.
model_type
}
and you passed
{
model_type
}
. Fix one of those so they "
"match!"
)
CONFIG_MAPPING
.
register
(
model_type
,
config
)
CONFIG_MAPPING
.
register
(
model_type
,
config
,
exist_ok
=
exist_ok
)
src/transformers/models/auto/feature_extraction_auto.py
View file @
3dd030d2
...
...
@@ -379,7 +379,7 @@ class AutoFeatureExtractor:
)
@
staticmethod
def
register
(
config_class
,
feature_extractor_class
):
def
register
(
config_class
,
feature_extractor_class
,
exist_ok
=
False
):
"""
Register a new feature extractor for this class.
...
...
@@ -388,4 +388,4 @@ class AutoFeatureExtractor:
The configuration corresponding to the model to register.
feature_extractor_class ([`FeatureExtractorMixin`]): The feature extractor to register.
"""
FEATURE_EXTRACTOR_MAPPING
.
register
(
config_class
,
feature_extractor_class
)
FEATURE_EXTRACTOR_MAPPING
.
register
(
config_class
,
feature_extractor_class
,
exist_ok
=
exist_ok
)
src/transformers/models/auto/image_processing_auto.py
View file @
3dd030d2
...
...
@@ -405,7 +405,7 @@ class AutoImageProcessor:
)
@
staticmethod
def
register
(
config_class
,
image_processor_class
):
def
register
(
config_class
,
image_processor_class
,
exist_ok
=
False
):
"""
Register a new image processor for this class.
...
...
@@ -414,4 +414,4 @@ class AutoImageProcessor:
The configuration corresponding to the model to register.
image_processor_class ([`ImageProcessingMixin`]): The image processor to register.
"""
IMAGE_PROCESSOR_MAPPING
.
register
(
config_class
,
image_processor_class
)
IMAGE_PROCESSOR_MAPPING
.
register
(
config_class
,
image_processor_class
,
exist_ok
=
exist_ok
)
src/transformers/models/auto/processing_auto.py
View file @
3dd030d2
...
...
@@ -319,7 +319,7 @@ class AutoProcessor:
)
@
staticmethod
def
register
(
config_class
,
processor_class
):
def
register
(
config_class
,
processor_class
,
exist_ok
=
False
):
"""
Register a new processor for this class.
...
...
@@ -328,4 +328,4 @@ class AutoProcessor:
The configuration corresponding to the model to register.
processor_class ([`FeatureExtractorMixin`]): The processor to register.
"""
PROCESSOR_MAPPING
.
register
(
config_class
,
processor_class
)
PROCESSOR_MAPPING
.
register
(
config_class
,
processor_class
,
exist_ok
=
exist_ok
)
src/transformers/models/auto/tokenization_auto.py
View file @
3dd030d2
...
...
@@ -764,7 +764,7 @@ class AutoTokenizer:
f
"Model type should be one of
{
', '
.
join
(
c
.
__name__
for
c
in
TOKENIZER_MAPPING
.
keys
())
}
."
)
def
register
(
config_class
,
slow_tokenizer_class
=
None
,
fast_tokenizer_class
=
None
):
def
register
(
config_class
,
slow_tokenizer_class
=
None
,
fast_tokenizer_class
=
None
,
exist_ok
=
False
):
"""
Register a new tokenizer in this mapping.
...
...
@@ -805,4 +805,4 @@ class AutoTokenizer:
if
fast_tokenizer_class
is
None
:
fast_tokenizer_class
=
existing_fast
TOKENIZER_MAPPING
.
register
(
config_class
,
(
slow_tokenizer_class
,
fast_tokenizer_class
))
TOKENIZER_MAPPING
.
register
(
config_class
,
(
slow_tokenizer_class
,
fast_tokenizer_class
)
,
exist_ok
=
exist_ok
)
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