Fix missing usage of token (#25382)

* add missing tokens

* fix

---------

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
Yih-Dar
2023-08-08 16:27:24 +02:00
committed by GitHub
parent 5bd8c011bb
commit 9c7b744795
6 changed files with 96 additions and 28 deletions

View File

@@ -342,11 +342,19 @@ def main():
# 5. Load pretrained model, tokenizer, and image processor
if model_args.tokenizer_name:
tokenizer = AutoTokenizer.from_pretrained(
model_args.tokenizer_name, cache_dir=model_args.cache_dir, use_fast=model_args.use_fast_tokenizer
model_args.tokenizer_name,
cache_dir=model_args.cache_dir,
use_fast=model_args.use_fast_tokenizer,
token=model_args.token,
trust_remote_code=model_args.trust_remote_code,
)
elif model_args.model_name_or_path:
tokenizer = AutoTokenizer.from_pretrained(
model_args.model_name_or_path, cache_dir=model_args.cache_dir, use_fast=model_args.use_fast_tokenizer
model_args.model_name_or_path,
cache_dir=model_args.cache_dir,
use_fast=model_args.use_fast_tokenizer,
token=model_args.token,
trust_remote_code=model_args.trust_remote_code,
)
else:
raise ValueError(

View File

@@ -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,
)