text stringlengths 0 5.54k |
|---|
layers_per_block=2, |
sample_size=32, |
in_channels=4, |
out_channels=4, |
down_block_types=("DownBlock2D", "CrossAttnDownBlock2D"), |
up_block_types=("CrossAttnUpBlock2D", "UpBlock2D"), |
cross_attention_dim=32, |
) |
scheduler = DDIMScheduler( |
beta_start=0.00085, |
beta_end=0.012, |
beta_schedule="scaled_linear", |
clip_sample=False, |
set_alpha_to_one=False, |
) |
vae = AutoencoderKL( |
block_out_channels=[32, 64], |
in_channels=3, |
out_channels=3, |
down_block_types=["DownEncoderBlock2D", "DownEncoderBlock2D"], |
up_block_types=["UpDecoderBlock2D", "UpDecoderBlock2D"], |
latent_channels=4, |
) |
text_encoder_config = CLIPTextConfig( |
bos_token_id=0, |
eos_token_id=2, |
hidden_size=32, |
intermediate_size=37, |
layer_norm_eps=1e-05, |
num_attention_heads=4, |
num_hidden_layers=5, |
pad_token_id=1, |
vocab_size=1000, |
) |
text_encoder = CLIPTextModel(text_encoder_config) |
tokenizer = CLIPTokenizer.from_pretrained("hf-internal-testing/tiny-random-clip") Pass all of the components to the StableDiffusionPipeline and call push_to_hub() to push the pipeline to the Hub: Copied components = { |
"unet": unet, |
"scheduler": scheduler, |
"vae": vae, |
"text_encoder": text_encoder, |
"tokenizer": tokenizer, |
"safety_checker": None, |
"feature_extractor": None, |
} |
pipeline = StableDiffusionPipeline(**components) |
pipeline.push_to_hub("my-pipeline") The push_to_hub() function saves each component to a subfolder in the repository. Now you can reload the pipeline from your repository on the Hub: Copied pipeline = StableDiffusionPipeline.from_pretrained("your-namespace/my-pipeline") Privacy Set private=True in the push_to_hub() ... |
Create a dataset for training There are many datasets on the Hub to train a model on, but if you can’t find one you’re interested in or want to use your own, you can create a dataset with the 🤗 Datasets library. The dataset structure depends on the task you want to train your model on. The most basic dataset structure... |
data_dir/xxy.png |
data_dir/[...]/xxz.png Pass the path to the dataset directory to the --train_data_dir argument, and then you can start training: Copied accelerate launch train_unconditional.py \ |
--train_data_dir <path-to-train-directory> \ |
<other-arguments> Upload your data to the Hub 💡 For more details and context about creating and uploading a dataset to the Hub, take a look at the Image search with 🤗 Datasets post. Start by creating a dataset with the ImageFolder feature, which creates an image column containing the PIL-encoded images. You can ... |
# example 1: local folder |
dataset = load_dataset("imagefolder", data_dir="path_to_your_folder") |
# example 2: local files (supported formats are tar, gzip, zip, xz, rar, zstd) |
dataset = load_dataset("imagefolder", data_files="path_to_zip_file") |
# example 3: remote files (supported formats are tar, gzip, zip, xz, rar, zstd) |
dataset = load_dataset( |
"imagefolder", |
data_files="https://download.microsoft.com/download/3/E/1/3E1C3F21-ECDB-4869-8368-6DEBA77B919F/kagglecatsanddogs_3367a.zip", |
) |
# example 4: providing several splits |
dataset = load_dataset( |
"imagefolder", data_files={"train": ["path/to/file1", "path/to/file2"], "test": ["path/to/file3", "path/to/file4"]} |
) Then use the push_to_hub method to upload the dataset to the Hub: Copied # assuming you have ran the huggingface-cli login command in a terminal |
dataset.push_to_hub("name_of_your_dataset") |
# if you want to push to a private repo, simply pass private=True: |
dataset.push_to_hub("name_of_your_dataset", private=True) Now the dataset is available for training by passing the dataset name to the --dataset_name argument: Copied accelerate launch --mixed_precision="fp16" train_text_to_image.py \ |
--pretrained_model_name_or_path="runwayml/stable-diffusion-v1-5" \ |
--dataset_name="name_of_your_dataset" \ |
<other-arguments> Next steps Now that you’ve created a dataset, you can plug it into the train_data_dir (if your dataset is local) or dataset_name (if your dataset is on the Hub) arguments of a training script. For your next steps, feel free to try and use your dataset to train a model for unconditional generation o... |
Latent upscaler The Stable Diffusion latent upscaler model was created by Katherine Crowson in collaboration with Stability AI. It is used to enhance the output image resolution by a factor of 2 (see this demo notebook for a demonstration of the original implementation). Make sure to check out the Stable Diffusion Tips... |
Variational Auto-Encoder (VAE) model to encode and decode images to and from latent representations. text_encoder (CLIPTextModel) — |
Frozen text-encoder (clip-vit-large-patch14). tokenizer (CLIPTokenizer) — |
A CLIPTokenizer to tokenize text. unet (UNet2DConditionModel) — |
A UNet2DConditionModel to denoise the encoded image latents. scheduler (SchedulerMixin) — |
A EulerDiscreteScheduler to be used in combination with unet to denoise the encoded image latents. Pipeline for upscaling Stable Diffusion output image resolution by a factor of 2. This model inherits from DiffusionPipeline. Check the superclass documentation for the generic methods |
implemented for all pipelines (downloading, saving, running on a particular device, etc.). The pipeline also inherits the following loading methods: from_single_file() for loading .ckpt files __call__ < source > ( prompt: Union image: Union = None num_inference_steps: int = 75 guidance_scale: float = 9.0 negative_pro... |
The prompt or prompts to guide image upscaling. image (torch.FloatTensor, PIL.Image.Image, np.ndarray, List[torch.FloatTensor], List[PIL.Image.Image], or List[np.ndarray]) — |
Image or tensor representing an image batch to be upscaled. If it’s a tensor, it can be either a |
latent output from a Stable Diffusion model or an image tensor in the range [-1, 1]. It is considered |
a latent if image.shape[1] is 4; otherwise, it is considered to be an image representation and |
encoded using this pipeline’s vae encoder. num_inference_steps (int, optional, defaults to 50) — |
The number of denoising steps. More denoising steps usually lead to a higher quality image at the |
expense of slower inference. guidance_scale (float, optional, defaults to 7.5) — |
A higher guidance scale value encourages the model to generate images closely linked to the text |
prompt at the expense of lower image quality. Guidance scale is enabled when guidance_scale > 1. negative_prompt (str or List[str], optional) — |
The prompt or prompts to guide what to not include in image generation. If not defined, you need to |
pass negative_prompt_embeds instead. Ignored when not using guidance (guidance_scale < 1). eta (float, optional, defaults to 0.0) — |
Corresponds to parameter eta (η) from the DDIM paper. Only applies |
to the DDIMScheduler, and is ignored in other schedulers. generator (torch.Generator or List[torch.Generator], optional) — |
A torch.Generator to make |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.