Make a base init in FeatureExtractionMixin (#11074)
This commit is contained in:
parent
04ceee7d24
commit
2199608ca6
|
@ -56,13 +56,7 @@ class SequenceFeatureExtractor(FeatureExtractionMixin):
|
|||
self.padding_side = kwargs.pop("padding_side", "right")
|
||||
self.return_attention_mask = kwargs.pop("return_attention_mask", True)
|
||||
|
||||
# Additional attributes without default values
|
||||
for key, value in kwargs.items():
|
||||
try:
|
||||
setattr(self, key, value)
|
||||
except AttributeError as err:
|
||||
logger.error(f"Can't set {key} with value {value} for {self}")
|
||||
raise err
|
||||
super().__init__(**kwargs)
|
||||
|
||||
def pad(
|
||||
self,
|
||||
|
|
|
@ -197,6 +197,16 @@ class FeatureExtractionMixin:
|
|||
extractors.
|
||||
"""
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
"""Set elements of `kwargs` as attributes."""
|
||||
# Additional attributes without default values
|
||||
for key, value in kwargs.items():
|
||||
try:
|
||||
setattr(self, key, value)
|
||||
except AttributeError as err:
|
||||
logger.error(f"Can't set {key} with value {value} for {self}")
|
||||
raise err
|
||||
|
||||
@classmethod
|
||||
def from_pretrained(
|
||||
cls, pretrained_model_name_or_path: Union[str, os.PathLike], **kwargs
|
||||
|
|
Loading…
Reference in New Issue