repo_id
stringlengths
15
89
file_path
stringlengths
27
180
content
stringlengths
1
2.23M
__index_level_0__
int64
0
0
hf_public_repos/candle/candle-book/src
hf_public_repos/candle/candle-book/src/inference/hub.md
# Using the hub Install the [`hf-hub`](https://github.com/huggingface/hf-hub) crate: ```bash cargo add hf-hub ``` Then let's start by downloading the [model file](https://huggingface.co/bert-base-uncased/tree/main). ```rust # extern crate candle_core; # extern crate hf_hub; use hf_hub::api::sync::Api; use candle_c...
0
hf_public_repos/candle/candle-book/src
hf_public_repos/candle/candle-book/src/inference/inference.md
# Running a model In order to run an existing model, you will need to download and use existing weights. Most models are already available on https://huggingface.co/ in [`safetensors`](https://github.com/huggingface/safetensors) format. Let's get started by running an old model : `bert-base-uncased`.
0
hf_public_repos/candle/candle-book/src/inference
hf_public_repos/candle/candle-book/src/inference/cuda/porting.md
# Porting a custom kernel
0
hf_public_repos/candle/candle-book/src/inference
hf_public_repos/candle/candle-book/src/inference/cuda/README.md
# Advanced Cuda usage
0
hf_public_repos/candle/candle-book/src/inference
hf_public_repos/candle/candle-book/src/inference/cuda/writing.md
# Writing a custom kernel
0
hf_public_repos/candle/candle-book/src
hf_public_repos/candle/candle-book/src/guide/installation.md
# Installation **With Cuda support**: 1. First, make sure that Cuda is correctly installed. - `nvcc --version` should print information about your Cuda compiler driver. - `nvidia-smi --query-gpu=compute_cap --format=csv` should print your GPUs compute capability, e.g. something like: ```bash compute_cap 8.9 ``` You...
0
hf_public_repos/candle/candle-book/src
hf_public_repos/candle/candle-book/src/guide/cheatsheet.md
# Pytorch cheatsheet {{#include ../../../README.md:cheatsheet}}
0
hf_public_repos/candle/candle-book/src
hf_public_repos/candle/candle-book/src/guide/hello_world.md
# Hello world! We will now create the hello world of the ML world, building a model capable of solving MNIST dataset. Open `src/main.rs` and fill in this content: ```rust # extern crate candle_core; use candle_core::{Device, Result, Tensor}; struct Model { first: Tensor, second: Tensor, } impl Model { ...
0
hf_public_repos/candle/candle-book/src
hf_public_repos/candle/candle-book/src/training/mnist.md
# MNIST So we now have downloaded the MNIST parquet files, let's put them in a simple struct. ```rust,ignore {{#include ../lib.rs:book_training_3}} ``` The parsing of the file and putting it into single tensors requires the dataset to fit the entire memory. It is quite rudimentary, but simple enough for a small data...
0
hf_public_repos/candle/candle-book/src
hf_public_repos/candle/candle-book/src/training/finetuning.md
# Fine-tuning
0
hf_public_repos/candle/candle-book/src
hf_public_repos/candle/candle-book/src/training/serialization.md
# Serialization
0
hf_public_repos/candle/candle-book/src
hf_public_repos/candle/candle-book/src/training/training.md
# Training Training starts with data. We're going to use the huggingface hub and start with the Hello world dataset of machine learning, MNIST. Let's start with downloading `MNIST` from [huggingface](https://huggingface.co/datasets/mnist). This requires [`hf-hub`](https://github.com/huggingface/hf-hub). ```bash ca...
0
hf_public_repos/candle/candle-book/src
hf_public_repos/candle/candle-book/src/training/simplified.md
# Simplified ## How its works This program implements a neural network to predict the winner of the second round of elections based on the results of the first round. Basic moments: 1. A multilayer perceptron with two hidden layers is used. The first hidden layer has 4 neurons, the second has 2 neurons. 2. The inpu...
0
hf_public_repos/candle/candle-book/src
hf_public_repos/candle/candle-book/src/apps/rest.md
# Creating a REST api webserver
0
hf_public_repos/candle/candle-book/src
hf_public_repos/candle/candle-book/src/apps/README.md
# Creating apps
0
hf_public_repos/candle/candle-book/src
hf_public_repos/candle/candle-book/src/apps/wasm.md
# Creating a WASM app
0
hf_public_repos/candle/candle-book/src
hf_public_repos/candle/candle-book/src/apps/desktop.md
# Creating a desktop Tauri app
0
hf_public_repos/candle/candle-book/src
hf_public_repos/candle/candle-book/src/cuda/porting.md
# Porting a custom kernel
0
hf_public_repos/candle/candle-book/src
hf_public_repos/candle/candle-book/src/cuda/README.md
# Advanced Cuda usage
0
hf_public_repos/candle/candle-book/src
hf_public_repos/candle/candle-book/src/cuda/writing.md
# Writing a custom kernel
0
hf_public_repos/candle
hf_public_repos/candle/candle-datasets/README.md
# candle-datasets
0
hf_public_repos/candle
hf_public_repos/candle/candle-datasets/Cargo.toml
[package] name = "candle-datasets" version.workspace = true edition.workspace = true description.workspace = true repository.workspace = true keywords.workspace = true categories.workspace = true license.workspace = true readme = "README.md" [dependencies] byteorder = { workspace = true } candle = { workspace = true }...
0
hf_public_repos/candle/candle-datasets
hf_public_repos/candle/candle-datasets/src/lib.rs
//! Datasets & Dataloaders for Candle pub mod batcher; pub mod hub; pub mod nlp; pub mod vision; pub use batcher::Batcher;
0
hf_public_repos/candle/candle-datasets
hf_public_repos/candle/candle-datasets/src/batcher.rs
use candle::{Result, Tensor}; pub struct Batcher<I> { inner: I, batch_size: usize, return_last_incomplete_batch: bool, } impl<I> Batcher<I> { fn new(inner: I) -> Self { Self { inner, batch_size: 16, return_last_incomplete_batch: false, } } p...
0
hf_public_repos/candle/candle-datasets
hf_public_repos/candle/candle-datasets/src/hub.rs
use hf_hub::{ api::sync::{Api, ApiRepo}, Repo, RepoType, }; use parquet::file::reader::SerializedFileReader; use std::fs::File; #[derive(thiserror::Error, Debug)] pub enum Error { #[error("ApiError : {0}")] ApiError(#[from] hf_hub::api::sync::ApiError), #[error("IoError : {0}")] IoError(#[from...
0
hf_public_repos/candle/candle-datasets/src
hf_public_repos/candle/candle-datasets/src/nlp/mod.rs
pub mod tinystories;
0
hf_public_repos/candle/candle-datasets/src
hf_public_repos/candle/candle-datasets/src/nlp/tinystories.rs
//! Helper functions for the tinystories dataset. This uses the pre-tokenized version as generated //! by the tools from https://github.com/karpathy/llama2.c use candle::{Device, Result, Tensor}; pub struct Dataset { valid_tokens: Vec<memmap2::Mmap>, train_tokens: Vec<memmap2::Mmap>, } fn mmap_file(p: &std::p...
0
hf_public_repos/candle/candle-datasets/src
hf_public_repos/candle/candle-datasets/src/vision/mod.rs
use candle::Tensor; pub struct Dataset { pub train_images: Tensor, pub train_labels: Tensor, pub test_images: Tensor, pub test_labels: Tensor, pub labels: usize, } pub mod cifar; pub mod mnist;
0
hf_public_repos/candle/candle-datasets/src
hf_public_repos/candle/candle-datasets/src/vision/mnist.rs
//! The MNIST hand-written digit dataset. //! //! The files can be obtained from the following link: //! <http://yann.lecun.com/exdb/mnist/> use candle::{DType, Device, Error, Result, Tensor}; use hf_hub::{api::sync::Api, Repo, RepoType}; use parquet::file::reader::{FileReader, SerializedFileReader}; use std::fs::File;...
0
hf_public_repos/candle/candle-datasets/src
hf_public_repos/candle/candle-datasets/src/vision/cifar.rs
//! The CIFAR-10 dataset. //! //! The files can be downloaded from the following page: //! <https://www.cs.toronto.edu/~kriz/cifar.html> //! The binary version of the dataset is used. use crate::vision::Dataset; use candle::{DType, Device, Error, Result, Tensor}; use hf_hub::{api::sync::Api, Repo, RepoType}; use parque...
0
hf_public_repos
hf_public_repos/diffusers/CODE_OF_CONDUCT.md
# Contributor Covenant Code of Conduct ## Our Pledge We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level o...
0
hf_public_repos
hf_public_repos/diffusers/README.md
<!--- Copyright 2022 - The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law o...
0
hf_public_repos
hf_public_repos/diffusers/_typos.toml
# Files for typos # Instruction: https://github.com/marketplace/actions/typos-action#getting-started [default.extend-identifiers] [default.extend-words] NIN="NIN" # NIN is used in scripts/convert_ncsnpp_original_checkpoint_to_diffusers.py nd="np" # nd may be np (numpy) parms="parms" # parms is used in scripts/conver...
0
hf_public_repos
hf_public_repos/diffusers/pyproject.toml
[tool.ruff] # Never enforce `E501` (line length violations). ignore = ["C901", "E501", "E741", "F402", "F823"] select = ["C", "E", "F", "I", "W"] line-length = 119 # Ignore import violations in all `__init__.py` files. [tool.ruff.per-file-ignores] "__init__.py" = ["E402", "F401", "F403", "F811"] "src/diffusers/utils/d...
0
hf_public_repos
hf_public_repos/diffusers/CONTRIBUTING.md
<!--Copyright 2023 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
0
hf_public_repos
hf_public_repos/diffusers/setup.py
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
0
hf_public_repos
hf_public_repos/diffusers/CITATION.cff
cff-version: 1.2.0 title: 'Diffusers: State-of-the-art diffusion models' message: >- If you use this software, please cite it using the metadata from this file. type: software authors: - given-names: Patrick family-names: von Platen - given-names: Suraj family-names: Patil - given-names: Anton fam...
0
hf_public_repos
hf_public_repos/diffusers/MANIFEST.in
include LICENSE include src/diffusers/utils/model_card_template.md
0
hf_public_repos
hf_public_repos/diffusers/Makefile
.PHONY: deps_table_update modified_only_fixup extra_style_checks quality style fixup fix-copies test test-examples # make sure to test the local checkout in scripts and not the pre-installed one (don't use quotes!) export PYTHONPATH = src check_dirs := examples scripts src tests utils benchmarks modified_only_fixup:...
0
hf_public_repos
hf_public_repos/diffusers/PHILOSOPHY.md
<!--Copyright 2023 The HuggingFace Team. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed...
0
hf_public_repos
hf_public_repos/diffusers/LICENSE
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, ...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/benchmarks/benchmark_sd_inpainting.py
import argparse import sys sys.path.append(".") from base_classes import InpaintingBenchmark # noqa: E402 if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument( "--ckpt", type=str, default="runwayml/stable-diffusion-v1-5", choices=[ "r...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/benchmarks/benchmark_sd_img.py
import argparse import sys sys.path.append(".") from base_classes import ImageToImageBenchmark, TurboImageToImageBenchmark # noqa: E402 if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument( "--ckpt", type=str, default="runwayml/stable-diffusion-v1-5", ...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/benchmarks/benchmark_t2i_lcm_lora.py
import argparse import sys sys.path.append(".") from base_classes import LCMLoRATextToImageBenchmark # noqa: E402 if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument( "--ckpt", type=str, default="stabilityai/stable-diffusion-xl-base-1.0", ) pars...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/benchmarks/utils.py
import argparse import csv import gc import os from dataclasses import dataclass from typing import Dict, List, Union import torch import torch.utils.benchmark as benchmark GITHUB_SHA = os.getenv("GITHUB_SHA", None) BENCHMARK_FIELDS = [ "pipeline_cls", "ckpt_id", "batch_size", "num_inference_steps", ...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/benchmarks/run_all.py
import glob import subprocess import sys from typing import List sys.path.append(".") from benchmark_text_to_image import ALL_T2I_CKPTS # noqa: E402 PATTERN = "benchmark_*.py" class SubprocessCallException(Exception): pass # Taken from `test_examples_utils.py` def run_command(command: List[str], return_std...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/benchmarks/benchmark_text_to_image.py
import argparse import sys sys.path.append(".") from base_classes import TextToImageBenchmark, TurboTextToImageBenchmark # noqa: E402 ALL_T2I_CKPTS = [ "runwayml/stable-diffusion-v1-5", "segmind/SSD-1B", "stabilityai/stable-diffusion-xl-base-1.0", "kandinsky-community/kandinsky-2-2-decoder", "w...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/benchmarks/push_results.py
import glob import sys import pandas as pd from huggingface_hub import hf_hub_download, upload_file from huggingface_hub.utils._errors import EntryNotFoundError sys.path.append(".") from utils import BASE_PATH, FINAL_CSV_FILE, GITHUB_SHA, REPO_ID, collate_csv # noqa: E402 def has_previous_benchmark() -> str: ...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/benchmarks/benchmark_t2i_adapter.py
import argparse import sys sys.path.append(".") from base_classes import T2IAdapterBenchmark, T2IAdapterSDXLBenchmark # noqa: E402 if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument( "--ckpt", type=str, default="TencentARC/t2iadapter_canny_sd14v1", ...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/benchmarks/benchmark_controlnet.py
import argparse import sys sys.path.append(".") from base_classes import ControlNetBenchmark, ControlNetSDXLBenchmark # noqa: E402 if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument( "--ckpt", type=str, default="lllyasviel/sd-controlnet-canny", ...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/benchmarks/base_classes.py
import os import sys import torch from diffusers import ( AutoPipelineForImage2Image, AutoPipelineForInpainting, AutoPipelineForText2Image, ControlNetModel, LCMScheduler, StableDiffusionAdapterPipeline, StableDiffusionControlNetPipeline, StableDiffusionXLAdapterPipeline, StableDiff...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_original_audioldm2_to_diffusers.py
# coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_kakao_brain_unclip_to_diffusers.py
import argparse import tempfile import torch from accelerate import load_checkpoint_and_dispatch from transformers import CLIPTextModelWithProjection, CLIPTokenizer from diffusers import UnCLIPPipeline, UNet2DConditionModel, UNet2DModel from diffusers.models.prior_transformer import PriorTransformer from diffusers.pi...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_pixart_alpha_to_diffusers.py
import argparse import os import torch from transformers import T5EncoderModel, T5Tokenizer from diffusers import AutoencoderKL, DPMSolverMultistepScheduler, PixArtAlphaPipeline, Transformer2DModel ckpt_id = "PixArt-alpha/PixArt-alpha" # https://github.com/PixArt-alpha/PixArt-alpha/blob/0f55e922376d8b797edd44d25d0e...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_zero123_to_diffusers.py
""" This script modified from https://github.com/huggingface/diffusers/blob/bc691231360a4cbc7d19a58742ebb8ed0f05e027/scripts/convert_original_stable_diffusion_to_diffusers.py Convert original Zero1to3 checkpoint to diffusers checkpoint. # run the convert script $ python convert_zero123_to_diffusers.py \ --checkpoi...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/conversion_ldm_uncond.py
import argparse import torch import yaml from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def convert_ldm_original(checkpoint_path, config_path, output_path): config = yaml.safe_load(config_path) state_dict = torch.load(checkpoint_path, map_location="cpu")["model"] keys = list(sta...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_vae_pt_to_diffusers.py
import argparse import io import requests import torch import yaml from diffusers import AutoencoderKL from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( assign_to_checkpoint, conv_attn_to_linear, create_vae_diffusers_config, renew_vae_attention_paths, renew_vae_resnet_paths, ) ...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_original_stable_diffusion_to_diffusers.py
# coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_animatediff_motion_module_to_diffusers.py
import argparse import torch from diffusers import MotionAdapter def convert_motion_module(original_state_dict): converted_state_dict = {} for k, v in original_state_dict.items(): if "pos_encoder" in k: continue else: converted_state_dict[ k.replace("...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_gligen_to_diffusers.py
import argparse import re import torch import yaml from transformers import ( CLIPProcessor, CLIPTextModel, CLIPTokenizer, CLIPVisionModelWithProjection, ) from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionGLIGENPipeline, StableDiffusionGLIGENTextImagePipeline, U...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_unidiffuser_to_diffusers.py
# Convert the original UniDiffuser checkpoints into diffusers equivalents. import argparse from argparse import Namespace import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModel, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, GPT2Tokenizer...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_dit_to_diffusers.py
import argparse import os import torch from torchvision.datasets.utils import download_url from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, Transformer2DModel pretrained_models = {512: "DiT-XL-2-512x512.pt", 256: "DiT-XL-2-256x256.pt"} def download_model(model_name): """ Downloads a pre-tr...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_if.py
import argparse import inspect import os import numpy as np import torch import yaml from torch.nn import functional as F from transformers import CLIPConfig, CLIPImageProcessor, CLIPVisionModelWithProjection, T5EncoderModel, T5Tokenizer from diffusers import DDPMScheduler, IFPipeline, IFSuperResolutionPipeline, UNet...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_original_musicldm_to_diffusers.py
# coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_vq_diffusion_to_diffusers.py
""" This script ports models from VQ-diffusion (https://github.com/microsoft/VQ-Diffusion) to diffusers. It currently only supports porting the ITHQ dataset. ITHQ dataset: ```sh # From the root directory of diffusers. # Download the VQVAE checkpoint $ wget https://facevcstandard.blob.core.windows.net/v-zhictang/Impr...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_tiny_autoencoder_to_diffusers.py
import argparse import safetensors.torch from diffusers import AutoencoderTiny """ Example - From the diffusers root directory: Download the weights: ```sh $ wget -q https://huggingface.co/madebyollin/taesd/resolve/main/taesd_encoder.safetensors $ wget -q https://huggingface.co/madebyollin/taesd/resolve/main/taesd...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_original_controlnet_to_diffusers.py
# coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_blipdiffusion_to_diffusers.py
""" This script requires you to build `LAVIS` from source, since the pip version doesn't have BLIP Diffusion. Follow instructions here: https://github.com/salesforce/LAVIS/tree/main. """ import argparse import os import tempfile import torch from lavis.models import load_model_and_preprocess from transformers import ...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/change_naming_configs_and_checkpoints.py
# coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_kandinsky3_unet.py
#!/usr/bin/env python3 import argparse import fnmatch from safetensors.torch import load_file from diffusers import Kandinsky3UNet MAPPING = { "to_time_embed.1": "time_embedding.linear_1", "to_time_embed.3": "time_embedding.linear_2", "in_layer": "conv_in", "out_layer.0": "conv_norm_out", "out_l...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_amused.py
import inspect import os from argparse import ArgumentParser import numpy as np import torch from muse import MaskGiTUViT, VQGANModel from muse import PipelineMuse as OldPipelineMuse from transformers import CLIPTextModelWithProjection, CLIPTokenizer from diffusers import VQModel from diffusers.models.attention_proce...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_original_t2i_adapter.py
# coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_lora_safetensor_to_diffusers.py
# coding=utf-8 # Copyright 2023, Haofan Wang, Qixun Wang, All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_shap_e_to_diffusers.py
import argparse import tempfile import torch from accelerate import load_checkpoint_and_dispatch from diffusers.models.prior_transformer import PriorTransformer from diffusers.pipelines.shap_e import ShapERenderer """ Example - From the diffusers root directory: Download weights: ```sh $ wget "https://openaipubli...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_svd_to_diffusers.py
from diffusers.utils import is_accelerate_available, logging if is_accelerate_available(): pass logger = logging.get_logger(__name__) # pylint: disable=invalid-name def create_unet_diffusers_config(original_config, image_size: int, controlnet=False): """ Creates a config for the diffusers based on the...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_stable_diffusion_controlnet_to_tensorrt.py
import argparse import sys import tensorrt as trt def convert_models(onnx_path: str, num_controlnet: int, output_path: str, fp16: bool = False, sd_xl: bool = False): """ Function to convert models in stable diffusion controlnet pipeline into TensorRT format Example: python convert_stable_diffusion_c...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_stable_diffusion_checkpoint_to_onnx.py
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_wuerstchen.py
# Run inside root directory of official source code: https://github.com/dome272/wuerstchen/ import os import torch from transformers import AutoTokenizer, CLIPTextModel from vqgan import VQModel from diffusers import ( DDPMWuerstchenScheduler, WuerstchenCombinedPipeline, WuerstchenDecoderPipeline, Wue...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_music_spectrogram_to_diffusers.py
#!/usr/bin/env python3 import argparse import os import jax as jnp import numpy as onp import torch import torch.nn as nn from music_spectrogram_diffusion import inference from t5x import checkpoints from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline from diffusers.pipelines.spectrogr...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_diffusers_to_original_sdxl.py
# Script for converting a HF Diffusers saved pipeline to a Stable Diffusion checkpoint. # *Only* converts the UNet, VAE, and Text Encoder. # Does not convert optimizer state or any other thing. import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # ========...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_stable_diffusion_controlnet_to_onnx.py
import argparse import os import shutil from pathlib import Path import onnx import onnx_graphsurgeon as gs import torch from onnx import shape_inference from packaging import version from polygraphy.backend.onnx.loader import fold_constants from torch.onnx import export from diffusers import ( ControlNetModel, ...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_dance_diffusion_to_diffusers.py
#!/usr/bin/env python3 import argparse import math import os from copy import deepcopy import torch from audio_diffusion.models import DiffusionAttnUnet1D from diffusion import sampling from torch import nn from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNet1DModel MODELS_MAP = { "gwf-440k": { ...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_vae_diff_to_onnx.py
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_consistency_decoder.py
import math import os import urllib import warnings from argparse import ArgumentParser import torch import torch.nn as nn import torch.nn.functional as F from huggingface_hub.utils import insecure_hashlib from safetensors.torch import load_file as stl from tqdm import tqdm from diffusers import AutoencoderKL, Consis...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_ddpm_original_checkpoint_to_diffusers.py
import argparse import json import torch from diffusers import AutoencoderKL, DDPMPipeline, DDPMScheduler, UNet2DModel, VQModel def shave_segments(path, n_shave_prefix_segments=1): """ Removes segments. Positive values shave the first segments, negative shave the last segments. """ if n_shave_prefix...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_models_diffuser_to_diffusers.py
import json import os import torch from diffusers import UNet1DModel os.makedirs("hub/hopper-medium-v2/unet/hor32", exist_ok=True) os.makedirs("hub/hopper-medium-v2/unet/hor128", exist_ok=True) os.makedirs("hub/hopper-medium-v2/value_function", exist_ok=True) def unet(hor): if hor == 128: down_block_...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_diffusers_to_original_stable_diffusion.py
# Script for converting a HF Diffusers saved pipeline to a Stable Diffusion checkpoint. # *Only* converts the UNet, VAE, and Text Encoder. # Does not convert optimizer state or any other thing. import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # ========...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_kandinsky_to_diffusers.py
import argparse import os import tempfile import torch from accelerate import load_checkpoint_and_dispatch from diffusers import UNet2DConditionModel from diffusers.models.prior_transformer import PriorTransformer from diffusers.models.vq_model import VQModel """ Example - From the diffusers root directory: Downlo...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_ldm_original_checkpoint_to_diffusers.py
# coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/generate_logits.py
import random import torch from huggingface_hub import HfApi from diffusers import UNet2DModel api = HfApi() results = {} # fmt: off results["google_ddpm_cifar10_32"] = torch.tensor([ -0.7515, -1.6883, 0.2420, 0.0300, 0.6347, 1.3433, -1.1743, -3.7467, 1.2342, -2.2485, 0.4636, 0.8076, -0.7991, 0.3969, 0.849...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_k_upscaler_to_diffusers.py
import argparse import huggingface_hub import k_diffusion as K import torch from diffusers import UNet2DConditionModel UPSCALER_REPO = "pcuenq/k-upscaler" def resnet_to_diffusers_checkpoint(resnet, checkpoint, *, diffusers_resnet_prefix, resnet_prefix): rv = { # norm1 f"{diffusers_resnet_prefi...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_diffusers_sdxl_lora_to_webui.py
# Script for converting a Hugging Face Diffusers trained SDXL LoRAs to Kohya format # This means that you can input your diffusers-trained LoRAs and # Get the output to work with WebUIs such as AUTOMATIC1111, ComfyUI, SD.Next and others. # To get started you can find some cool `diffusers` trained LoRAs such as this cu...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_original_audioldm_to_diffusers.py
# coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_asymmetric_vqgan_to_diffusers.py
import argparse import time from pathlib import Path from typing import Any, Dict, Literal import torch from diffusers import AsymmetricAutoencoderKL ASYMMETRIC_AUTOENCODER_KL_x_1_5_CONFIG = { "in_channels": 3, "out_channels": 3, "down_block_types": [ "DownEncoderBlock2D", "DownEncoderBl...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_ncsnpp_original_checkpoint_to_diffusers.py
# coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_unclip_txt2img_to_image_variation.py
import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_ms_text_to_video_to_diffusers.py
# coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_versatile_diffusion_to_diffusers.py
# coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_consistency_to_diffusers.py
import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNet2DModel, ) TEST_UNET_CONFIG = { "sample_size": 32, "in_channels": 3, "out_channels": 3, "layers_per_block": 2, "num_class_embeds": 1000, "block_out_channel...
0
hf_public_repos/diffusers
hf_public_repos/diffusers/scripts/convert_animatediff_motion_lora_to_diffusers.py
import argparse import torch from safetensors.torch import save_file def convert_motion_module(original_state_dict): converted_state_dict = {} for k, v in original_state_dict.items(): if "pos_encoder" in k: continue else: converted_state_dict[ k.replac...
0