text
stringlengths
5
424k
id
stringlengths
13
178
metadata
dict
__index_level_0__
int64
0
672
use candle::{Result, Tensor, D}; use candle_nn as nn; use candle_nn::Module; #[derive(Debug)] pub struct TimestepEmbedding { linear_1: nn::Linear, linear_2: nn::Linear, } impl TimestepEmbedding { // act_fn: "silu" pub fn new(vs: nn::VarBuilder, channel: usize, time_embed_dim: usize) -> Result<Self> { ...
candle/candle-transformers/src/models/stable_diffusion/embeddings.rs/0
{ "file_path": "candle/candle-transformers/src/models/stable_diffusion/embeddings.rs", "repo_id": "candle", "token_count": 1008 }
69
//! Vision Transformer (ViT) implementation. //! //! Vision Transformer applies transformer architecture to image classification //! by splitting images into patches and processing them as a sequence. //! //! Key characteristics: //! - Image patches as sequence tokens //! - Self-attention between patches //! - Position...
candle/candle-transformers/src/models/vit.rs/0
{ "file_path": "candle/candle-transformers/src/models/vit.rs", "repo_id": "candle", "token_count": 6028 }
70
use super::common::{AttnBlock, ResBlock, TimestepBlock}; use candle::{DType, Result, Tensor, D}; use candle_nn::VarBuilder; #[derive(Debug)] struct Block { res_block: ResBlock, ts_block: TimestepBlock, attn_block: AttnBlock, } #[derive(Debug)] pub struct WPrior { projection: candle_nn::Conv2d, con...
candle/candle-transformers/src/models/wuerstchen/prior.rs/0
{ "file_path": "candle/candle-transformers/src/models/wuerstchen/prior.rs", "repo_id": "candle", "token_count": 1920 }
71
use candle::{DType, Device, Tensor}; use candle_nn::VarBuilder; use candle_transformers::models::bert::{BertModel, Config}; use candle_wasm_example_bert::console_log; use tokenizers::{PaddingParams, Tokenizer}; use wasm_bindgen::prelude::*; #[wasm_bindgen] pub struct Model { bert: BertModel, tokenizer: Tokeniz...
candle/candle-wasm-examples/bert/src/bin/m.rs/0
{ "file_path": "candle/candle-wasm-examples/bert/src/bin/m.rs", "repo_id": "candle", "token_count": 1752 }
72
import init, { Model } from "./build/m.js"; async function fetchArrayBuffer(url) { const cacheName = "llama2c-candle-cache"; const cache = await caches.open(cacheName); const cachedResponse = await cache.match(url); if (cachedResponse) { const data = await cachedResponse.arrayBuffer(); return new Uint8...
candle/candle-wasm-examples/llama2-c/llama2cWorker.js/0
{ "file_path": "candle/candle-wasm-examples/llama2-c/llama2cWorker.js", "repo_id": "candle", "token_count": 1223 }
73
[package] name = "candle-wasm-example-phi" version.workspace = true edition.workspace = true description.workspace = true repository.workspace = true keywords.workspace = true categories.workspace = true license.workspace = true [dependencies] candle = { workspace = true } candle-nn = { workspace = true } candle-trans...
candle/candle-wasm-examples/phi/Cargo.toml/0
{ "file_path": "candle/candle-wasm-examples/phi/Cargo.toml", "repo_id": "candle", "token_count": 278 }
74
//load Candle Bert Module wasm module let init, ModelConditionalGeneration; async function fetchArrayBuffer(url) { const cacheName = "t5-candle-cache"; const cache = await caches.open(cacheName); const cachedResponse = await cache.match(url); if (cachedResponse) { const data = await cachedResponse.arrayBuf...
candle/candle-wasm-examples/t5/T5ModelConditionalGeneration.js/0
{ "file_path": "candle/candle-wasm-examples/t5/T5ModelConditionalGeneration.js", "repo_id": "candle", "token_count": 980 }
75
fn main() { wasm_logger::init(wasm_logger::Config::new(log::Level::Trace)); yew::Renderer::<candle_wasm_example_whisper::App>::new().render(); }
candle/candle-wasm-examples/whisper/src/bin/app.rs/0
{ "file_path": "candle/candle-wasm-examples/whisper/src/bin/app.rs", "repo_id": "candle", "token_count": 67 }
76
pub const NAMES: [&str; 80] = [ "person", "bicycle", "car", "motorbike", "aeroplane", "bus", "train", "truck", "boat", "traffic light", "fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse", "sheep", "cow", ...
candle/candle-wasm-examples/yolo/src/coco_classes.rs/0
{ "file_path": "candle/candle-wasm-examples/yolo/src/coco_classes.rs", "repo_id": "candle", "token_count": 648 }
77
MONGODB_URL=mongodb://localhost:27017/
chat-ui/.env.ci/0
{ "file_path": "chat-ui/.env.ci", "repo_id": "chat-ui", "token_count": 16 }
78
{ "editor.formatOnSave": true, "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.codeActionsOnSave": { "source.fixAll": "explicit" }, "eslint.validate": ["javascript", "svelte"], "[svelte]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[typescript]": { "editor.defaultFormatter": "e...
chat-ui/.vscode/settings.json/0
{ "file_path": "chat-ui/.vscode/settings.json", "repo_id": "chat-ui", "token_count": 153 }
79
{{- if and .Values.serviceAccount.enabled .Values.serviceAccount.create }} apiVersion: v1 kind: ServiceAccount automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }} metadata: name: "{{ .Values.serviceAccount.name | default (include "name" .) }}" namespace: {{ .Release.Namespace }} ...
chat-ui/chart/templates/service-account.yaml/0
{ "file_path": "chat-ui/chart/templates/service-account.yaml", "repo_id": "chat-ui", "token_count": 154 }
80
/// <reference types="@sveltejs/kit" /> /// <reference types="unplugin-icons/types/svelte" /> import type { User } from "$lib/types/User"; // See https://kit.svelte.dev/docs/types#app // for information about these interfaces declare global { namespace App { // interface Error {} interface Locals { sessionId:...
chat-ui/src/app.d.ts/0
{ "file_path": "chat-ui/src/app.d.ts", "repo_id": "chat-ui", "token_count": 199 }
81
<script lang="ts"> import { onMount } from "svelte"; interface Props { onvisible?: () => void; } let { onvisible }: Props = $props(); let loader: HTMLDivElement | undefined = $state(); let observer: IntersectionObserver; let intervalId: ReturnType<typeof setInterval> | undefined; onMount(() => { if (!loa...
chat-ui/src/lib/components/InfiniteScroll.svelte/0
{ "file_path": "chat-ui/src/lib/components/InfiniteScroll.svelte", "repo_id": "chat-ui", "token_count": 439 }
82
<script lang="ts"> interface Props { checked: boolean; name: string; } let { checked = $bindable(), name }: Props = $props(); function toggle() { checked = !checked; } function onKeydown(e: KeyboardEvent) { if (e.key === " " || e.key === "Enter") { e.preventDefault(); toggle(); } } </script> ...
chat-ui/src/lib/components/Switch.svelte/0
{ "file_path": "chat-ui/src/lib/components/Switch.svelte", "repo_id": "chat-ui", "token_count": 375 }
83
<script lang="ts"> import { page } from "$app/state"; import type { MessageFile } from "$lib/types/Message"; import CarbonClose from "~icons/carbon/close"; import CarbonDocumentBlank from "~icons/carbon/document-blank"; import CarbonDownload from "~icons/carbon/download"; import CarbonDocument from "~icons/carbon...
chat-ui/src/lib/components/chat/UploadedFile.svelte/0
{ "file_path": "chat-ui/src/lib/components/chat/UploadedFile.svelte", "repo_id": "chat-ui", "token_count": 3532 }
84
export type RouterFollowUp = { title: string; prompt: string; }; export type RouterExample = { title: string; prompt: string; followUps?: RouterFollowUp[]; }; export const routerExamples: RouterExample[] = [ { title: "Pong game", prompt: "Create a minimalist pong game using HTML and tailwindcss", followU...
chat-ui/src/lib/constants/routerExamples.ts/0
{ "file_path": "chat-ui/src/lib/constants/routerExamples.ts", "repo_id": "chat-ui", "token_count": 1540 }
85
// Shouldn't be needed if we dove into sveltekit internals, see https://github.com/huggingface/chat-ui/pull/88#issuecomment-1523173850 import { logger } from "$lib/server/logger"; import { collections } from "$lib/server/database"; import { onExit } from "./exitHandler"; export class AbortedGenerations { private sta...
chat-ui/src/lib/server/abortedGenerations.ts/0
{ "file_path": "chat-ui/src/lib/server/abortedGenerations.ts", "repo_id": "chat-ui", "token_count": 397 }
86
import type { TextGenerationStreamOutput } from "@huggingface/inference"; import type OpenAI from "openai"; import type { Stream } from "openai/streaming"; /** * Transform a stream of OpenAI.Chat.ChatCompletion into a stream of TextGenerationStreamOutput */ export async function* openAIChatToTextGenerationStream( c...
chat-ui/src/lib/server/endpoints/openai/openAIChatToTextGenerationStream.ts/0
{ "file_path": "chat-ui/src/lib/server/endpoints/openai/openAIChatToTextGenerationStream.ts", "repo_id": "chat-ui", "token_count": 2120 }
87
import { taskModel, models } from "$lib/server/models"; import { MessageUpdateType, type MessageUpdate } from "$lib/types/MessageUpdate"; import type { EndpointMessage } from "./endpoints/endpoints"; export async function* generateFromDefaultEndpoint({ messages, preprompt, generateSettings, modelId, }: { messages...
chat-ui/src/lib/server/generateFromDefaultEndpoint.ts/0
{ "file_path": "chat-ui/src/lib/server/generateFromDefaultEndpoint.ts", "repo_id": "chat-ui", "token_count": 473 }
88
import { writable } from "svelte/store"; export const ERROR_MESSAGES = { default: "Oops, something went wrong.", authOnly: "You have to be logged in.", rateLimited: "You are sending too many messages. Try again later.", }; export const error = writable<string | undefined>(undefined);
chat-ui/src/lib/stores/errors.ts/0
{ "file_path": "chat-ui/src/lib/stores/errors.ts", "repo_id": "chat-ui", "token_count": 86 }
89
import type { Session } from "./Session"; import type { Timestamps } from "./Timestamps"; import type { User } from "./User"; export interface MessageEvent extends Pick<Timestamps, "createdAt"> { userId: User["_id"] | Session["sessionId"]; ip?: string; expiresAt: Date; type: "message" | "export"; }
chat-ui/src/lib/types/MessageEvent.ts/0
{ "file_path": "chat-ui/src/lib/types/MessageEvent.ts", "repo_id": "chat-ui", "token_count": 99 }
90
/** * Chunk array into arrays of length at most `chunkSize` * * @param chunkSize must be greater than or equal to 1 */ export function chunk<T extends unknown[] | string>(arr: T, chunkSize: number): T[] { if (isNaN(chunkSize) || chunkSize < 1) { throw new RangeError("Invalid chunk size: " + chunkSize); } if (...
chat-ui/src/lib/utils/chunk.ts/0
{ "file_path": "chat-ui/src/lib/utils/chunk.ts", "repo_id": "chat-ui", "token_count": 295 }
91
import type { Model } from "$lib/types/Model"; export const findCurrentModel = ( models: Model[], oldModels: { id: string; transferTo?: string }[] = [], id?: string ): Model => { if (id) { const direct = models.find((m) => m.id === id); if (direct) return direct; const legacy = oldModels.find((m) => m.id ==...
chat-ui/src/lib/utils/models.ts/0
{ "file_path": "chat-ui/src/lib/utils/models.ts", "repo_id": "chat-ui", "token_count": 181 }
92
import { collections } from "$lib/server/database"; import { ObjectId } from "mongodb"; import { describe, expect, it } from "vitest"; import { convertLegacyConversation } from "./convertLegacyConversation"; import { insertLegacyConversation } from "./treeHelpers.spec"; describe("convertLegacyConversation", () => { ...
chat-ui/src/lib/utils/tree/convertLegacyConversation.spec.ts/0
{ "file_path": "chat-ui/src/lib/utils/tree/convertLegacyConversation.spec.ts", "repo_id": "chat-ui", "token_count": 425 }
93
import { authCondition } from "$lib/server/auth"; import { collections } from "$lib/server/database"; import { error } from "@sveltejs/kit"; import { ObjectId } from "mongodb"; export async function DELETE({ locals, params }) { const messageId = params.messageId; if (!messageId || typeof messageId !== "string") { ...
chat-ui/src/routes/api/conversation/[id]/message/[messageId]/+server.ts/0
{ "file_path": "chat-ui/src/routes/api/conversation/[id]/message/[messageId]/+server.ts", "repo_id": "chat-ui", "token_count": 398 }
94
import { error, redirect } from "@sveltejs/kit"; import { getOIDCUserData, validateAndParseCsrfToken } from "$lib/server/auth"; import { z } from "zod"; import { base } from "$app/paths"; import { config } from "$lib/server/config"; import JSON5 from "json5"; import { updateUser } from "./updateUser.js"; const sanitiz...
chat-ui/src/routes/login/callback/+server.ts/0
{ "file_path": "chat-ui/src/routes/login/callback/+server.ts", "repo_id": "chat-ui", "token_count": 938 }
95
import { base } from "$app/paths"; import { redirect } from "@sveltejs/kit"; export async function load({ parent, params }) { const data = await parent(); const model = data.models.find((m: { id: string }) => m.id === params.model); if (!model || model.unlisted) { redirect(302, `${base}/settings`); } return ...
chat-ui/src/routes/settings/(nav)/[...model]/+page.ts/0
{ "file_path": "chat-ui/src/routes/settings/(nav)/[...model]/+page.ts", "repo_id": "chat-ui", "token_count": 111 }
96
# Add patterns of files dvc should ignore, which could improve # the performance. Learn more at # https://dvc.org/doc/user-guide/dvcignore
datasets/.dvcignore/0
{ "file_path": "datasets/.dvcignore", "repo_id": "datasets", "token_count": 40 }
97
.PHONY: quality style test check_dirs := tests src benchmarks utils # Check that source code meets quality standards quality: ruff check $(check_dirs) setup.py # linter ruff format --check $(check_dirs) setup.py # formatter # Format source code automatically style: ruff check --fix $(check_dirs) setup.py # lin...
datasets/Makefile/0
{ "file_path": "datasets/Makefile", "repo_id": "datasets", "token_count": 148 }
98
<!--- Copyright 2020 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 ...
datasets/docs/README.md/0
{ "file_path": "datasets/docs/README.md", "repo_id": "datasets", "token_count": 3068 }
99
# Create a dataset Sometimes, you may need to create a dataset if you're working with your own data. Creating a dataset with 🤗 Datasets confers all the advantages of the library to your dataset: fast loading and processing, [stream enormous datasets](stream), [memory-mapping](https://huggingface.co/course/chapter5/4?...
datasets/docs/source/create_dataset.mdx/0
{ "file_path": "datasets/docs/source/create_dataset.mdx", "repo_id": "datasets", "token_count": 1994 }
100
# Load a dataset from the Hub Finding high-quality datasets that are reproducible and accessible can be difficult. One of 🤗 Datasets main goals is to provide a simple way to load a dataset of any format or type. The easiest way to get started is to discover an existing dataset on the [Hugging Face Hub](https://huggin...
datasets/docs/source/load_hub.mdx/0
{ "file_path": "datasets/docs/source/load_hub.mdx", "repo_id": "datasets", "token_count": 1342 }
101
# Load tabular data A tabular dataset is a generic dataset used to describe any data stored in rows and columns, where the rows represent an example and the columns represent a feature (can be continuous or categorical). These datasets are commonly stored in CSV files, Pandas DataFrames, and in database tables. This g...
datasets/docs/source/tabular_load.mdx/0
{ "file_path": "datasets/docs/source/tabular_load.mdx", "repo_id": "datasets", "token_count": 2026 }
102
[tool.ruff] line-length = 119 [tool.ruff.lint] # Ignored rules: # "E501" -> line length violation # "F821" -> undefined named in type annotation (e.g. Literal["something"]) # "C901" -> `function_name` is too complex ignore = ["E501", "F821", "C901"] select = ["C", "E", "F", "I", "W"] [tool.ruff.lint.isort] line...
datasets/pyproject.toml/0
{ "file_path": "datasets/pyproject.toml", "repo_id": "datasets", "token_count": 274 }
103
from typing import TypeVar from .arrow_dataset import Dataset, _split_by_node_map_style_dataset from .iterable_dataset import IterableDataset, _split_by_node_iterable_dataset DatasetType = TypeVar("DatasetType", Dataset, IterableDataset) def split_dataset_by_node(dataset: DatasetType, rank: int, world_size: int) -...
datasets/src/datasets/distributed.py/0
{ "file_path": "datasets/src/datasets/distributed.py", "repo_id": "datasets", "token_count": 582 }
104
import inspect import os import random import shutil import tempfile import weakref from functools import wraps from pathlib import Path from typing import TYPE_CHECKING, Any, Callable, Optional, Union import numpy as np import xxhash from . import config from .naming import INVALID_WINDOWS_CHARACTERS_IN_PATH from .u...
datasets/src/datasets/fingerprint.py/0
{ "file_path": "datasets/src/datasets/fingerprint.py", "repo_id": "datasets", "token_count": 7512 }
105
import json import os from typing import BinaryIO, Optional, Union import fsspec import pyarrow.parquet as pq from .. import Dataset, Features, NamedSplit, config from ..arrow_writer import get_writer_batch_size_from_data_size, get_writer_batch_size_from_features from ..formatting import query_table from ..packaged_m...
datasets/src/datasets/io/parquet.py/0
{ "file_path": "datasets/src/datasets/io/parquet.py", "repo_id": "datasets", "token_count": 2580 }
106
import itertools from dataclasses import dataclass from typing import Any, Callable, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cast from datasets.utils.py_utils import Lit...
datasets/src/datasets/packaged_modules/csv/csv.py/0
{ "file_path": "datasets/src/datasets/packaged_modules/csv/csv.py", "repo_id": "datasets", "token_count": 3883 }
107
import datasets from ..folder_based_builder import folder_based_builder logger = datasets.utils.logging.get_logger(__name__) class PdfFolderConfig(folder_based_builder.FolderBasedBuilderConfig): """BuilderConfig for ImageFolder.""" drop_labels: bool = None drop_metadata: bool = None def __post_in...
datasets/src/datasets/packaged_modules/pdffolder/pdffolder.py/0
{ "file_path": "datasets/src/datasets/packaged_modules/pdffolder/pdffolder.py", "repo_id": "datasets", "token_count": 201 }
108
import importlib.util import os import tempfile from pathlib import PurePath from typing import TYPE_CHECKING, NamedTuple, Optional, Union import fsspec import numpy as np from .features import List from .utils import logging from .utils import tqdm as hf_tqdm if TYPE_CHECKING: from .arrow_dataset import Datase...
datasets/src/datasets/search.py/0
{ "file_path": "datasets/src/datasets/search.py", "repo_id": "datasets", "token_count": 15323 }
109
# Copyright 2020 Optuna, Hugging Face # # 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 to in ...
datasets/src/datasets/utils/logging.py/0
{ "file_path": "datasets/src/datasets/utils/logging.py", "repo_id": "datasets", "token_count": 1912 }
110
# Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets Authors. # # 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 # # U...
datasets/src/datasets/utils/version.py/0
{ "file_path": "datasets/src/datasets/utils/version.py", "repo_id": "datasets", "token_count": 1291 }
111
import textwrap import pyarrow as pa import pytest from datasets import Features, Value from datasets.builder import InvalidConfigName from datasets.data_files import DataFilesList from datasets.packaged_modules.json.json import Json, JsonConfig @pytest.fixture def jsonl_file(tmp_path): filename = tmp_path / "f...
datasets/tests/packaged_modules/test_json.py/0
{ "file_path": "datasets/tests/packaged_modules/test_json.py", "repo_id": "datasets", "token_count": 3820 }
112
import warnings import pytest import datasets.utils.deprecation_utils from datasets.exceptions import ( ChecksumVerificationError, ExpectedMoreDownloadedFilesError, ExpectedMoreSplitsError, NonMatchingChecksumError, NonMatchingSplitsSizesError, SplitsVerificationError, UnexpectedDownloaded...
datasets/tests/test_exceptions.py/0
{ "file_path": "datasets/tests/test_exceptions.py", "repo_id": "datasets", "token_count": 360 }
113
import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def add_one(i): # picklable for multiprocessing return i + 1 @require_dill_gt_0_3_2 @require_jo...
datasets/tests/test_parallel.py/0
{ "file_path": "datasets/tests/test_parallel.py", "repo_id": "datasets", "token_count": 825 }
114
include LICENSE include src/diffusers/utils/model_card_template.md
diffusers/MANIFEST.in/0
{ "file_path": "diffusers/MANIFEST.in", "repo_id": "diffusers", "token_count": 20 }
115
FROM ubuntu:20.04 LABEL maintainer="Hugging Face" LABEL repository="diffusers" ENV DEBIAN_FRONTEND=noninteractive RUN apt-get -y update \ && apt-get install -y software-properties-common \ && add-apt-repository ppa:deadsnakes/ppa RUN apt install -y bash \ build-essential \ ...
diffusers/docker/diffusers-doc-builder/Dockerfile/0
{ "file_path": "diffusers/docker/diffusers-doc-builder/Dockerfile", "repo_id": "diffusers", "token_count": 823 }
116
<!--Copyright 2025 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...
diffusers/docs/source/en/api/image_processor.md/0
{ "file_path": "diffusers/docs/source/en/api/image_processor.md", "repo_id": "diffusers", "token_count": 562 }
117
<!--Copyright 2025 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...
diffusers/docs/source/en/api/models/consisid_transformer3d.md/0
{ "file_path": "diffusers/docs/source/en/api/models/consisid_transformer3d.md", "repo_id": "diffusers", "token_count": 380 }
118
<!-- Copyright 2025 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 applic...
diffusers/docs/source/en/api/pipelines/qwenimage.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/qwenimage.md", "repo_id": "diffusers", "token_count": 1853 }
119
<!--Copyright 2025 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...
diffusers/docs/source/en/api/pipelines/stable_diffusion/latent_upscale.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/stable_diffusion/latent_upscale.md", "repo_id": "diffusers", "token_count": 543 }
120
# Getting Started: VAE Decode with Hybrid Inference VAE decode is an essential component of diffusion models - turning latent representations into images or videos. ## Memory These tables demonstrate the VRAM requirements for VAE decode with SD v1 and SD XL on different GPUs. For the majority of these GPUs the memo...
diffusers/docs/source/en/hybrid_inference/vae_decode.md/0
{ "file_path": "diffusers/docs/source/en/hybrid_inference/vae_decode.md", "repo_id": "diffusers", "token_count": 4810 }
121
<!-- Copyright 2025 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 agree...
diffusers/docs/source/en/optimization/attention_backends.md/0
{ "file_path": "diffusers/docs/source/en/optimization/attention_backends.md", "repo_id": "diffusers", "token_count": 2281 }
122
<!--Copyright 2025 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...
diffusers/docs/source/en/optimization/tome.md/0
{ "file_path": "diffusers/docs/source/en/optimization/tome.md", "repo_id": "diffusers", "token_count": 3387 }
123
<!--Copyright 2025 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...
diffusers/docs/source/en/training/ddpo.md/0
{ "file_path": "diffusers/docs/source/en/training/ddpo.md", "repo_id": "diffusers", "token_count": 322 }
124
<!--Copyright 2025 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...
diffusers/docs/source/en/tutorials/using_peft_for_inference.md/0
{ "file_path": "diffusers/docs/source/en/tutorials/using_peft_for_inference.md", "repo_id": "diffusers", "token_count": 9244 }
125
<!--Copyright 2025 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...
diffusers/docs/source/en/using-diffusers/inpaint.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/inpaint.md", "repo_id": "diffusers", "token_count": 14185 }
126
<!--Copyright 2025 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...
diffusers/docs/source/en/using-diffusers/text-img2vid.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/text-img2vid.md", "repo_id": "diffusers", "token_count": 5831 }
127
<!--Copyright 2025 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...
diffusers/docs/source/ko/conceptual/evaluation.md/0
{ "file_path": "diffusers/docs/source/ko/conceptual/evaluation.md", "repo_id": "diffusers", "token_count": 16762 }
128
<!--Copyright 2025 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...
diffusers/docs/source/ko/training/adapt_a_model.md/0
{ "file_path": "diffusers/docs/source/ko/training/adapt_a_model.md", "repo_id": "diffusers", "token_count": 1850 }
129
<!--Copyright 2025 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...
diffusers/docs/source/ko/using-diffusers/custom_pipeline_overview.md/0
{ "file_path": "diffusers/docs/source/ko/using-diffusers/custom_pipeline_overview.md", "repo_id": "diffusers", "token_count": 2389 }
130
<!--Copyright 2025 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...
diffusers/docs/source/ko/using-diffusers/unconditional_image_generation.md/0
{ "file_path": "diffusers/docs/source/ko/using-diffusers/unconditional_image_generation.md", "repo_id": "diffusers", "token_count": 1741 }
131
<!--版权所有 2025 The HuggingFace Team。保留所有权利。 根据 Apache 许可证 2.0 版本("许可证")授权;除非遵守许可证,否则不得使用此文件。您可以在以下网址获取许可证副本: http://www.apache.org/licenses/LICENSE-2.0 除非适用法律要求或书面同意,根据许可证分发的软件按"原样"分发,无任何明示或暗示的担保或条件。有关许可证管理权限和限制的具体语言,请参阅许可证。 --> # Intel Gaudi Intel Gaudi AI 加速器系列包括 [Intel Gaudi 1](https://habana.ai/products/gaudi/)...
diffusers/docs/source/zh/optimization/habana.md/0
{ "file_path": "diffusers/docs/source/zh/optimization/habana.md", "repo_id": "diffusers", "token_count": 1058 }
132
<!--Copyright 2025 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...
diffusers/docs/source/zh/training/controlnet.md/0
{ "file_path": "diffusers/docs/source/zh/training/controlnet.md", "repo_id": "diffusers", "token_count": 6948 }
133
# 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...
diffusers/examples/community/adaptive_mask_inpainting.py/0
{ "file_path": "diffusers/examples/community/adaptive_mask_inpainting.py", "repo_id": "diffusers", "token_count": 30874 }
134
import inspect from typing import Callable, List, Optional, Tuple, Union import numpy as np import PIL.Image import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import DiffusionPipeline from diffusers.configuration_utils import FrozenDict from diffusers.models import ...
diffusers/examples/community/img2img_inpainting.py/0
{ "file_path": "diffusers/examples/community/img2img_inpainting.py", "repo_id": "diffusers", "token_count": 9670 }
135
# Copyright 2025 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...
diffusers/examples/community/matryoshka.py/0
{ "file_path": "diffusers/examples/community/matryoshka.py", "repo_id": "diffusers", "token_count": 100488 }
136
# Copyright 2025 Black Forest Labs and 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...
diffusers/examples/community/pipeline_flux_differential_img2img.py/0
{ "file_path": "diffusers/examples/community/pipeline_flux_differential_img2img.py", "repo_id": "diffusers", "token_count": 21505 }
137
# Copyright 2025 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...
diffusers/examples/community/pipeline_stable_diffusion_xl_attentive_eraser.py/0
{ "file_path": "diffusers/examples/community/pipeline_stable_diffusion_xl_attentive_eraser.py", "repo_id": "diffusers", "token_count": 52108 }
138
# Copyright 2025 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...
diffusers/examples/community/rerender_a_video.py/0
{ "file_path": "diffusers/examples/community/rerender_a_video.py", "repo_id": "diffusers", "token_count": 27316 }
139
# Copyright 2025 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...
diffusers/examples/community/stable_diffusion_repaint.py/0
{ "file_path": "diffusers/examples/community/stable_diffusion_repaint.py", "repo_id": "diffusers", "token_count": 19672 }
140
# coding=utf-8 # Copyright 2025 HuggingFace Inc. # # 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 ag...
diffusers/examples/consistency_distillation/test_lcm_lora.py/0
{ "file_path": "diffusers/examples/consistency_distillation/test_lcm_lora.py", "repo_id": "diffusers", "token_count": 2105 }
141
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. 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/LI...
diffusers/examples/controlnet/train_controlnet.py/0
{ "file_path": "diffusers/examples/controlnet/train_controlnet.py", "repo_id": "diffusers", "token_count": 20834 }
142
# DreamBooth training example for Stable Diffusion 3 (SD3) [DreamBooth](https://huggingface.co/papers/2208.12242) is a method to personalize text2image models like stable diffusion given just a few (3~5) images of a subject. The `train_dreambooth_sd3.py` script shows how to implement the training procedure and adapt ...
diffusers/examples/dreambooth/README_sd3.md/0
{ "file_path": "diffusers/examples/dreambooth/README_sd3.md", "repo_id": "diffusers", "token_count": 3202 }
143
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. 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/LI...
diffusers/examples/dreambooth/train_dreambooth_lora_sd3.py/0
{ "file_path": "diffusers/examples/dreambooth/train_dreambooth_lora_sd3.py", "repo_id": "diffusers", "token_count": 36888 }
144
# Kandinsky2.2 text-to-image fine-tuning Kandinsky 2.2 includes a prior pipeline that generates image embeddings from text prompts, and a decoder pipeline that generates the output image based on the image embeddings. We provide `train_text_to_image_prior.py` and `train_text_to_image_decoder.py` scripts to show you ho...
diffusers/examples/kandinsky2_2/text_to_image/README.md/0
{ "file_path": "diffusers/examples/kandinsky2_2/text_to_image/README.md", "repo_id": "diffusers", "token_count": 4392 }
145
import torch from torch import nn from .RecSVTR import Block class Swish(nn.Module): def __int__(self): super(Swish, self).__int__() def forward(self, x): return x * torch.sigmoid(x) class Im2Im(nn.Module): def __init__(self, in_channels, **kwargs): super().__init__() s...
diffusers/examples/research_projects/anytext/ocr_recog/RNN.py/0
{ "file_path": "diffusers/examples/research_projects/anytext/ocr_recog/RNN.py", "repo_id": "diffusers", "token_count": 3527 }
146
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. 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/LI...
diffusers/examples/research_projects/consistency_training/train_cm_ct_unconditional.py/0
{ "file_path": "diffusers/examples/research_projects/consistency_training/train_cm_ct_unconditional.py", "repo_id": "diffusers", "token_count": 26285 }
147
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. 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/LI...
diffusers/examples/research_projects/flux_lora_quantization/compute_embeddings.py/0
{ "file_path": "diffusers/examples/research_projects/flux_lora_quantization/compute_embeddings.py", "repo_id": "diffusers", "token_count": 1459 }
148
## Textual Inversion fine-tuning example [Textual inversion](https://huggingface.co/papers/2208.01618) is a method to personalize text2image models like stable diffusion on your own images using just 3-5 examples. The `textual_inversion.py` script shows how to implement the training procedure and adapt it for stable d...
diffusers/examples/research_projects/intel_opts/textual_inversion/README.md/0
{ "file_path": "diffusers/examples/research_projects/intel_opts/textual_inversion/README.md", "repo_id": "diffusers", "token_count": 1014 }
149
# Multi Subject DreamBooth training [DreamBooth](https://huggingface.co/papers/2208.12242) is a method to personalize text2image models like stable diffusion given just a few(3~5) images of a subject. This `train_multi_subject_dreambooth.py` script shows how to implement the training procedure for one or more subjects...
diffusers/examples/research_projects/multi_subject_dreambooth/README.md/0
{ "file_path": "diffusers/examples/research_projects/multi_subject_dreambooth/README.md", "repo_id": "diffusers", "token_count": 4801 }
150
## Textual Inversion fine-tuning example [Textual inversion](https://huggingface.co/papers/2208.01618) is a method to personalize text2image models like stable diffusion on your own images using just 3-5 examples. The `textual_inversion.py` script shows how to implement the training procedure and adapt it for stable d...
diffusers/examples/research_projects/onnxruntime/textual_inversion/README.md/0
{ "file_path": "diffusers/examples/research_projects/onnxruntime/textual_inversion/README.md", "repo_id": "diffusers", "token_count": 1127 }
151
# 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...
diffusers/examples/research_projects/promptdiffusion/promptdiffusioncontrolnet.py/0
{ "file_path": "diffusers/examples/research_projects/promptdiffusion/promptdiffusioncontrolnet.py", "repo_id": "diffusers", "token_count": 8426 }
152
# Scheduled Pseudo-Huber Loss for Diffusers These are the modifications of to include the possibility of training text2image models with Scheduled Pseudo Huber loss, introduced in https://huggingface.co/papers/2403.16728. (https://github.com/kabachuha/SPHL-for-stable-diffusion) ## Why this might be useful? - If you ...
diffusers/examples/research_projects/scheduled_huber_loss_training/README.md/0
{ "file_path": "diffusers/examples/research_projects/scheduled_huber_loss_training/README.md", "repo_id": "diffusers", "token_count": 218 }
153
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. 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/LI...
diffusers/examples/research_projects/vae/vae_roundtrip.py/0
{ "file_path": "diffusers/examples/research_projects/vae/vae_roundtrip.py", "repo_id": "diffusers", "token_count": 3623 }
154
# Create a server Diffusers' pipelines can be used as an inference engine for a server. It supports concurrent and multithreaded requests to generate images that may be requested by multiple users at the same time. This guide will show you how to use the [`StableDiffusion3Pipeline`] in a server, but feel free to use...
diffusers/examples/server/README.md/0
{ "file_path": "diffusers/examples/server/README.md", "repo_id": "diffusers", "token_count": 1151 }
155
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. 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/LI...
diffusers/examples/text_to_image/test_text_to_image_lora.py/0
{ "file_path": "diffusers/examples/text_to_image/test_text_to_image_lora.py", "repo_id": "diffusers", "token_count": 6179 }
156
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...
diffusers/scripts/convert_asymmetric_vqgan_to_diffusers.py/0
{ "file_path": "diffusers/scripts/convert_asymmetric_vqgan_to_diffusers.py", "repo_id": "diffusers", "token_count": 3351 }
157
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...
diffusers/scripts/convert_dit_to_diffusers.py/0
{ "file_path": "diffusers/scripts/convert_dit_to_diffusers.py", "repo_id": "diffusers", "token_count": 3037 }
158
import argparse import os import torch from safetensors.torch import load_file from transformers import AutoModel, AutoTokenizer from diffusers import AutoencoderKL, FlowMatchEulerDiscreteScheduler, LuminaNextDiT2DModel, LuminaPipeline def main(args): # checkpoint from https://huggingface.co/Alpha-VLLM/Lumina-N...
diffusers/scripts/convert_lumina_to_diffusers.py/0
{ "file_path": "diffusers/scripts/convert_lumina_to_diffusers.py", "repo_id": "diffusers", "token_count": 3148 }
159
#!/usr/bin/env python from __future__ import annotations import argparse import os from contextlib import nullcontext import torch from accelerate import init_empty_weights from huggingface_hub import hf_hub_download, snapshot_download from termcolor import colored from transformers import AutoModelForCausalLM, AutoT...
diffusers/scripts/convert_sana_to_diffusers.py/0
{ "file_path": "diffusers/scripts/convert_sana_to_diffusers.py", "repo_id": "diffusers", "token_count": 9521 }
160
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, ) f...
diffusers/scripts/convert_vae_pt_to_diffusers.py/0
{ "file_path": "diffusers/scripts/convert_vae_pt_to_diffusers.py", "repo_id": "diffusers", "token_count": 3572 }
161
# coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. # Copyright (c) 2022, NVIDIA CORPORATION. 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.a...
diffusers/src/diffusers/configuration_utils.py/0
{ "file_path": "diffusers/src/diffusers/configuration_utils.py", "repo_id": "diffusers", "token_count": 14950 }
162
# Copyright 2025 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...
diffusers/src/diffusers/guiders/smoothed_energy_guidance.py/0
{ "file_path": "diffusers/src/diffusers/guiders/smoothed_energy_guidance.py", "repo_id": "diffusers", "token_count": 5192 }
163
from typing import TYPE_CHECKING from ..utils import DIFFUSERS_SLOW_IMPORT, _LazyModule, deprecate from ..utils.import_utils import is_peft_available, is_torch_available, is_transformers_available def text_encoder_lora_state_dict(text_encoder): deprecate( "text_encoder_load_state_dict in `models`", ...
diffusers/src/diffusers/loaders/__init__.py/0
{ "file_path": "diffusers/src/diffusers/loaders/__init__.py", "repo_id": "diffusers", "token_count": 2647 }
164
# Copyright 2025 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...
diffusers/src/diffusers/models/__init__.py/0
{ "file_path": "diffusers/src/diffusers/models/__init__.py", "repo_id": "diffusers", "token_count": 4854 }
165
# Copyright 2025 The Hunyuan Team and 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 ...
diffusers/src/diffusers/models/autoencoders/autoencoder_kl_hunyuan_video.py/0
{ "file_path": "diffusers/src/diffusers/models/autoencoders/autoencoder_kl_hunyuan_video.py", "repo_id": "diffusers", "token_count": 21290 }
166
# Copyright 2025 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...
diffusers/src/diffusers/models/controlnet_sparsectrl.py/0
{ "file_path": "diffusers/src/diffusers/models/controlnet_sparsectrl.py", "repo_id": "diffusers", "token_count": 2376 }
167
# Copyright 2025 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...
diffusers/src/diffusers/models/embeddings_flax.py/0
{ "file_path": "diffusers/src/diffusers/models/embeddings_flax.py", "repo_id": "diffusers", "token_count": 1911 }
168