text
stringlengths
96
319k
id
stringlengths
14
178
metadata
dict
pub const AFFINE: &str = include_str!(concat!(env!("OUT_DIR"), "/affine.ptx")); pub const BINARY: &str = include_str!(concat!(env!("OUT_DIR"), "/binary.ptx")); pub const CAST: &str = include_str!(concat!(env!("OUT_DIR"), "/cast.ptx")); pub const CONV: &str = include_str!(concat!(env!("OUT_DIR"), "/conv.ptx")); pub cons...
candle/candle-kernels/src/lib.rs/0
{ "file_path": "candle/candle-kernels/src/lib.rs", "repo_id": "candle", "token_count": 365 }
// MLX Kernel extracted from: // https://github.com/ml-explore/mlx/blob/main/mlx/backend/metal/kernels/steel/gemm // Copyright © 2024 Apple Inc. #include <metal_simdgroup> #include <metal_simdgroup_matrix> #include <metal_stdlib> #define STEEL_CONST static constant constexpr const #define STEEL_PRAGMA_UNROLL _Pragma(...
candle/candle-metal-kernels/src/mlx_gemm.metal/0
{ "file_path": "candle/candle-metal-kernels/src/mlx_gemm.metal", "repo_id": "candle", "token_count": 20231 }
use candle_metal_kernels::{call_cast_contiguous, Kernels}; use metal::objc::rc::autoreleasepool; use metal::{Device, MTLResourceOptions}; use rand; use std::any::type_name; use std::time::Instant; fn main() { let device = Device::system_default().unwrap(); let kernels = Kernels::new(); let f32_1k = (0..10...
candle/candle-metal-kernels/tmp/cast.rs/0
{ "file_path": "candle/candle-metal-kernels/tmp/cast.rs", "repo_id": "candle", "token_count": 1299 }
//! Layers defined by closures. use candle::{Result, Tensor}; use std::sync::Arc; /// A layer defined by a simple closure. #[derive(Clone)] pub struct Func<'a> { #[allow(clippy::type_complexity)] f: Arc<dyn 'a + Fn(&Tensor) -> Result<Tensor> + Send + Sync>, } impl std::fmt::Debug for Func<'_> { fn fmt(&se...
candle/candle-nn/src/func.rs/0
{ "file_path": "candle/candle-nn/src/func.rs", "repo_id": "candle", "token_count": 784 }
/* Equivalent PyTorch code. import torch from torch.nn.functional import group_norm t = torch.tensor( [[[-0.3034, 0.2726, -0.9659], [-1.1845, -1.3236, 0.0172], [ 1.9507, 1.2554, -0.8625], [ 1.0682, 0.3604, 0.3985], [-0.4957, -0.4461, -0.9721], [ 1.5157, -0....
candle/candle-nn/tests/group_norm.rs/0
{ "file_path": "candle/candle-nn/tests/group_norm.rs", "repo_id": "candle", "token_count": 2154 }
import math from typing import Any import candle from candle import Tensor from .module import Module # See https://github.com/pytorch/pytorch/blob/main/torch/nn/modules/linear.py class Identity(Module): r"""A placeholder identity operator that is argument-insensitive. Args: args: any argument (unu...
candle/candle-pyo3/py_src/candle/nn/linear.py/0
{ "file_path": "candle/candle-pyo3/py_src/candle/nn/linear.py", "repo_id": "candle", "token_count": 1947 }
# See: https://raw.githubusercontent.com/huggingface/tokenizers/main/bindings/python/stub.py import argparse import inspect import os from typing import Optional import black from pathlib import Path import re INDENT = " " * 4 GENERATED_COMMENT = "# Generated content DO NOT EDIT\n" TYPING = """from typing import Any,...
candle/candle-pyo3/stub.py/0
{ "file_path": "candle/candle-pyo3/stub.py", "repo_id": "candle", "token_count": 3931 }
//! BERT (Bidirectional Encoder Representations from Transformers) //! //! Bert is a general large language model that can be used for various language tasks: //! - Compute sentence embeddings for a prompt. //! - Compute similarities between a set of sentences. //! - [Arxiv](https://arxiv.org/abs/1810.04805) "BERT: Pre...
candle/candle-transformers/src/models/bert.rs/0
{ "file_path": "candle/candle-transformers/src/models/bert.rs", "repo_id": "candle", "token_count": 10056 }
use std::collections::HashMap; use candle::{bail, Context, DType, Device, Module, Result, Tensor, D}; use candle_nn::{ conv1d, embedding, layer_norm, Conv1d, Conv1dConfig, Embedding, LayerNorm, VarBuilder, }; use serde::{Deserialize, Deserializer}; pub const DTYPE: DType = DType::F32; // NOTE: HiddenAct and Hidd...
candle/candle-transformers/src/models/debertav2.rs/0
{ "file_path": "candle/candle-transformers/src/models/debertav2.rs", "repo_id": "candle", "token_count": 24495 }
//! Gemma inference implementation. //! //! See ["Gemma: Open Models Based on Gemini Technology"](https://blog.google/technology/developers/gemma-open-ai-model/) //! //! Based on implementation from Google and PyTorch use std::sync::Arc; use candle::{DType, Device, Module, Result, Tensor, D}; use candle_nn::{linear_b...
candle/candle-transformers/src/models/gemma.rs/0
{ "file_path": "candle/candle-transformers/src/models/gemma.rs", "repo_id": "candle", "token_count": 7496 }
// Copyright (c) Kyutai, all rights reserved. // This source code is licensed under the license found in the // LICENSE file in the root directory of this source tree. use candle::{Module, Result, StreamTensor, StreamingModule, Tensor, D}; use candle_nn::{Conv1d, VarBuilder}; #[allow(clippy::enum_variant_names)] #[de...
candle/candle-transformers/src/models/mimi/conv.rs/0
{ "file_path": "candle/candle-transformers/src/models/mimi/conv.rs", "repo_id": "candle", "token_count": 11113 }
//! # MobileOne //! //! MobileOne inference implementation based on timm and candle-repvgg //! //! See ["MobileOne: An Improved One millisecond Mobile Backbone"](https://arxiv.org/abs/2206.04040) use candle::{DType, Result, Tensor, D}; use candle_nn::{ batch_norm, conv2d, conv2d_no_bias, linear, ops::sigmoid, Batc...
candle/candle-transformers/src/models/mobileone.rs/0
{ "file_path": "candle/candle-transformers/src/models/mobileone.rs", "repo_id": "candle", "token_count": 4729 }
use candle::{Module, Result, Tensor}; use candle_nn::{linear, Linear, VarBuilder}; use super::vision_model; use crate::models::mistral; #[derive(serde::Deserialize, Debug, Clone)] pub struct Config { pub projector_hidden_act: candle_nn::Activation, pub text_config: mistral::Config, pub vision_config: visi...
candle/candle-transformers/src/models/pixtral/llava.rs/0
{ "file_path": "candle/candle-transformers/src/models/pixtral/llava.rs", "repo_id": "candle", "token_count": 1393 }
//! RWKV v5 model implementation with quantization support. //! //! RWKV v5 is an attention-free language model optimized for efficiency. //! This implementation provides quantization for reduced memory and compute. //! //! Key characteristics: //! - Linear attention mechanism //! - GroupNorm layer normalization //! - ...
candle/candle-transformers/src/models/quantized_rwkv_v5.rs/0
{ "file_path": "candle/candle-transformers/src/models/quantized_rwkv_v5.rs", "repo_id": "candle", "token_count": 5686 }
use candle::{DType, IndexOp, Result, Tensor}; use candle_nn::{Module, VarBuilder}; use super::image_encoder::ImageEncoderViT; use super::mask_decoder::MaskDecoder; use super::prompt_encoder::PromptEncoder; use super::tiny_vit::{tiny_vit_5m, TinyViT}; const PROMPT_EMBED_DIM: usize = 256; pub const IMAGE_SIZE: usize = ...
candle/candle-transformers/src/models/segment_anything/sam.rs/0
{ "file_path": "candle/candle-transformers/src/models/segment_anything/sam.rs", "repo_id": "candle", "token_count": 8444 }
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 }
use candle::{Result, Tensor}; #[derive(Debug, Clone)] pub struct DDPMWSchedulerConfig { scaler: f64, s: f64, } impl Default for DDPMWSchedulerConfig { fn default() -> Self { Self { scaler: 1f64, s: 0.008f64, } } } pub struct DDPMWScheduler { init_alpha_cump...
candle/candle-transformers/src/models/wuerstchen/ddpm.rs/0
{ "file_path": "candle/candle-transformers/src/models/wuerstchen/ddpm.rs", "repo_id": "candle", "token_count": 1537 }
## Running [llama2.c](https://github.com/karpathy/llama2.c) Examples Here, we provide two examples of how to run [llama2.c](https://github.com/karpathy/llama2.c) written in Rust 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://trun...
candle/candle-wasm-examples/llama2-c/README.md/0
{ "file_path": "candle/candle-wasm-examples/llama2-c/README.md", "repo_id": "candle", "token_count": 449 }
<html> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type" /> <title>Candle Moondream Rust/WASM</title> </head> <body></body> </html> <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link ...
candle/candle-wasm-examples/moondream/index.html/0
{ "file_path": "candle/candle-wasm-examples/moondream/index.html", "repo_id": "candle", "token_count": 6120 }
use candle::{DType, Device, Tensor}; use candle_nn::VarBuilder; use candle_wasm_example_sam as sam; use wasm_bindgen::prelude::*; struct Embeddings { original_width: u32, original_height: u32, width: u32, height: u32, data: Tensor, } #[wasm_bindgen] pub struct Model { sam: sam::Sam, embedd...
candle/candle-wasm-examples/segment-anything/src/bin/m.rs/0
{ "file_path": "candle/candle-wasm-examples/segment-anything/src/bin/m.rs", "repo_id": "candle", "token_count": 2399 }
<html> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type" /> <title>Candle Whisper Rust/WASM</title> </head> <body></body> </html> <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <style> ...
candle/candle-wasm-examples/whisper/lib-example.html/0
{ "file_path": "candle/candle-wasm-examples/whisper/lib-example.html", "repo_id": "candle", "token_count": 6488 }
use crate::console_log; use crate::worker::{ModelData, RunData, Worker, WorkerInput, WorkerOutput}; use wasm_bindgen::prelude::*; use wasm_bindgen_futures::JsFuture; use yew::{html, Component, Context, Html}; use yew_agent::{Bridge, Bridged}; async fn fetch_url(url: &str) -> Result<Vec<u8>, JsValue> { use web_sys:...
candle/candle-wasm-examples/yolo/src/app.rs/0
{ "file_path": "candle/candle-wasm-examples/yolo/src/app.rs", "repo_id": "candle", "token_count": 5961 }
 backend-test:J  xytest"Relu SingleReluZ x   b y   B
candle/test.onnx/0
{ "file_path": "candle/test.onnx", "repo_id": "candle", "token_count": 76 }
{{- if .Values.infisical.enabled }} apiVersion: secrets.infisical.com/v1alpha1 kind: InfisicalSecret metadata: name: {{ include "name" $ }}-infisical-secret namespace: {{ $.Release.Namespace }} spec: authentication: universalAuth: credentialsRef: secretName: {{ .Values.infisical.operatorSecretNa...
chat-ui/chart/templates/infisical.yaml/0
{ "file_path": "chat-ui/chart/templates/infisical.yaml", "repo_id": "chat-ui", "token_count": 311 }
# Cohere | Feature | Available | | --------------------------- | --------- | | [Tools](../tools) | Yes | | [Multimodal](../multimodal) | No | You may use Cohere to run their models directly from Chat UI. You will need to have a Cohere account, then get your [API token](https...
chat-ui/docs/source/configuration/models/providers/cohere.md/0
{ "file_path": "chat-ui/docs/source/configuration/models/providers/cohere.md", "repo_id": "chat-ui", "token_count": 342 }
# Helm <Tip warning={true}> **We highly discourage using the chart**. The Helm chart is a work in progress and should be considered unstable. Breaking changes to the chart may be pushed without migration guides or notice. Contributions welcome! </Tip> For installation on Kubernetes, you may use the helm chart in `/...
chat-ui/docs/source/installation/helm.md/0
{ "file_path": "chat-ui/docs/source/installation/helm.md", "repo_id": "chat-ui", "token_count": 292 }
import type { EndpointParameters } from "./server/endpoints/endpoints"; import type { BackendModel } from "./server/models"; import type { Tool, ToolResult } from "./types/Tool"; type buildPromptOptions = Pick<EndpointParameters, "messages" | "preprompt" | "continueMessage"> & { model: BackendModel; tools?: Tool[]; ...
chat-ui/src/lib/buildPrompt.ts/0
{ "file_path": "chat-ui/src/lib/buildPrompt.ts", "repo_id": "chat-ui", "token_count": 514 }
<script lang="ts"> import { base } from "$app/paths"; import Logo from "$lib/components/icons/Logo.svelte"; import { switchTheme } from "$lib/switchTheme"; import { isAborted } from "$lib/stores/isAborted"; import { env as envPublic } from "$env/dynamic/public"; import NavConversationItem from "./NavConversation...
chat-ui/src/lib/components/NavMenu.svelte/0
{ "file_path": "chat-ui/src/lib/components/NavMenu.svelte", "repo_id": "chat-ui", "token_count": 3075 }
<script lang="ts"> interface Props { classNames?: string; label?: string; position?: string; } let { classNames = "", label = "Copied", position = "left-1/2 top-full transform -translate-x-1/2 translate-y-2", }: Props = $props(); </script> <div class=" pointer-events-none absolute rounded bg-black ...
chat-ui/src/lib/components/Tooltip.svelte/0
{ "file_path": "chat-ui/src/lib/components/Tooltip.svelte", "repo_id": "chat-ui", "token_count": 260 }
<script lang="ts"> interface Props { classNames?: string; } let { classNames = "" }: Props = $props(); </script> <svg width="1em" height="1em" viewBox="0 0 15 6" class={classNames} fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M1.67236 1L7.67236 7L13.6724 1" stroke="currentColor" stroke-...
chat-ui/src/lib/components/icons/IconChevron.svelte/0
{ "file_path": "chat-ui/src/lib/components/icons/IconChevron.svelte", "repo_id": "chat-ui", "token_count": 181 }
import type { ConversationStats } from "$lib/types/ConversationStats"; import { CONVERSATION_STATS_COLLECTION, collections } from "$lib/server/database"; import { logger } from "$lib/server/logger"; import type { ObjectId } from "mongodb"; import { acquireLock, refreshLock } from "$lib/migrations/lock"; export async f...
chat-ui/src/lib/jobs/refresh-conversation-stats.ts/0
{ "file_path": "chat-ui/src/lib/jobs/refresh-conversation-stats.ts", "repo_id": "chat-ui", "token_count": 2646 }
import { Issuer, type BaseClient, type UserinfoResponse, type TokenSet, custom, } from "openid-client"; import { addHours, addWeeks } from "date-fns"; import { env } from "$env/dynamic/private"; import { sha256 } from "$lib/utils/sha256"; import { z } from "zod"; import { dev } from "$app/environment"; import type...
chat-ui/src/lib/server/auth.ts/0
{ "file_path": "chat-ui/src/lib/server/auth.ts", "repo_id": "chat-ui", "token_count": 1854 }
import type { Conversation } from "$lib/types/Conversation"; import type { Message } from "$lib/types/Message"; import type { TextGenerationStreamOutput, TextGenerationStreamToken } from "@huggingface/inference"; import { endpointTgi, endpointTgiParametersSchema } from "./tgi/endpointTgi"; import { z } from "zod"; impo...
chat-ui/src/lib/server/endpoints/endpoints.ts/0
{ "file_path": "chat-ui/src/lib/server/endpoints/endpoints.ts", "repo_id": "chat-ui", "token_count": 1103 }
import { isURLLocal } from "../isURLLocal"; import { env } from "$env/dynamic/private"; import { collections } from "$lib/server/database"; import type { Assistant } from "$lib/types/Assistant"; import type { ObjectId } from "mongodb"; export async function processPreprompt(preprompt: string, user_message: string | un...
chat-ui/src/lib/server/textGeneration/assistant.ts/0
{ "file_path": "chat-ui/src/lib/server/textGeneration/assistant.ts", "repo_id": "chat-ui", "token_count": 886 }
import { MetricsServer } from "$lib/server/metrics"; import type { WebSearchScrapedSource, WebSearchUsedSource } from "$lib/types/WebSearch"; import type { EmbeddingBackendModel } from "../../embeddingModels"; import { getSentenceSimilarity, innerProduct } from "../../sentenceSimilarity"; import { MarkdownElementType, ...
chat-ui/src/lib/server/websearch/embed/embed.ts/0
{ "file_path": "chat-ui/src/lib/server/websearch/embed/embed.ts", "repo_id": "chat-ui", "token_count": 1027 }
import { env } from "$env/dynamic/private"; import { logger } from "$lib/server/logger"; import type { WebSearchSource } from "$lib/types/WebSearch"; import { isURL } from "$lib/utils/isUrl"; export default async function searchSearxng(query: string): Promise<WebSearchSource[]> { const abortController = new AbortCont...
chat-ui/src/lib/server/websearch/search/endpoints/searxng.ts/0
{ "file_path": "chat-ui/src/lib/server/websearch/search/endpoints/searxng.ts", "repo_id": "chat-ui", "token_count": 417 }
import type { ObjectId } from "bson"; import type { Timestamps } from "./Timestamps"; import type { User } from "./User"; export interface Session extends Timestamps { _id: ObjectId; sessionId: string; userId: User["_id"]; userAgent?: string; ip?: string; expiresAt: Date; }
chat-ui/src/lib/types/Session.ts/0
{ "file_path": "chat-ui/src/lib/types/Session.ts", "repo_id": "chat-ui", "token_count": 97 }
import { base } from "$app/paths"; import type { Client } from "@gradio/client"; export type ApiReturnType = Awaited<ReturnType<typeof Client.prototype.view_api>>; export async function getGradioApi(space: string) { const api: ApiReturnType = await fetch(`${base}/api/spaces-config?space=${space}`).then( async (res...
chat-ui/src/lib/utils/getGradioApi.ts/0
{ "file_path": "chat-ui/src/lib/utils/getGradioApi.ts", "repo_id": "chat-ui", "token_count": 166 }
import { describe, expect, it } from "vitest"; import { isMessageId } from "./isMessageId"; import { v4 } from "uuid"; describe("isMessageId", () => { it("should return true for a valid message id", () => { expect(isMessageId(v4())).toBe(true); }); it("should return false for an invalid message id", () => { exp...
chat-ui/src/lib/utils/tree/isMessageId.spec.ts/0
{ "file_path": "chat-ui/src/lib/utils/tree/isMessageId.spec.ts", "repo_id": "chat-ui", "token_count": 170 }
import { env } from "$env/dynamic/private"; import { collections } from "$lib/server/database.js"; import { toolFromConfigs } from "$lib/server/tools/index.js"; import type { BaseTool, CommunityToolDB } from "$lib/types/Tool.js"; import { generateQueryTokens, generateSearchTokens } from "$lib/utils/searchTokens.js"; im...
chat-ui/src/routes/api/tools/search/+server.ts/0
{ "file_path": "chat-ui/src/routes/api/tools/search/+server.ts", "repo_id": "chat-ui", "token_count": 683 }
import { authCondition } from "$lib/server/auth"; import { collections } from "$lib/server/database"; import type { SharedConversation } from "$lib/types/SharedConversation"; import { getShareUrl } from "$lib/utils/getShareUrl"; import { hashConv } from "$lib/utils/hashConv"; import { error } from "@sveltejs/kit"; impo...
chat-ui/src/routes/conversation/[id]/share/+server.ts/0
{ "file_path": "chat-ui/src/routes/conversation/[id]/share/+server.ts", "repo_id": "chat-ui", "token_count": 760 }
<script lang="ts"> import { onMount } from "svelte"; import { base } from "$app/paths"; import { afterNavigate, goto } from "$app/navigation"; import { page } from "$app/state"; import { useSettingsStore } from "$lib/stores/settings"; import CarbonClose from "~icons/carbon/close"; import CarbonArrowUpRight from ...
chat-ui/src/routes/settings/(nav)/+layout.svelte/0
{ "file_path": "chat-ui/src/routes/settings/(nav)/+layout.svelte", "repo_id": "chat-ui", "token_count": 3297 }
<script lang="ts"> import { env as envPublic } from "$env/dynamic/public"; import { isHuggingChat } from "$lib/utils/isHuggingChat"; import { base } from "$app/paths"; import { page } from "$app/state"; interface Props { children?: import("svelte").Snippet; } let { children }: Props = $props(); </script> <sv...
chat-ui/src/routes/tools/+layout.svelte/0
{ "file_path": "chat-ui/src/routes/tools/+layout.svelte", "repo_id": "chat-ui", "token_count": 320 }
{ "$schema": "https://vega.github.io/schema/vega-lite/v4.json", "data": { "values": "<DVC_METRIC_DATA>" }, "title": "<DVC_METRIC_TITLE>", "mark": "rect", "encoding": { "x": { "field": "<DVC_METRIC_X>", "type": "nominal", "sort": "ascending", ...
datasets/.dvc/plots/confusion.json/0
{ "file_path": "datasets/.dvc/plots/confusion.json", "repo_id": "datasets", "token_count": 450 }
# Create an audio dataset You can share a dataset with your team or with anyone in the community by creating a dataset repository on the Hugging Face Hub: ```py from datasets import load_dataset dataset = load_dataset("<username>/my_dataset") ``` There are several methods for creating and sharing an audio dataset: ...
datasets/docs/source/audio_dataset.mdx/0
{ "file_path": "datasets/docs/source/audio_dataset.mdx", "repo_id": "datasets", "token_count": 9772 }
# Structure your repository To host and share your dataset, create a dataset repository on the Hugging Face Hub and upload your data files. This guide will show you how to structure your dataset repository when you upload it. A dataset with a supported structure and file format (`.txt`, `.csv`, `.parquet`, `.jsonl`, ...
datasets/docs/source/repository_structure.mdx/0
{ "file_path": "datasets/docs/source/repository_structure.mdx", "repo_id": "datasets", "token_count": 2555 }
# Using Datasets with TensorFlow This document is a quick introduction to using `datasets` with TensorFlow, with a particular focus on how to get `tf.Tensor` objects out of our datasets, and how to stream data from Hugging Face `Dataset` objects to Keras methods like `model.fit()`. ## Dataset format By default, data...
datasets/docs/source/use_with_tensorflow.mdx/0
{ "file_path": "datasets/docs/source/use_with_tensorflow.mdx", "repo_id": "datasets", "token_count": 3825 }
from argparse import ArgumentParser from typing import Optional from datasets.commands import BaseDatasetsCLICommand from datasets.hub import delete_from_hub def _command_factory(args): return DeleteFromHubCommand( args.dataset_id, args.config_name, args.token, args.revision, ...
datasets/src/datasets/commands/delete_from_hub.py/0
{ "file_path": "datasets/src/datasets/commands/delete_from_hub.py", "repo_id": "datasets", "token_count": 562 }
from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class Translation: """`Feature` for translations with fixed languages per example. Here for compatibl...
datasets/src/datasets/features/translation.py/0
{ "file_path": "datasets/src/datasets/features/translation.py", "repo_id": "datasets", "token_count": 1677 }
from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class AbstractDatasetReader(ABC): def __init__( self, path_or_paths: ...
datasets/src/datasets/io/abc.py/0
{ "file_path": "datasets/src/datasets/io/abc.py", "repo_id": "datasets", "token_count": 721 }
from typing import List import datasets from ..folder_based_builder import folder_based_builder logger = datasets.utils.logging.get_logger(__name__) class AudioFolderConfig(folder_based_builder.FolderBasedBuilderConfig): """Builder Config for AudioFolder.""" drop_labels: bool = None drop_metadata: bo...
datasets/src/datasets/packaged_modules/audiofolder/audiofolder.py/0
{ "file_path": "datasets/src/datasets/packaged_modules/audiofolder/audiofolder.py", "repo_id": "datasets", "token_count": 588 }
import itertools from dataclasses import dataclass from typing import List, Optional, Union import pyarrow as pa import pyarrow.dataset as ds import pyarrow.parquet as pq import datasets from datasets.table import table_cast logger = datasets.utils.logging.get_logger(__name__) @dataclass class ParquetConfig(datas...
datasets/src/datasets/packaged_modules/parquet/parquet.py/0
{ "file_path": "datasets/src/datasets/packaged_modules/parquet/parquet.py", "repo_id": "datasets", "token_count": 2415 }
import importlib.util import os import tempfile from pathlib import PurePath from typing import TYPE_CHECKING, Dict, List, NamedTuple, Optional, Union import fsspec import numpy as np from .features import Sequence from .utils import logging from .utils import tqdm as hf_tqdm if TYPE_CHECKING: from .arrow_datas...
datasets/src/datasets/search.py/0
{ "file_path": "datasets/src/datasets/search.py", "repo_id": "datasets", "token_count": 15341 }
# 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": 1914 }
# 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 }
import pytest from datasets.builder import InvalidConfigName from datasets.data_files import DataFilesList from datasets.packaged_modules.parquet.parquet import ParquetConfig def test_config_raises_when_invalid_name() -> None: with pytest.raises(InvalidConfigName, match="Bad characters"): _ = ParquetConf...
datasets/tests/packaged_modules/test_parquet.py/0
{ "file_path": "datasets/tests/packaged_modules/test_parquet.py", "repo_id": "datasets", "token_count": 227 }
import os import zipfile import pytest from datasets.utils.extract import ( Bzip2Extractor, Extractor, GzipExtractor, Lz4Extractor, SevenZipExtractor, TarExtractor, XzExtractor, ZipExtractor, ZstdExtractor, ) from .utils import require_lz4, require_py7zr, require_zstandard @pyte...
datasets/tests/test_extract.py/0
{ "file_path": "datasets/tests/test_extract.py", "repo_id": "datasets", "token_count": 2984 }
import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap_unordered, map_nested, temp_...
datasets/tests/test_py_utils.py/0
{ "file_path": "datasets/tests/test_py_utils.py", "repo_id": "datasets", "token_count": 4313 }
# Files for typos # Instruction: https://github.com/marketplace/actions/typos-action#getting-started [default.extend-identifiers] [default.extend-words] NIN="NIN" # NIN is used in scripts/convert_ncsnpp_original_checkpoint_to_diffusers.py nd="np" # nd may be np (numpy) parms="parms" # parms is used in scripts/conver...
diffusers/_typos.toml/0
{ "file_path": "diffusers/_typos.toml", "repo_id": "diffusers", "token_count": 151 }
<!--Copyright 2024 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/internal_classes_overview.md/0
{ "file_path": "diffusers/docs/source/en/api/internal_classes_overview.md", "repo_id": "diffusers", "token_count": 211 }
<!--Copyright 2024 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/autoencoderkl.md/0
{ "file_path": "diffusers/docs/source/en/api/models/autoencoderkl.md", "repo_id": "diffusers", "token_count": 783 }
<!--Copyright 2024 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/auto_pipeline.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/auto_pipeline.md", "repo_id": "diffusers", "token_count": 378 }
<!--Copyright 2024 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/ddim.md/0
{ "file_path": "diffusers/docs/source/en/api/pipelines/ddim.md", "repo_id": "diffusers", "token_count": 477 }
<!--Copyright 2024 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/cosine_dpm.md/0
{ "file_path": "diffusers/docs/source/en/api/schedulers/cosine_dpm.md", "repo_id": "diffusers", "token_count": 357 }
<!--Copyright 2024 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": 291 }
<!--Copyright 2024 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/community_projects.md/0
{ "file_path": "diffusers/docs/source/en/community_projects.md", "repo_id": "diffusers", "token_count": 1417 }
<!--Copyright 2024 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/onnx.md/0
{ "file_path": "diffusers/docs/source/en/optimization/onnx.md", "repo_id": "diffusers", "token_count": 1206 }
<!--Copyright 2024 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/controlnet.md/0
{ "file_path": "diffusers/docs/source/en/training/controlnet.md", "repo_id": "diffusers", "token_count": 4995 }
<!--Copyright 2024 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/wuerstchen.md/0
{ "file_path": "diffusers/docs/source/en/training/wuerstchen.md", "repo_id": "diffusers", "token_count": 2906 }
<!--Copyright 2024 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/diffedit.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/diffedit.md", "repo_id": "diffusers", "token_count": 3847 }
<!--Copyright 2024 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/reusing_seeds.md/0
{ "file_path": "diffusers/docs/source/en/using-diffusers/reusing_seeds.md", "repo_id": "diffusers", "token_count": 3005 }
<!--Copyright 2024 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/installation.md/0
{ "file_path": "diffusers/docs/source/ja/installation.md", "repo_id": "diffusers", "token_count": 2493 }
<!--Copyright 2024 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/habana.md/0
{ "file_path": "diffusers/docs/source/ko/optimization/habana.md", "repo_id": "diffusers", "token_count": 1911 }
<!--Copyright 2024 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/lora.md/0
{ "file_path": "diffusers/docs/source/ko/training/lora.md", "repo_id": "diffusers", "token_count": 4756 }
<!--Copyright 2024 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/loading_adapters.md/0
{ "file_path": "diffusers/docs/source/ko/using-diffusers/loading_adapters.md", "repo_id": "diffusers", "token_count": 12272 }
- sections: - local: index title: 🧨 Diffusers - local: quicktour title: 快速入门 - local: stable_diffusion title: 有效和高效的扩散 - local: consisid title: 身份保持的文本到视频生成 - local: installation title: 安装 title: 开始
diffusers/docs/source/zh/_toctree.yml/0
{ "file_path": "diffusers/docs/source/zh/_toctree.yml", "repo_id": "diffusers", "token_count": 141 }
# coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
diffusers/examples/amused/train_amused.py/0
{ "file_path": "diffusers/examples/amused/train_amused.py", "repo_id": "diffusers", "token_count": 17513 }
from typing import Optional import torch from PIL import Image from tqdm.auto import tqdm from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, DiffusionPipeline, UNet2DConditionModel from diffusers.image_processor import VaeImageProcessor from diffusers.utils impor...
diffusers/examples/community/edict_pipeline.py/0
{ "file_path": "diffusers/examples/community/edict_pipeline.py", "repo_id": "diffusers", "token_count": 4682 }
import inspect import re from typing import Callable, List, Optional, Union import numpy as np import PIL.Image import torch from packaging import version from transformers import CLIPImageProcessor, CLIPTokenizer import diffusers from diffusers import OnnxRuntimeModel, OnnxStableDiffusionPipeline, SchedulerMixin fro...
diffusers/examples/community/lpw_stable_diffusion_onnx.py/0
{ "file_path": "diffusers/examples/community/lpw_stable_diffusion_onnx.py", "repo_id": "diffusers", "token_count": 24240 }
# Inspired by: https://github.com/haofanwang/ControlNet-for-Diffusers/ import inspect from typing import Any, Callable, Dict, List, Optional, Tuple, Union import numpy as np import PIL.Image import torch import torch.nn.functional as F from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from di...
diffusers/examples/community/stable_diffusion_controlnet_inpaint.py/0
{ "file_path": "diffusers/examples/community/stable_diffusion_controlnet_inpaint.py", "repo_id": "diffusers", "token_count": 23770 }
import inspect from typing import List, Optional, Tuple, Union import torch from torch.nn import functional as F from transformers import CLIPTextModelWithProjection, CLIPTokenizer from transformers.models.clip.modeling_clip import CLIPTextModelOutput from diffusers import ( DiffusionPipeline, ImagePipelineOu...
diffusers/examples/community/unclip_text_interpolation.py/0
{ "file_path": "diffusers/examples/community/unclip_text_interpolation.py", "repo_id": "diffusers", "token_count": 10699 }
# DreamBooth training example [DreamBooth](https://arxiv.org/abs/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.py` script shows how to implement the training procedure and adapt it for stable diffusion. ## Running local...
diffusers/examples/dreambooth/README.md/0
{ "file_path": "diffusers/examples/dreambooth/README.md", "repo_id": "diffusers", "token_count": 10149 }
# coding=utf-8 # Copyright 2024 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/dreambooth/test_dreambooth_lora_flux.py/0
{ "file_path": "diffusers/examples/dreambooth/test_dreambooth_lora_flux.py", "repo_id": "diffusers", "token_count": 4875 }
# Search models on Civitai and Hugging Face The [auto_diffusers](https://github.com/suzukimain/auto_diffusers) library provides additional functionalities to Diffusers such as searching for models on Civitai and the Hugging Face Hub. Please refer to the original library [here](https://pypi.org/project/auto-diffusers/)...
diffusers/examples/model_search/README.md/0
{ "file_path": "diffusers/examples/model_search/README.md", "repo_id": "diffusers", "token_count": 3696 }
#!/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": 26288 }
#!/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 }
## Textual Inversion fine-tuning example [Textual inversion](https://arxiv.org/abs/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 diffusion...
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": 1013 }
# Multi Subject DreamBooth training [DreamBooth](https://arxiv.org/abs/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 and ada...
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": 4800 }
## Textual Inversion fine-tuning example [Textual inversion](https://arxiv.org/abs/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 diffusion...
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": 1129 }
# 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 }
#!/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/scheduled_huber_loss_training/dreambooth/train_dreambooth_lora_sdxl.py/0
{ "file_path": "diffusers/examples/research_projects/scheduled_huber_loss_training/dreambooth/train_dreambooth_lora_sdxl.py", "repo_id": "diffusers", "token_count": 40446 }
import torch.nn as nn from torchvision.models import efficientnet_v2_l, efficientnet_v2_s from diffusers.configuration_utils import ConfigMixin, register_to_config from diffusers.models.modeling_utils import ModelMixin class EfficientNetEncoder(ModelMixin, ConfigMixin): @register_to_config def __init__(self,...
diffusers/examples/research_projects/wuerstchen/text_to_image/modeling_efficient_net_encoder.py/0
{ "file_path": "diffusers/examples/research_projects/wuerstchen/text_to_image/modeling_efficient_net_encoder.py", "repo_id": "diffusers", "token_count": 374 }
#!/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/textual_inversion/textual_inversion.py/0
{ "file_path": "diffusers/examples/textual_inversion/textual_inversion.py", "repo_id": "diffusers", "token_count": 17436 }
import inspect import os from argparse import ArgumentParser import numpy as np import torch from muse import MaskGiTUViT, VQGANModel from muse import PipelineMuse as OldPipelineMuse from transformers import CLIPTextModelWithProjection, CLIPTokenizer from diffusers import VQModel from diffusers.models.attention_proce...
diffusers/scripts/convert_amused.py/0
{ "file_path": "diffusers/scripts/convert_amused.py", "repo_id": "diffusers", "token_count": 12883 }
import argparse from pathlib import Path from typing import Any, Dict import torch from accelerate import init_empty_weights from safetensors.torch import load_file from transformers import T5EncoderModel, T5Tokenizer from diffusers import AutoencoderKLLTXVideo, FlowMatchEulerDiscreteScheduler, LTXPipeline, LTXVideoT...
diffusers/scripts/convert_ltx_to_diffusers.py/0
{ "file_path": "diffusers/scripts/convert_ltx_to_diffusers.py", "repo_id": "diffusers", "token_count": 4898 }
""" A script to convert Stable Diffusion 3.5 ControlNet checkpoints to the Diffusers format. Example: Convert a SD3.5 ControlNet checkpoint to Diffusers format using local file: ```bash python scripts/convert_sd3_controlnet_to_diffusers.py \ --checkpoint_path "path/to/local/sd3.5_large_controlnet_c...
diffusers/scripts/convert_sd3_controlnet_to_diffusers.py/0
{ "file_path": "diffusers/scripts/convert_sd3_controlnet_to_diffusers.py", "repo_id": "diffusers", "token_count": 3453 }
""" This script ports models from VQ-diffusion (https://github.com/microsoft/VQ-Diffusion) to diffusers. It currently only supports porting the ITHQ dataset. ITHQ dataset: ```sh # From the root directory of diffusers. # Download the VQVAE checkpoint $ wget https://facevcstandard.blob.core.windows.net/v-zhictang/Impr...
diffusers/scripts/convert_vq_diffusion_to_diffusers.py/0
{ "file_path": "diffusers/scripts/convert_vq_diffusion_to_diffusers.py", "repo_id": "diffusers", "token_count": 14916 }
# coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
diffusers/src/diffusers/loaders/single_file_utils.py/0
{ "file_path": "diffusers/src/diffusers/loaders/single_file_utils.py", "repo_id": "diffusers", "token_count": 56617 }
# Copyright 2024 MIT, Tsinghua University, NVIDIA CORPORATION 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/li...
diffusers/src/diffusers/models/autoencoders/autoencoder_dc.py/0
{ "file_path": "diffusers/src/diffusers/models/autoencoders/autoencoder_dc.py", "repo_id": "diffusers", "token_count": 13842 }
# Copyright 2024 Stability AI, 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-...
diffusers/src/diffusers/models/controlnet_sd3.py/0
{ "file_path": "diffusers/src/diffusers/models/controlnet_sd3.py", "repo_id": "diffusers", "token_count": 1263 }