Add token arugment in example scripts (#25172)
* fix * fix * fix * fix * fix * fix * fix --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
@@ -152,15 +152,21 @@ class ModelArguments:
|
||||
attention_mask: bool = field(
|
||||
default=True, metadata={"help": "Whether to generate an attention mask in the feature extractor."}
|
||||
)
|
||||
use_auth_token: bool = field(
|
||||
default=False,
|
||||
token: str = field(
|
||||
default=None,
|
||||
metadata={
|
||||
"help": (
|
||||
"Will use the token generated when running `huggingface-cli login` (necessary to use this script "
|
||||
"with private models)."
|
||||
"The token to use as HTTP bearer authorization for remote files. If not specified, will use the token "
|
||||
"generated when running `huggingface-cli login` (stored in `~/.huggingface`)."
|
||||
)
|
||||
},
|
||||
)
|
||||
use_auth_token: bool = field(
|
||||
default=None,
|
||||
metadata={
|
||||
"help": "The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token`."
|
||||
},
|
||||
)
|
||||
freeze_feature_extractor: Optional[bool] = field(
|
||||
default=None, metadata={"help": "Whether to freeze the feature extractor layers of the model."}
|
||||
)
|
||||
@@ -198,6 +204,12 @@ def main():
|
||||
else:
|
||||
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
||||
|
||||
if model_args.use_auth_token is not None:
|
||||
warnings.warn("The `use_auth_token` argument is deprecated and will be removed in v4.34.", FutureWarning)
|
||||
if model_args.token is not None:
|
||||
raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
|
||||
model_args.token = model_args.use_auth_token
|
||||
|
||||
# Sending telemetry. Tracking the example usage helps us better allocate resources to maintain them. The
|
||||
# information sent is the one passed as arguments along with your Python/PyTorch versions.
|
||||
send_example_telemetry("run_audio_classification", model_args, data_args)
|
||||
@@ -250,13 +262,13 @@ def main():
|
||||
data_args.dataset_name,
|
||||
data_args.dataset_config_name,
|
||||
split=data_args.train_split_name,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=model_args.token,
|
||||
)
|
||||
raw_datasets["eval"] = load_dataset(
|
||||
data_args.dataset_name,
|
||||
data_args.dataset_config_name,
|
||||
split=data_args.eval_split_name,
|
||||
use_auth_token=True if model_args.use_auth_token else None,
|
||||
token=model_args.token,
|
||||
)
|
||||
|
||||
if data_args.audio_column_name not in raw_datasets["train"].column_names:
|
||||
@@ -280,7 +292,7 @@ def main():
|
||||
return_attention_mask=model_args.attention_mask,
|
||||
cache_dir=model_args.cache_dir,
|
||||
revision=model_args.model_revision,
|
||||
token=True if model_args.use_auth_token else None,
|
||||
token=model_args.token,
|
||||
)
|
||||
|
||||
# `datasets` takes care of automatically loading and resampling the audio,
|
||||
@@ -340,7 +352,7 @@ def main():
|
||||
finetuning_task="audio-classification",
|
||||
cache_dir=model_args.cache_dir,
|
||||
revision=model_args.model_revision,
|
||||
token=True if model_args.use_auth_token else None,
|
||||
token=model_args.token,
|
||||
)
|
||||
model = AutoModelForAudioClassification.from_pretrained(
|
||||
model_args.model_name_or_path,
|
||||
@@ -348,7 +360,7 @@ def main():
|
||||
config=config,
|
||||
cache_dir=model_args.cache_dir,
|
||||
revision=model_args.model_revision,
|
||||
token=True if model_args.use_auth_token else None,
|
||||
token=model_args.token,
|
||||
ignore_mismatched_sizes=model_args.ignore_mismatched_sizes,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user