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

Function main

diffusers/examples/controlnet/train_controlnet.py:737–1182  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

735
736
737def main(args):
738 if args.report_to == "wandb" and args.hub_token is not None:
739 raise ValueError(
740 "You cannot use both --report_to=wandb and --hub_token due to a security risk of exposing your token."
741 " Please use `huggingface-cli login` to authenticate with the Hub."
742 )
743
744 logging_dir = Path(args.output_dir, args.logging_dir)
745
746 accelerator_project_config = ProjectConfiguration(project_dir=args.output_dir, logging_dir=logging_dir)
747
748 accelerator = Accelerator(
749 gradient_accumulation_steps=args.gradient_accumulation_steps,
750 mixed_precision=args.mixed_precision,
751 log_with=args.report_to,
752 project_config=accelerator_project_config,
753 )
754
755 # Disable AMP for MPS.
756 if torch.backends.mps.is_available():
757 accelerator.native_amp = False
758
759 # Make one log on every process with the configuration for debugging.
760 logging.basicConfig(
761 format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
762 datefmt="%m/%d/%Y %H:%M:%S",
763 level=logging.INFO,
764 )
765 logger.info(accelerator.state, main_process_only=False)
766 if accelerator.is_local_main_process:
767 transformers.utils.logging.set_verbosity_warning()
768 diffusers.utils.logging.set_verbosity_info()
769 else:
770 transformers.utils.logging.set_verbosity_error()
771 diffusers.utils.logging.set_verbosity_error()
772
773 # If passed along, set the training seed now.
774 if args.seed is not None:
775 set_seed(args.seed)
776
777 # Handle the repository creation
778 if accelerator.is_main_process:
779 if args.output_dir is not None:
780 os.makedirs(args.output_dir, exist_ok=True)
781
782 if args.push_to_hub:
783 repo_id = create_repo(
784 repo_id=args.hub_model_id or Path(args.output_dir).name, exist_ok=True, token=args.hub_token
785 ).repo_id
786
787 # Load the tokenizer
788 if args.tokenizer_name:
789 tokenizer = AutoTokenizer.from_pretrained(args.tokenizer_name, revision=args.revision, use_fast=False)
790 elif args.pretrained_model_name_or_path:
791 tokenizer = AutoTokenizer.from_pretrained(
792 args.pretrained_model_name_or_path,
793 subfolder="tokenizer",
794 revision=args.revision,

Callers 1

Calls 15

set_seedFunction · 0.90
is_xformers_availableFunction · 0.90
get_schedulerFunction · 0.90
text_encoderFunction · 0.85
unetFunction · 0.85
infoMethod · 0.80
trainMethod · 0.80
unwrap_modelFunction · 0.70
make_train_datasetFunction · 0.70
log_validationFunction · 0.70

Tested by

no test coverage detected