Fix missing usage of token (#25382)
* add missing tokens * fix --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
@@ -17,6 +17,7 @@ import argparse
|
||||
import logging
|
||||
import math
|
||||
import os
|
||||
import warnings
|
||||
from pathlib import Path
|
||||
|
||||
import datasets
|
||||
@@ -186,14 +187,20 @@ def parse_args():
|
||||
default=None,
|
||||
help="Name or path of preprocessor config.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--token",
|
||||
type=str,
|
||||
default=None,
|
||||
help=(
|
||||
"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`)."
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--use_auth_token",
|
||||
type=bool,
|
||||
default=False,
|
||||
help=(
|
||||
"Will use the token generated when running `huggingface-cli login` (necessary to use this script "
|
||||
"with private models)."
|
||||
),
|
||||
default=None,
|
||||
help="The `use_auth_token` argument is deprecated and will be removed in v4.34. Please use `token`.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--trust_remote_code",
|
||||
@@ -377,6 +384,12 @@ def collate_fn(examples):
|
||||
def main():
|
||||
args = parse_args()
|
||||
|
||||
if 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 args.token is not None:
|
||||
raise ValueError("`token` and `use_auth_token` are both specified. Please set only the argument `token`.")
|
||||
args.token = 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_mim_no_trainer", args)
|
||||
@@ -440,7 +453,7 @@ def main():
|
||||
args.dataset_config_name,
|
||||
data_files=args.data_files,
|
||||
cache_dir=args.cache_dir,
|
||||
use_auth_token=True if args.use_auth_token else None,
|
||||
token=args.token,
|
||||
)
|
||||
|
||||
# If we don't have a validation split, split off a percentage of train as validation.
|
||||
@@ -457,7 +470,7 @@ def main():
|
||||
config_kwargs = {
|
||||
"cache_dir": args.cache_dir,
|
||||
"revision": args.model_revision,
|
||||
"use_auth_token": True if args.use_auth_token else None,
|
||||
"token": args.token,
|
||||
"trust_remote_code": args.trust_remote_code,
|
||||
}
|
||||
if args.config_name_or_path:
|
||||
@@ -508,13 +521,14 @@ def main():
|
||||
config=config,
|
||||
cache_dir=args.cache_dir,
|
||||
revision=args.model_revision,
|
||||
token=True if args.use_auth_token else None,
|
||||
token=args.token,
|
||||
trust_remote_code=args.trust_remote_code,
|
||||
)
|
||||
else:
|
||||
logger.info("Training new model from scratch")
|
||||
model = AutoModelForMaskedImageModeling.from_config(
|
||||
config,
|
||||
token=args.token,
|
||||
trust_remote_code=args.trust_remote_code,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user