text stringlengths 5 424k | id stringlengths 13 178 | metadata dict | __index_level_0__ int64 0 672 |
|---|---|---|---|
use anyhow::Result;
use candle::{DType, Device, IndexOp, Tensor, D};
fn to_vec3_round(t: Tensor, digits: i32) -> Result<Vec<Vec<Vec<f32>>>> {
let b = 10f32.powi(digits);
let t = t.to_vec3::<f32>()?;
let t = t
.iter()
.map(|t| {
t.iter()
.map(|t| t.iter().map(|t| ... | candle/candle-flash-attn/tests/flash_attn_tests.rs/0 | {
"file_path": "candle/candle-flash-attn/tests/flash_attn_tests.rs",
"repo_id": "candle",
"token_count": 3779
} | 46 |
#include "cuda_utils.cuh"
#include <cmath>
#include <stdint.h>
#define WARP_SIZE 32
const int BLOCK_SIZE = 1024;
// TODO: Maybe add some fast_sum_f16_f32 variant that not only accumulate in f32
// but also expect a f32 output so that this can be used for normalization e.g.
// in softmax.
// Fast reduce sum kernel, t... | candle/candle-kernels/src/reduce.cu/0 | {
"file_path": "candle/candle-kernels/src/reduce.cu",
"repo_id": "candle",
"token_count": 13341
} | 47 |
use crate::metal::{Buffer, ComputeCommandEncoder, Device};
use crate::utils::EncoderProvider;
use crate::{set_params, ConstantValues, EncoderParam, Kernels, MetalKernelError, Source, Value};
use objc2_metal::{MTLResourceUsage, MTLSize};
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub enum GemmDType {
BF16,
... | candle/candle-metal-kernels/src/kernels/mlx_gemm.rs/0 | {
"file_path": "candle/candle-metal-kernels/src/kernels/mlx_gemm.rs",
"repo_id": "candle",
"token_count": 3309
} | 48 |
use crate::MetalKernelError;
use objc2::{rc::Retained, runtime::ProtocolObject};
use objc2_foundation::NSString;
use objc2_metal::{MTLDataType, MTLFunction, MTLFunctionConstantValues, MTLLibrary};
use std::{ffi::c_void, ptr};
#[derive(Clone, Debug)]
pub struct Library {
raw: Retained<ProtocolObject<dyn MTLLibrary>... | candle/candle-metal-kernels/src/metal/library.rs/0 | {
"file_path": "candle/candle-metal-kernels/src/metal/library.rs",
"repo_id": "candle",
"token_count": 1895
} | 49 |
#include <metal_stdlib>
#include <metal_math>
#
using namespace metal;
METAL_FUNC uint get_strided_index(
uint idx,
constant size_t &num_dims,
constant size_t *dims,
constant size_t *strides
) {
uint strided_i = 0;
for (uint d = 0; d < num_dims; d++) {
uint dim_idx = num_dims - 1 - d;
... | candle/candle-metal-kernels/src/metal_src/unary.metal/0 | {
"file_path": "candle/candle-metal-kernels/src/metal_src/unary.metal",
"repo_id": "candle",
"token_count": 3219
} | 50 |
//! Convolution Layers.
use crate::BatchNorm;
use candle::{conv::CudnnFwdAlgo, Result, Tensor};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Conv1dConfig {
pub padding: usize,
pub stride: usize,
pub dilation: usize,
pub groups: usize,
pub cudnn_fwd_algo: Option<CudnnFwdAlgo>,
}
impl Def... | candle/candle-nn/src/conv.rs/0 | {
"file_path": "candle/candle-nn/src/conv.rs",
"repo_id": "candle",
"token_count": 6061
} | 51 |
use candle::{Result, Tensor};
/// Sample according to the Gumbel-Softmax distribution.
pub fn gumbel_softmax<D: candle::shape::Dim>(
logits: &Tensor,
temperature: f64,
dim: D,
) -> Result<Tensor> {
if temperature <= 0.0 {
logits.argmax(dim)
} else {
// Cast to f32, doing the Gumbel ... | candle/candle-nn/src/sampling.rs/0 | {
"file_path": "candle/candle-nn/src/sampling.rs",
"repo_id": "candle",
"token_count": 357
} | 52 |
# candle-onnx
This crate adds ONNX support to candle
## FAQ
#### Missing protoc installation when compiling candle-onnx
The candle-onnx dependency prost-build no longer comes bundled with prost
binaries. This could cause the following error when attempting to compile
candle-onnx:
```
error: failed to run custom bu... | candle/candle-onnx/README.md/0 | {
"file_path": "candle/candle-onnx/README.md",
"repo_id": "candle",
"token_count": 180
} | 53 |
# Generated content DO NOT EDIT
from typing import Any, Callable, Dict, List, Optional, Tuple, Union, Sequence
from os import PathLike
from candle.typing import _ArrayLike, Device, Scalar, Index, Shape
from candle import Tensor, DType, QTensor
@staticmethod
def avg_pool2d(tensor: Tensor, ksize: int, stride: int = 1) -... | candle/candle-pyo3/py_src/candle/functional/__init__.pyi/0 | {
"file_path": "candle/candle-pyo3/py_src/candle/functional/__init__.pyi",
"repo_id": "candle",
"token_count": 484
} | 54 |
[project]
name = 'candle-nn'
requires-python = '>=3.7'
authors = [
{name = 'The Candle Team'},
]
dynamic = [
'description',
'license',
'readme',
'version',
]
[project.urls]
Homepage = 'https://github.com/huggingface/candle'
Source = 'https://github.com/huggingface/candle'
[build-system]
requires ... | candle/candle-pyo3/pyproject.toml/0 | {
"file_path": "candle/candle-pyo3/pyproject.toml",
"repo_id": "candle",
"token_count": 292
} | 55 |
[package]
name = "candle-transformers"
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]
accelerate-src = { workspace = true, optional = true }
byt... | candle/candle-transformers/Cargo.toml/0 | {
"file_path": "candle/candle-transformers/Cargo.toml",
"repo_id": "candle",
"token_count": 395
} | 56 |
//! Contrastive Language-Image Pre-Training
//!
//! Contrastive Language-Image Pre-Training (CLIP) is an architecture trained on
//! pairs of images with related texts.
//!
//! https://github.com/openai/CLIP
//! https://github.com/huggingface/transformers/tree/f6fa0f0bf0796ac66f201f23bdb8585de1609add/src/transformers/m... | candle/candle-transformers/src/models/clip/vision_model.rs/0 | {
"file_path": "candle/candle-transformers/src/models/clip/vision_model.rs",
"repo_id": "candle",
"token_count": 2837
} | 57 |
//! EVA-2 inference implementation.
//!
//! EVA-02 is a computer vision model that can be used as an ImageNet classifier.
//! The model returns the probability for an image to belong to each of the 1000
//! ImageNet categories.
//!
//! - [Paper](https://arxiv.org/abs/2303.11331). EVA-02: A Visual Representation for Neo... | candle/candle-transformers/src/models/eva2.rs/0 | {
"file_path": "candle/candle-transformers/src/models/eva2.rs",
"repo_id": "candle",
"token_count": 7638
} | 58 |
//! # JinaBERT inference implementation
//!
//! Based on implementation from huggingface for Jina BERT and its variants
//!
//! See: [Jina Embeddings on HuggingFace](https://huggingface.co/jinaai/jina-embeddings-v2-base-en)
use super::with_tracing::{linear, linear_no_bias, Embedding, Linear};
use candle::{DType, Devic... | candle/candle-transformers/src/models/jina_bert.rs/0 | {
"file_path": "candle/candle-transformers/src/models/jina_bert.rs",
"repo_id": "candle",
"token_count": 6364
} | 59 |
//! Mixtral Model, based on the Mistral architecture
//!
//! See Mistral and Mixtral at:
//! - [Hugging Face](https://huggingface.co/docs/transformers/model_doc/mixtral)
//! - [GitHub](https://github.com/mistralai/mistral-src)
//!
use crate::models::with_tracing::{linear_no_bias, Linear, RmsNorm};
/// Mistral LLM, htt... | candle/candle-transformers/src/models/mistral.rs/0 | {
"file_path": "candle/candle-transformers/src/models/mistral.rs",
"repo_id": "candle",
"token_count": 8060
} | 60 |
//! NV-Embed-v2
//!
//! NV-Embed-v2 is a text embedding model that combines a Mistral decoder with a latent attention mechanism to produce high-quality text embeddings.
//!
//! This implementation is based on the [paper](https://arxiv.org/pdf/2405.17428) and [weights](https://huggingface.co/nvidia/NV-Embed-v2)
//!
//! ... | candle/candle-transformers/src/models/nvembed_v2/mod.rs/0 | {
"file_path": "candle/candle-transformers/src/models/nvembed_v2/mod.rs",
"repo_id": "candle",
"token_count": 211
} | 61 |
//! Gemma 3 model implementation with quantization support.
//!
//! Gemma 3 is a family of multimodal language models developed by Google.
//! This implementation provides quantization for reduced memory usage and faster inference.
//!
//! Key characteristics:
//! - Group-Query Attention (GQA) with specialized key-valu... | candle/candle-transformers/src/models/quantized_gemma3.rs/0 | {
"file_path": "candle/candle-transformers/src/models/quantized_gemma3.rs",
"repo_id": "candle",
"token_count": 8559
} | 62 |
//! T5 model implementation with quantization support.
//!
//! T5 is an encoder-decoder model pre-trained on a multi-task mixture of supervised
//! and unsupervised tasks. This implementation provides quantization for reduced
//! memory and compute requirements.
//!
//! Key characteristics:
//! - Encoder-decoder archit... | candle/candle-transformers/src/models/quantized_t5.rs/0 | {
"file_path": "candle/candle-transformers/src/models/quantized_t5.rs",
"repo_id": "candle",
"token_count": 14169
} | 63 |
// Adapted from:
// https://github.com/ChaoningZhang/MobileSAM/blob/master/mobile_sam/modeling/tiny_vit_sam.py
use candle::{IndexOp, Result, Tensor, D};
use candle_nn::{Conv2dConfig, Module, VarBuilder};
const MBCONV_EXPAND_RATIO: usize = 4;
const MLP_RATIO: usize = 4;
const LOCAL_CONV_SIZE: usize = 3;
const IMG_SIZE:... | candle/candle-transformers/src/models/segment_anything/tiny_vit.rs/0 | {
"file_path": "candle/candle-transformers/src/models/segment_anything/tiny_vit.rs",
"repo_id": "candle",
"token_count": 10372
} | 64 |
use candle::{Device, Result, Tensor};
pub fn linspace(start: f64, stop: f64, steps: usize) -> Result<Tensor> {
if steps == 0 {
Tensor::from_vec(Vec::<f64>::new(), steps, &Device::Cpu)
} else if steps == 1 {
Tensor::from_vec(vec![start], steps, &Device::Cpu)
} else {
let delta = (sto... | candle/candle-transformers/src/models/stable_diffusion/utils.rs/0 | {
"file_path": "candle/candle-transformers/src/models/stable_diffusion/utils.rs",
"repo_id": "candle",
"token_count": 971
} | 65 |
//! Apply penalty and repeat_kv
use candle::{Result, Tensor};
pub fn apply_repeat_penalty(logits: &Tensor, penalty: f32, context: &[u32]) -> Result<Tensor> {
let device = logits.device();
let mut logits = logits.to_dtype(candle::DType::F32)?.to_vec1::<f32>()?;
let mut already_seen = std::collections::Hash... | candle/candle-transformers/src/utils.rs/0 | {
"file_path": "candle/candle-transformers/src/utils.rs",
"repo_id": "candle",
"token_count": 642
} | 66 |
use candle::{DType, Device, Tensor};
use candle_nn::VarBuilder;
use candle_transformers::generation::LogitsProcessor;
use candle_transformers::models::blip;
use candle_transformers::models::quantized_blip;
use candle_wasm_example_blip::console_log;
use candle_wasm_example_blip::token_output_stream::TokenOutputStream;
u... | candle/candle-wasm-examples/blip/src/bin/m.rs/0 | {
"file_path": "candle/candle-wasm-examples/blip/src/bin/m.rs",
"repo_id": "candle",
"token_count": 2698
} | 67 |
[package]
name = "candle-wasm-example-whisper"
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-t... | candle/candle-wasm-examples/whisper/Cargo.toml/0 | {
"file_path": "candle/candle-wasm-examples/whisper/Cargo.toml",
"repo_id": "candle",
"token_count": 428
} | 68 |
## Running Yolo Examples
Here, we provide two examples of how to run YOLOv8 using a Candle-compiled WASM binary and runtimes.
### Pure Rust UI
To build and test the UI made in Rust you will need [Trunk](https://trunkrs.dev/#install)
From the `candle-wasm-examples/yolo` directory run:
Download assets:
```bash
wget ... | candle/candle-wasm-examples/yolo/README.md/0 | {
"file_path": "candle/candle-wasm-examples/yolo/README.md",
"repo_id": "candle",
"token_count": 412
} | 69 |
#![allow(unused)]
use candle::{
quantized::{self, k_quants, GgmlDType, GgmlType},
test_utils::to_vec2_round,
Device, Module, Result, Tensor,
};
use wasm_bindgen_test::*;
wasm_bindgen_test_configure!(run_in_browser);
#[wasm_bindgen_test]
fn quantized_matmul_neg() -> Result<()> {
let cpu = &Device::Cpu;... | candle/candle-wasm-tests/tests/quantized_tests.rs/0 | {
"file_path": "candle/candle-wasm-tests/tests/quantized_tests.rs",
"repo_id": "candle",
"token_count": 3151
} | 70 |
{{- define "name" -}}
{{- default $.Release.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- define "app.name" -}}
chat-ui
{{- end -}}
{{- define "labels.standard" -}}
release: {{ $.Release.Name | quote }}
heritage: {{ $.Release.Service | quote }}
chart: "{{ include "name" . }}"
app: "{{ include "app.name" . }}"
... | chat-ui/chart/templates/_helpers.tpl/0 | {
"file_path": "chat-ui/chart/templates/_helpers.tpl",
"repo_id": "chat-ui",
"token_count": 202
} | 71 |
import sade from "sade";
// @ts-expect-error: vite-node makes the var available but the typescript compiler doesn't see them
import { config, ready } from "$lib/server/config";
const prog = sade("config");
await ready;
prog
.command("clear")
.describe("Clear all config keys")
.action(async () => {
console.log("C... | chat-ui/scripts/config.ts/0 | {
"file_path": "chat-ui/scripts/config.ts",
"repo_id": "chat-ui",
"token_count": 510
} | 72 |
<script lang="ts">
interface Props {
title?: string;
classNames?: string;
children?: import("svelte").Snippet;
}
let { title = "", classNames = "", children }: Props = $props();
</script>
<div class="flex items-center rounded-xl bg-gray-100 p-1 text-sm dark:bg-gray-800 {classNames}">
<span
class="from-pri... | chat-ui/src/lib/components/AnnouncementBanner.svelte/0 | {
"file_path": "chat-ui/src/lib/components/AnnouncementBanner.svelte",
"repo_id": "chat-ui",
"token_count": 235
} | 73 |
<script lang="ts">
import { page } from "$app/state";
import { getHref } from "$lib/utils/getHref";
import PaginationArrow from "./PaginationArrow.svelte";
interface Props {
classNames?: string;
numItemsPerPage: number;
numTotalItems: number;
}
let { classNames = "", numItemsPerPage, numTotalItems }: Prop... | chat-ui/src/lib/components/Pagination.svelte/0 | {
"file_path": "chat-ui/src/lib/components/Pagination.svelte",
"repo_id": "chat-ui",
"token_count": 1249
} | 74 |
<script lang="ts">
import type { Message } from "$lib/types/Message";
import { tick } from "svelte";
import { usePublicConfig } from "$lib/utils/PublicConfig.svelte";
const publicConfig = usePublicConfig();
import CopyToClipBoardBtn from "../CopyToClipBoardBtn.svelte";
import IconLoading from "../icons/IconLoadi... | chat-ui/src/lib/components/chat/ChatMessage.svelte/0 | {
"file_path": "chat-ui/src/lib/components/chat/ChatMessage.svelte",
"repo_id": "chat-ui",
"token_count": 4960
} | 75 |
<script lang="ts">
interface Props {
classNames?: string;
}
let { classNames = "" }: Props = $props();
</script>
<svg
class={classNames}
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
focusable="false"
role="img"
width="1em"
height="1em"
fill="currentColor"
preserveAspectRatio="xMidYMid meet"
vi... | chat-ui/src/lib/components/icons/IconPaperclip.svelte/0 | {
"file_path": "chat-ui/src/lib/components/icons/IconPaperclip.svelte",
"repo_id": "chat-ui",
"token_count": 381
} | 76 |
import type { Migration } from ".";
import { collections } from "$lib/server/database";
import { ObjectId, type WithId } from "mongodb";
import type { Conversation } from "$lib/types/Conversation";
import {
MessageUpdateStatus,
MessageUpdateType,
type MessageUpdate,
} from "$lib/types/MessageUpdate";
import type { M... | chat-ui/src/lib/migrations/routines/04-update-message-updates.ts/0 | {
"file_path": "chat-ui/src/lib/migrations/routines/04-update-message-updates.ts",
"repo_id": "chat-ui",
"token_count": 1340
} | 77 |
import { Elysia } from "elysia";
import { authPlugin } from "$api/authPlugin";
import { defaultModel } from "$lib/server/models";
import { collections } from "$lib/server/database";
import { authCondition } from "$lib/server/auth";
import { models, validateModel } from "$lib/server/models";
import { DEFAULT_SETTINGS, t... | chat-ui/src/lib/server/api/routes/groups/user.ts/0 | {
"file_path": "chat-ui/src/lib/server/api/routes/groups/user.ts",
"repo_id": "chat-ui",
"token_count": 1664
} | 78 |
export interface Route {
name: string;
description: string;
primary_model: string;
fallback_models?: string[];
}
export interface RouteConfig {
name: string;
description: string;
}
export const ROUTER_FAILURE = "arch_router_failure";
| chat-ui/src/lib/server/router/types.ts/0 | {
"file_path": "chat-ui/src/lib/server/router/types.ts",
"repo_id": "chat-ui",
"token_count": 79
} | 79 |
// Ideally shouldn't be needed, see https://github.com/huggingface/chat-ui/pull/88#issuecomment-1523173850
import type { Conversation } from "./Conversation";
import type { Timestamps } from "./Timestamps";
export interface AbortedGeneration extends Timestamps {
conversationId: Conversation["_id"];
}
| chat-ui/src/lib/types/AbortedGeneration.ts/0 | {
"file_path": "chat-ui/src/lib/types/AbortedGeneration.ts",
"repo_id": "chat-ui",
"token_count": 93
} | 80 |
import { defaultModel } from "$lib/server/models";
import type { Timestamps } from "./Timestamps";
import type { User } from "./User";
export interface Settings extends Timestamps {
userId?: User["_id"];
sessionId?: string;
shareConversationsWithModelAuthors: boolean;
/** One-time welcome modal acknowledgement */... | chat-ui/src/lib/types/Settings.ts/0 | {
"file_path": "chat-ui/src/lib/types/Settings.ts",
"repo_id": "chat-ui",
"token_count": 410
} | 81 |
export async function getReturnFromGenerator<T, R>(generator: AsyncGenerator<T, R>): Promise<R> {
let result: IteratorResult<T, R>;
do {
result = await generator.next();
} while (!result.done); // Keep calling `next()` until `done` is true
return result.value; // Return the final value
}
| chat-ui/src/lib/utils/getReturnFromGenerator.ts/0 | {
"file_path": "chat-ui/src/lib/utils/getReturnFromGenerator.ts",
"repo_id": "chat-ui",
"token_count": 96
} | 82 |
import type { Message } from "$lib/types/Message";
import Handlebars from "handlebars";
import { Template } from "@huggingface/jinja";
import { logger } from "$lib/server/logger";
// Register Handlebars helpers
Handlebars.registerHelper("ifUser", function (this: Pick<Message, "from" | "content">, options) {
if (this.... | chat-ui/src/lib/utils/template.ts/0 | {
"file_path": "chat-ui/src/lib/utils/template.ts",
"repo_id": "chat-ui",
"token_count": 522
} | 83 |
<script lang="ts">
import { page } from "$app/state";
</script>
<div
class="flex items-center justify-center bg-gradient-to-t from-gray-200 text-gray-800 dark:from-gray-700 dark:text-gray-300"
>
<div
class="align-center -mt-24 flex flex-col justify-center rounded-xl border bg-white px-8 pb-2 pt-4 text-center dark... | chat-ui/src/routes/+error.svelte/0 | {
"file_path": "chat-ui/src/routes/+error.svelte",
"repo_id": "chat-ui",
"token_count": 342
} | 84 |
import { useAPIClient, handleResponse } from "$lib/APIClient";
import { UrlDependency } from "$lib/types/UrlDependency";
import { redirect } from "@sveltejs/kit";
export const load = async ({ params, depends, fetch, url }) => {
depends(UrlDependency.Conversation);
const client = useAPIClient({ fetch, origin: url.or... | chat-ui/src/routes/conversation/[id]/+page.ts/0 | {
"file_path": "chat-ui/src/routes/conversation/[id]/+page.ts",
"repo_id": "chat-ui",
"token_count": 155
} | 85 |
<script lang="ts">
import logo from "../../../../../static/huggingchat/fulltext-logo.svg?raw";
interface Props {
name: string;
isHuggingChat?: boolean;
backgroundImage?: string;
}
let { name, isHuggingChat = false }: Props = $props();
</script>
<div
class=" flex h-[648px] w-full flex-col items-center just... | chat-ui/src/routes/models/[...model]/thumbnail.png/ModelThumbnail.svelte/0 | {
"file_path": "chat-ui/src/routes/models/[...model]/thumbnail.png/ModelThumbnail.svelte",
"repo_id": "chat-ui",
"token_count": 330
} | 86 |
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "ES2018"
},
"exclude": ["vite.config.t... | chat-ui/tsconfig.json/0 | {
"file_path": "chat-ui/tsconfig.json",
"repo_id": "chat-ui",
"token_count": 211
} | 87 |
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit # https://github.com/charliermarsh/ruff#usage
rev: 'v0.11.8'
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
| datasets/.pre-commit-config.yaml/0 | {
"file_path": "datasets/.pre-commit-config.yaml",
"repo_id": "datasets",
"token_count": 122
} | 88 |
import json
import sys
def format_json_to_md(input_json_file, output_md_file):
with open(input_json_file, encoding="utf-8") as f:
results = json.load(f)
output_md = ["<details>", "<summary>Show updated benchmarks!</summary>", " "]
for benchmark_name in sorted(results):
benchmark_res = re... | datasets/benchmarks/format.py/0 | {
"file_path": "datasets/benchmarks/format.py",
"repo_id": "datasets",
"token_count": 746
} | 89 |
# Batch mapping
Combining the utility of [`Dataset.map`] with batch mode is very powerful. It allows you to speed up processing, and freely control the size of the generated dataset.
## Need for speed
The primary objective of batch mapping is to speed up processing. Often times, it is faster to work with batches of... | datasets/docs/source/about_map_batch.mdx/0 | {
"file_path": "datasets/docs/source/about_map_batch.mdx",
"repo_id": "datasets",
"token_count": 931
} | 90 |
# Image classification
Image classification datasets are used to train a model to classify an entire image. There are a wide variety of applications enabled by these datasets such as identifying endangered wildlife species or screening for disease in medical images. This guide will show you how to apply transformation... | datasets/docs/source/image_classification.mdx/0 | {
"file_path": "datasets/docs/source/image_classification.mdx",
"repo_id": "datasets",
"token_count": 1051
} | 91 |
# Table Classes
Each `Dataset` object is backed by a PyArrow Table.
A Table can be loaded from either the disk (memory mapped) or in memory.
Several Table types are available, and they all inherit from [`table.Table`].
## Table
[[autodoc]] datasets.table.Table
- validate
- equals
- to_batches
- to_py... | datasets/docs/source/package_reference/table_classes.mdx/0 | {
"file_path": "datasets/docs/source/package_reference/table_classes.mdx",
"repo_id": "datasets",
"token_count": 1029
} | 92 |
# Use with Polars
This document is a quick introduction to using `datasets` with Polars, with a particular focus on how to process
datasets using Polars functions, and how to convert a dataset to Polars or from Polars.
This is particularly useful as it allows fast zero-copy operations, since both `datasets` and Polar... | datasets/docs/source/use_with_polars.mdx/0 | {
"file_path": "datasets/docs/source/use_with_polars.mdx",
"repo_id": "datasets",
"token_count": 1829
} | 93 |
from abc import ABC, abstractmethod
from argparse import ArgumentParser
class BaseDatasetsCLICommand(ABC):
@staticmethod
@abstractmethod
def register_subcommand(parser: ArgumentParser):
raise NotImplementedError()
@abstractmethod
def run(self):
raise NotImplementedError()
| datasets/src/datasets/commands/__init__.py/0 | {
"file_path": "datasets/src/datasets/commands/__init__.py",
"repo_id": "datasets",
"token_count": 107
} | 94 |
import os
from dataclasses import dataclass, field
from io import BytesIO
from pathlib import Path
from typing import TYPE_CHECKING, Any, ClassVar, Optional, Union
import numpy as np
import pyarrow as pa
from .. import config
from ..download.download_config import DownloadConfig
from ..table import array_cast
from ..... | datasets/src/datasets/features/audio.py/0 | {
"file_path": "datasets/src/datasets/features/audio.py",
"repo_id": "datasets",
"token_count": 5954
} | 95 |
from itertools import chain
from typing import Optional, Union
from huggingface_hub import (
CommitInfo,
CommitOperationAdd,
CommitOperationDelete,
DatasetCard,
DatasetCardData,
HfApi,
HfFileSystem,
)
import datasets.config
from datasets.info import DatasetInfosDict
from datasets.load impo... | datasets/src/datasets/hub.py/0 | {
"file_path": "datasets/src/datasets/hub.py",
"repo_id": "datasets",
"token_count": 2184
} | 96 |
import inspect
import re
from typing import Dict, List, Tuple
from huggingface_hub.utils import insecure_hashlib
from .arrow import arrow
from .audiofolder import audiofolder
from .cache import cache
from .csv import csv
from .hdf5 import hdf5
from .imagefolder import imagefolder
from .json import json
from .pandas i... | datasets/src/datasets/packaged_modules/__init__.py/0 | {
"file_path": "datasets/src/datasets/packaged_modules/__init__.py",
"repo_id": "datasets",
"token_count": 2142
} | 97 |
import datasets
from ..folder_based_builder import folder_based_builder
logger = datasets.utils.logging.get_logger(__name__)
class ImageFolderConfig(folder_based_builder.FolderBasedBuilderConfig):
"""BuilderConfig for ImageFolder."""
drop_labels: bool = None
drop_metadata: bool = None
def __post_... | datasets/src/datasets/packaged_modules/imagefolder/imagefolder.py/0 | {
"file_path": "datasets/src/datasets/packaged_modules/imagefolder/imagefolder.py",
"repo_id": "datasets",
"token_count": 887
} | 98 |
import datasets
from ..folder_based_builder import folder_based_builder
logger = datasets.utils.logging.get_logger(__name__)
class VideoFolderConfig(folder_based_builder.FolderBasedBuilderConfig):
"""BuilderConfig for ImageFolder."""
drop_labels: bool = None
drop_metadata: bool = None
def __post_... | datasets/src/datasets/packaged_modules/videofolder/videofolder.py/0 | {
"file_path": "datasets/src/datasets/packaged_modules/videofolder/videofolder.py",
"repo_id": "datasets",
"token_count": 279
} | 99 |
import enum
import inspect
import warnings
from functools import wraps
from typing import Callable, Optional
from .logging import get_logger
_emitted_deprecation_warnings = set()
logger = get_logger(__name__)
def deprecated(help_message: Optional[str] = None):
"""Decorator to mark a class or a function as depr... | datasets/src/datasets/utils/deprecation_utils.py/0 | {
"file_path": "datasets/src/datasets/utils/deprecation_utils.py",
"repo_id": "datasets",
"token_count": 1426
} | 100 |
name: "" # Filename comes here
allow_empty: false
allow_empty_text: true
subsections:
- name: "Dataset Card for X" # First-level markdown heading
allow_empty: false
allow_empty_text: true
subsections:
- name: "Table of Contents"
allow_empty: false
allow_empty_text: false
subs... | datasets/src/datasets/utils/resources/readme_structure.yaml/0 | {
"file_path": "datasets/src/datasets/utils/resources/readme_structure.yaml",
"repo_id": "datasets",
"token_count": 1924
} | 101 |
import pytest
import datasets
import datasets.config
# Import fixture modules as plugins
pytest_plugins = ["tests.fixtures.files", "tests.fixtures.hub", "tests.fixtures.fsspec"]
def pytest_collection_modifyitems(config, items):
# Mark tests as "unit" by default if not marked as "integration" (or already marked... | datasets/tests/conftest.py/0 | {
"file_path": "datasets/tests/conftest.py",
"repo_id": "datasets",
"token_count": 853
} | 102 |
from pathlib import Path
import pytest
from datasets import Dataset, Features, Pdf
from ..utils import require_pdfplumber
@require_pdfplumber
@pytest.mark.parametrize(
"build_example",
[
lambda pdf_path: pdf_path,
lambda pdf_path: Path(pdf_path),
lambda pdf_path: open(pdf_path, "rb"... | datasets/tests/features/test_pdf.py/0 | {
"file_path": "datasets/tests/features/test_pdf.py",
"repo_id": "datasets",
"token_count": 852
} | 103 |
import os
import tempfile
from pathlib import Path
from unittest import TestCase
import pyarrow as pa
import pytest
from datasets.arrow_dataset import Dataset
from datasets.arrow_reader import ArrowReader, BaseReader, FileInstructions, ReadInstruction, make_file_instructions
from datasets.info import DatasetInfo
from... | datasets/tests/test_arrow_reader.py/0 | {
"file_path": "datasets/tests/test_arrow_reader.py",
"repo_id": "datasets",
"token_count": 5688
} | 104 |
from textwrap import dedent
from types import SimpleNamespace
from unittest.mock import patch
from urllib.parse import quote
import pytest
from huggingface_hub import CommitOperationAdd, CommitOperationDelete
import datasets
from datasets.config import METADATA_CONFIGS_FIELD
from datasets.hub import delete_from_hub
f... | datasets/tests/test_hub.py/0 | {
"file_path": "datasets/tests/test_hub.py",
"repo_id": "datasets",
"token_count": 1576
} | 105 |
import unittest
from unittest.mock import patch
import pytest
from pytest import CaptureFixture
from datasets.utils import (
are_progress_bars_disabled,
disable_progress_bars,
enable_progress_bars,
tqdm,
)
class TestTqdmUtils(unittest.TestCase):
@pytest.fixture(autouse=True)
def capsys(self,... | datasets/tests/test_tqdm.py/0 | {
"file_path": "datasets/tests/test_tqdm.py",
"repo_id": "datasets",
"token_count": 1804
} | 106 |
from functools import partial
import torch
from benchmarking_utils import BenchmarkMixin, BenchmarkScenario, model_init_fn
from diffusers import LTXVideoTransformer3DModel
from diffusers.utils.testing_utils import torch_device
CKPT_ID = "Lightricks/LTX-Video-0.9.7-dev"
RESULT_FILENAME = "ltx.csv"
def get_input_di... | diffusers/benchmarks/benchmarking_ltx.py/0 | {
"file_path": "diffusers/benchmarks/benchmarking_ltx.py",
"repo_id": "diffusers",
"token_count": 1511
} | 107 |
<!--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/TRANSLATING.md/0 | {
"file_path": "diffusers/docs/TRANSLATING.md",
"repo_id": "diffusers",
"token_count": 1100
} | 108 |
<!--Copyright 2025 The HuggingFace Team and The InstantX 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 ap... | diffusers/docs/source/en/api/models/controlnet_union.md/0 | {
"file_path": "diffusers/docs/source/en/api/models/controlnet_union.md",
"repo_id": "diffusers",
"token_count": 486
} | 109 |
<!--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/overview.md/0 | {
"file_path": "diffusers/docs/source/en/api/pipelines/overview.md",
"repo_id": "diffusers",
"token_count": 2114
} | 110 |
<!--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_cascade.md/0 | {
"file_path": "diffusers/docs/source/en/api/pipelines/stable_cascade.md",
"repo_id": "diffusers",
"token_count": 2836
} | 111 |
<!--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/schedulers/ddim.md/0 | {
"file_path": "diffusers/docs/source/en/api/schedulers/ddim.md",
"repo_id": "diffusers",
"token_count": 1122
} | 112 |
<!--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/schedulers/lcm.md/0 | {
"file_path": "diffusers/docs/source/en/api/schedulers/lcm.md",
"repo_id": "diffusers",
"token_count": 292
} | 113 |
<!--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/video_processor.md/0 | {
"file_path": "diffusers/docs/source/en/api/video_processor.md",
"repo_id": "diffusers",
"token_count": 266
} | 114 |
<!--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/modular_diffusers/guiders.md/0 | {
"file_path": "diffusers/docs/source/en/modular_diffusers/guiders.md",
"repo_id": "diffusers",
"token_count": 2572
} | 115 |
<!--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/mps.md/0 | {
"file_path": "diffusers/docs/source/en/optimization/mps.md",
"repo_id": "diffusers",
"token_count": 1245
} | 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 agree... | diffusers/docs/source/en/quantization/torchao.md/0 | {
"file_path": "diffusers/docs/source/en/quantization/torchao.md",
"repo_id": "diffusers",
"token_count": 2770
} | 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/training/sdxl.md/0 | {
"file_path": "diffusers/docs/source/en/training/sdxl.md",
"repo_id": "diffusers",
"token_count": 4384
} | 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 applicable law or agreed... | diffusers/docs/source/en/using-diffusers/custom_pipeline_overview.md/0 | {
"file_path": "diffusers/docs/source/en/using-diffusers/custom_pipeline_overview.md",
"repo_id": "diffusers",
"token_count": 2793
} | 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/using-diffusers/push_to_hub.md/0 | {
"file_path": "diffusers/docs/source/en/using-diffusers/push_to_hub.md",
"repo_id": "diffusers",
"token_count": 1981
} | 120 |
<!--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/ja/quicktour.md/0 | {
"file_path": "diffusers/docs/source/ja/quicktour.md",
"repo_id": "diffusers",
"token_count": 7859
} | 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 agreed... | diffusers/docs/source/ko/optimization/mps.md/0 | {
"file_path": "diffusers/docs/source/ko/optimization/mps.md",
"repo_id": "diffusers",
"token_count": 2535
} | 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/ko/training/overview.md/0 | {
"file_path": "diffusers/docs/source/ko/training/overview.md",
"repo_id": "diffusers",
"token_count": 4741
} | 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/ko/using-diffusers/other-formats.md/0 | {
"file_path": "diffusers/docs/source/ko/using-diffusers/other-formats.md",
"repo_id": "diffusers",
"token_count": 6828
} | 124 |
<!--版权 2025 The HuggingFace Team。保留所有权利。
根据Apache许可证,版本2.0("许可证")授权;除非符合许可证,否则不得使用此文件。您可以在
http://www.apache.org/licenses/LICENSE-2.0
获取许可证的副本。
除非适用法律要求或书面同意,根据许可证分发的软件是按"原样"分发的,没有任何形式的明示或暗示的担保或条件。有关许可证的特定语言,请参阅许可证。
-->
# 社区项目
欢迎来到社区项目。这个空间致力于展示我们充满活力的社区使用`diffusers`库创建的令人难以置信的工作和创新应用。
本节旨在:
- 突出使用`diffusers`构建... | diffusers/docs/source/zh/community_projects.md/0 | {
"file_path": "diffusers/docs/source/zh/community_projects.md",
"repo_id": "diffusers",
"token_count": 2255
} | 125 |
<!--版权所有 2025 The HuggingFace Team。保留所有权利。
根据Apache许可证2.0版("许可证")授权;除非符合许可证,否则不得使用此文件。您可以在以下位置获取许可证的副本:
http://www.apache.org/licenses/LICENSE-2.0
除非适用法律要求或书面同意,根据许可证分发的软件按"原样"分发,无任何明示或暗示的担保或条件。有关许可证下特定语言的权限和限制,请参阅许可证。
-->
# 概述
> [!WARNING]
> 模块化Diffusers正在积极开发中,其API可能会发生变化。
模块化Diffusers是一个统一的管道系统,通过*管道块*简化您的工作流程... | diffusers/docs/source/zh/modular_diffusers/overview.md/0 | {
"file_path": "diffusers/docs/source/zh/modular_diffusers/overview.md",
"repo_id": "diffusers",
"token_count": 1430
} | 126 |
<!--版权所有 2024 The HuggingFace Team。保留所有权利。
根据 Apache 许可证 2.0 版(“许可证”)授权;除非符合许可证,否则不得使用此文件。
您可以在以下网址获取许可证副本:
http://www.apache.org/licenses/LICENSE-2.0
除非适用法律要求或书面同意,根据许可证分发的软件按“原样”分发,不附带任何明示或暗示的担保或条件。有关许可证的特定语言,请参阅许可证。
-->
# 编译和卸载量化模型
优化模型通常涉及[推理速度](./fp16)和[内存使用](./memory)之间的权衡。例如,虽然[缓存](./cache)可以提高推理速度,但它也会增加内存... | diffusers/docs/source/zh/optimization/speed-memory-optims.md/0 | {
"file_path": "diffusers/docs/source/zh/optimization/speed-memory-optims.md",
"repo_id": "diffusers",
"token_count": 4097
} | 127 |
<!--版权声明 2025 由 HuggingFace 团队所有。保留所有权利。
根据 Apache 许可证 2.0 版("许可证")授权;除非符合许可证要求,否则不得使用本文件。
您可以通过以下网址获取许可证副本:
http://www.apache.org/licenses/LICENSE-2.0
除非适用法律要求或书面同意,本软件按"原样"分发,不附带任何明示或暗示的担保或条件。详见许可证中规定的特定语言权限和限制。
-->
# 文本反转(Textual Inversion)
[文本反转](https://hf.co/papers/2208.01618)是一种训练技术,仅需少量示例图像即可个性化图像生成模型。该技术通... | diffusers/docs/source/zh/training/text_inversion.md/0 | {
"file_path": "diffusers/docs/source/zh/training/text_inversion.md",
"repo_id": "diffusers",
"token_count": 6739
} | 128 |
# 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... | diffusers/examples/community/ddim_noise_comparative_analysis.py/0 | {
"file_path": "diffusers/examples/community/ddim_noise_comparative_analysis.py",
"repo_id": "diffusers",
"token_count": 3415
} | 129 |
# Copyright 2025 Long Lian, the GLIGEN Authors, 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... | diffusers/examples/community/llm_grounded_diffusion.py/0 | {
"file_path": "diffusers/examples/community/llm_grounded_diffusion.py",
"repo_id": "diffusers",
"token_count": 32839
} | 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 applicabl... | diffusers/examples/community/pipeline_animatediff_img2video.py/0 | {
"file_path": "diffusers/examples/community/pipeline_animatediff_img2video.py",
"repo_id": "diffusers",
"token_count": 20617
} | 131 |
import inspect
import os
import numpy as np
import torch
import torch.nn.functional as nnf
from PIL import Image
from torch.optim.adam import Adam
from tqdm import tqdm
from diffusers import StableDiffusionPipeline
from diffusers.pipelines.stable_diffusion import StableDiffusionPipelineOutput
def retrieve_timesteps... | diffusers/examples/community/pipeline_null_text_inversion.py/0 | {
"file_path": "diffusers/examples/community/pipeline_null_text_inversion.py",
"repo_id": "diffusers",
"token_count": 5423
} | 132 |
from typing import Any, Callable, Dict, List, Optional, Union
import torch
from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer
from diffusers import (
AutoencoderKL,
DDIMScheduler,
DiffusionPipeline,
LMSDiscreteScheduler,
PNDMScheduler,
StableDiffusionPipeline,
UNet2D... | diffusers/examples/community/stable_diffusion_comparison.py/0 | {
"file_path": "diffusers/examples/community/stable_diffusion_comparison.py",
"repo_id": "diffusers",
"token_count": 7371
} | 133 |
# Copyright 2025 Peter Willemsen <peter@codebuffet.co>. 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 requ... | diffusers/examples/community/tiled_upscaling.py/0 | {
"file_path": "diffusers/examples/community/tiled_upscaling.py",
"repo_id": "diffusers",
"token_count": 5901
} | 134 |
# ControlNet training example for Stable Diffusion 3/3.5 (SD3/3.5)
The `train_controlnet_sd3.py` script shows how to implement the ControlNet training procedure and adapt it for [Stable Diffusion 3](https://huggingface.co/papers/2403.03206) and [Stable Diffusion 3.5](https://stability.ai/news/introducing-stable-diffus... | diffusers/examples/controlnet/README_sd3.md/0 | {
"file_path": "diffusers/examples/controlnet/README_sd3.md",
"repo_id": "diffusers",
"token_count": 2839
} | 135 |
# 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/custom_diffusion/test_custom_diffusion.py/0 | {
"file_path": "diffusers/examples/custom_diffusion/test_custom_diffusion.py",
"repo_id": "diffusers",
"token_count": 2234
} | 136 |
import warnings
from diffusers import StableDiffusionImg2ImgPipeline # noqa F401
warnings.warn(
"The `image_to_image.py` script is outdated. Please use directly `from diffusers import"
" StableDiffusionImg2ImgPipeline` instead."
)
| diffusers/examples/inference/image_to_image.py/0 | {
"file_path": "diffusers/examples/inference/image_to_image.py",
"repo_id": "diffusers",
"token_count": 84
} | 137 |
import os
from typing import List
import faiss
import numpy as np
import torch
from datasets import Dataset, load_dataset
from PIL import Image
from transformers import CLIPImageProcessor, CLIPModel, PretrainedConfig
from diffusers import logging
logger = logging.get_logger(__name__) # pylint: disable=invalid-name... | diffusers/examples/research_projects/rdm/retriever.py/0 | {
"file_path": "diffusers/examples/research_projects/rdm/retriever.py",
"repo_id": "diffusers",
"token_count": 3929
} | 138 |
# Running Stable Diffusion 3 DreamBooth LoRA training under 16GB
This is an **EDUCATIONAL** project that provides utilities for DreamBooth LoRA training for [Stable Diffusion 3 (SD3)](ttps://huggingface.co/papers/2403.03206) under 16GB GPU VRAM. This means you can successfully try out this project using a [free-tier C... | diffusers/examples/research_projects/sd3_lora_colab/README.md/0 | {
"file_path": "diffusers/examples/research_projects/sd3_lora_colab/README.md",
"repo_id": "diffusers",
"token_count": 704
} | 139 |
# Asynchronous server and parallel execution of models
> Example/demo server that keeps a single model in memory while safely running parallel inference requests by creating per-request lightweight views and cloning only small, stateful components (schedulers, RNG state, small mutable attrs). Works with StableDiffusio... | diffusers/examples/server-async/README.md/0 | {
"file_path": "diffusers/examples/server-async/README.md",
"repo_id": "diffusers",
"token_count": 2414
} | 140 |
[tool.ruff]
line-length = 119
[tool.ruff.lint]
# Never enforce `E501` (line length violations).
ignore = ["C901", "E501", "E721", "E741", "F402", "F823"]
select = ["C", "E", "F", "I", "W"]
# Ignore import violations in all `__init__.py` files.
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["E402", "F401", "F403",... | diffusers/pyproject.toml/0 | {
"file_path": "diffusers/pyproject.toml",
"repo_id": "diffusers",
"token_count": 291
} | 141 |
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... | diffusers/scripts/convert_consistency_to_diffusers.py/0 | {
"file_path": "diffusers/scripts/convert_consistency_to_diffusers.py",
"repo_id": "diffusers",
"token_count": 5773
} | 142 |
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... | diffusers/scripts/convert_if.py/0 | {
"file_path": "diffusers/scripts/convert_if.py",
"repo_id": "diffusers",
"token_count": 23054
} | 143 |
# 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/scripts/convert_stable_diffusion_checkpoint_to_onnx.py/0 | {
"file_path": "diffusers/scripts/convert_stable_diffusion_checkpoint_to_onnx.py",
"repo_id": "diffusers",
"token_count": 4384
} | 144 |
# 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/setup.py/0 | {
"file_path": "diffusers/setup.py",
"repo_id": "diffusers",
"token_count": 4217
} | 145 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.