MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / main

Function main

diffusers/examples/controlnet/train_controlnet_flax.py:662–1148  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

660
661
662def main():
663 args = parse_args()
664
665 if args.report_to == "wandb" and args.hub_token is not None:
666 raise ValueError(
667 "You cannot use both --report_to=wandb and --hub_token due to a security risk of exposing your token."
668 " Please use `huggingface-cli login` to authenticate with the Hub."
669 )
670
671 logging.basicConfig(
672 format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
673 datefmt="%m/%d/%Y %H:%M:%S",
674 level=logging.INFO,
675 )
676 # Setup logging, we only want one process per machine to log things on the screen.
677 logger.setLevel(logging.INFO if jax.process_index() == 0 else logging.ERROR)
678 if jax.process_index() == 0:
679 transformers.utils.logging.set_verbosity_info()
680 else:
681 transformers.utils.logging.set_verbosity_error()
682
683 # wandb init
684 if jax.process_index() == 0 and args.report_to == "wandb":
685 wandb.init(
686 entity=args.wandb_entity,
687 project=args.tracker_project_name,
688 job_type="train",
689 config=args,
690 )
691
692 if args.seed is not None:
693 set_seed(args.seed)
694
695 rng = jax.random.PRNGKey(0)
696
697 # Handle the repository creation
698 if jax.process_index() == 0:
699 if args.output_dir is not None:
700 os.makedirs(args.output_dir, exist_ok=True)
701
702 if args.push_to_hub:
703 repo_id = create_repo(
704 repo_id=args.hub_model_id or Path(args.output_dir).name, exist_ok=True, token=args.hub_token
705 ).repo_id
706
707 # Load the tokenizer and add the placeholder token as a additional special token
708 if args.tokenizer_name:
709 tokenizer = CLIPTokenizer.from_pretrained(args.tokenizer_name)
710 elif args.pretrained_model_name_or_path:
711 tokenizer = CLIPTokenizer.from_pretrained(
712 args.pretrained_model_name_or_path, subfolder="tokenizer", revision=args.revision
713 )
714 else:
715 raise NotImplementedError("No tokenizer specified!")
716
717 # Get the datasets: you can either provide your own training and evaluation files (see below)
718 total_train_batch_size = args.train_batch_size * jax.local_device_count() * args.gradient_accumulation_steps
719 train_dataset = make_train_dataset(args, tokenizer, batch_size=total_train_batch_size)

Callers 1

Calls 13

init_weightsMethod · 0.95
FlaxControlNetModelClass · 0.90
set_seedFunction · 0.85
infoMethod · 0.80
parse_argsFunction · 0.70
make_train_datasetFunction · 0.70
log_validationFunction · 0.70
get_params_to_saveFunction · 0.70
save_model_cardFunction · 0.70
from_pretrainedMethod · 0.45
createMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected