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

Method push_to_hub

diffusers/src/diffusers/utils/hub_utils.py:546–615  ·  view source on GitHub ↗

Upload model, scheduler, or pipeline files to the 🤗 Hugging Face Hub. Parameters: repo_id (`str`): The name of the repository you want to push your model, scheduler, or pipeline files to. It should contain your organization name when push

(
        self,
        repo_id: str,
        commit_message: Optional[str] = None,
        private: Optional[bool] = None,
        token: Optional[str] = None,
        create_pr: bool = False,
        safe_serialization: bool = True,
        variant: Optional[str] = None,
    )

Source from the content-addressed store, hash-verified

544 )
545
546 def push_to_hub(
547 self,
548 repo_id: str,
549 commit_message: Optional[str] = None,
550 private: Optional[bool] = None,
551 token: Optional[str] = None,
552 create_pr: bool = False,
553 safe_serialization: bool = True,
554 variant: Optional[str] = None,
555 ) -> str:
556 """
557 Upload model, scheduler, or pipeline files to the 🤗 Hugging Face Hub.
558
559 Parameters:
560 repo_id (`str`):
561 The name of the repository you want to push your model, scheduler, or pipeline files to. It should
562 contain your organization name when pushing to an organization. `repo_id` can also be a path to a local
563 directory.
564 commit_message (`str`, *optional*):
565 Message to commit while pushing. Default to `"Upload {object}"`.
566 private (`bool`, *optional*):
567 Whether or not the repository created should be private.
568 token (`str`, *optional*):
569 The token to use as HTTP bearer authorization for remote files. The token generated when running
570 `huggingface-cli login` (stored in `~/.huggingface`).
571 create_pr (`bool`, *optional*, defaults to `False`):
572 Whether or not to create a PR with the uploaded files or directly commit.
573 safe_serialization (`bool`, *optional*, defaults to `True`):
574 Whether or not to convert the model weights to the `safetensors` format.
575 variant (`str`, *optional*):
576 If specified, weights are saved in the format `pytorch_model.<variant>.bin`.
577
578 Examples:
579
580 ```python
581 from diffusers import UNet2DConditionModel
582
583 unet = UNet2DConditionModel.from_pretrained("stabilityai/stable-diffusion-2", subfolder="unet")
584
585 # Push the `unet` to your namespace with the name "my-finetuned-unet".
586 unet.push_to_hub("my-finetuned-unet")
587
588 # Push the `unet` to an organization with the name "my-finetuned-unet".
589 unet.push_to_hub("your-org/my-finetuned-unet")
590 ```
591 """
592 repo_id = create_repo(repo_id, private=private, token=token, exist_ok=True).repo_id
593
594 # Create a new empty model card and eventually tag it
595 model_card = load_or_create_model_card(repo_id, token=token)
596 model_card = populate_model_card(model_card)
597
598 # Save all files.
599 save_kwargs = {"safe_serialization": safe_serialization}
600 if "Scheduler" not in self.__class__.__name__:
601 save_kwargs.update({"variant": variant})
602
603 with tempfile.TemporaryDirectory() as tmpdir:

Calls 5

_upload_folderMethod · 0.95
populate_model_cardFunction · 0.85
updateMethod · 0.45
save_pretrainedMethod · 0.45