id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
26,292
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- get: summary: Retrieve the text of a story chunk tags: - story description: |-2 Returns the text inside a story chunk given its `num`. parameters: - name: num in: path description: |-2 `num` of the desired story chunk. schema: type: integer responses: 200: description: Successful request content: application/json: ...
26,293
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- put: summary: Set the text of a story chunk tags: - story description: |-2 Sets the text inside a story chunk given its `num`. parameters: - name: num in: path description: |-2 `num` of the desired story chunk. schema: type: integer requestBody: required: true content: application/json: schema: StoryChunkSetTextSch...
26,294
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- delete: summary: Remove a story chunk tags: - story description: |-2 Removes a story chunk from the story in the KoboldAI GUI given its `num`. Cannot be used to delete the first action (the prompt). parameters: - name: num in: path description: |-2 `num` of the desired story chunk. Must be larger than or equal to 1...
26,295
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- delete: summary: Clear the story tags: - story description: |-2 Starts a new blank story. responses: 200: description: Successful request content: application/json: schema: EmptySchema {api_server_busy_response}
26,296
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- put: summary: Load a story tags: - story description: |-2 Loads a story given its filename (without the .json). requestBody: required: true content: application/json: schema: StoryLoadSchema example: name: string responses: 200: description: Successful request content: application/json: schema: EmptySchema {api_val...
26,297
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- put: summary: Save the current story tags: - story description: |-2 Saves the current story given its destination filename (without the .json). requestBody: required: true content: application/json: schema: StorySaveSchema example: name: string responses: 200: description: Successful request content: application/js...
26,298
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- get: summary: Retrieve all world info entries tags: - world_info description: |-2 Returns all world info entries currently shown in the KoboldAI GUI. The `folders` are sorted in the same order as they are in the GUI and the `entries` within the folders and within the parent `result` object are all sorted in the sam...
26,299
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- get: summary: Retrieve the UIDs of all world info entries tags: - world_info description: |-2 Returns in a similar format as GET /world_info except only the `uid`s are returned. responses: 200: description: Successful request content: application/json: schema: WorldInfoUIDsSchema
26,300
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- get: summary: Determine whether or not there is a world info entry with the given UID tags: - world_info parameters: - name: uid in: path description: |-2 `uid` of the desired world info entry. schema: type: integer minimum: -2147483648 maximum: 2147483647 responses: 200: description: Successful request content: ap...
26,301
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- get: summary: Retrieve all world info folders tags: - world_info description: |-2 Returns details about all world info folders currently shown in the KoboldAI GUI. The `folders` are sorted in the same order as they are in the GUI. responses: 200: description: Successful request content: application/json: schema: Wo...
26,302
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- get: summary: Retrieve the UIDs all world info folders tags: - world_info description: |-2 Returns the `uid`s of all world info folders currently shown in the KoboldAI GUI. The `folders` are sorted in the same order as they are in the GUI. responses: 200: description: Successful request content: application/json: s...
26,303
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- get: summary: Retrieve all world info entries not in a folder tags: - world_info description: |-2 Returns all world info entries that are not in a world info folder. The `entries` are sorted in the same order as they are in the KoboldAI GUI. responses: 200: description: Successful request content: application/json:...
26,304
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- get: summary: Retrieve the UIDs of all world info entries not in a folder tags: - world_info description: |-2 Returns the `uid`s of all world info entries that are not in a world info folder. The `entries` are sorted in the same order as they are in the KoboldAI GUI. responses: 200: description: Successful request ...
26,305
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- get: summary: Determine whether or not there is a world info entry with the given UID that is not in a world info folder tags: - world_info parameters: - name: uid in: path description: |-2 `uid` of the desired world info entry. schema: type: integer minimum: -2147483648 maximum: 2147483647 responses: 200: descript...
26,306
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- get: summary: Retrieve all world info entries in the given folder tags: - world_info parameters: - name: uid in: path description: |-2 `uid` of the desired world info folder. schema: type: integer minimum: -2147483648 maximum: 2147483647 description: |-2 Returns all world info entries that are in the world info fol...
26,307
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- get: summary: Retrieve the UIDs of all world info entries in the given folder tags: - world_info parameters: - name: uid in: path description: |-2 `uid` of the desired world info folder. schema: type: integer minimum: -2147483648 maximum: 2147483647 description: |-2 Returns the `uid`s of all world info entries that...
26,308
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- get: summary: Determine whether or not there is a world info entry with the given UID in the world info folder with the given UID tags: - world_info parameters: - name: folder_uid in: path description: |-2 `uid` of the desired world info folder. schema: type: integer minimum: -2147483648 maximum: 2147483647 - name:...
26,309
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- get: summary: Retrieve the name of the world info folder with the given UID tags: - world_info parameters: - name: uid in: path description: |-2 `uid` of the desired world info folder. schema: type: integer minimum: -2147483648 maximum: 2147483647 responses: 200: description: Successful request content: application...
26,310
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- put: summary: Set the name of the world info folder with the given UID to the specified value tags: - world_info parameters: - name: uid in: path description: |-2 `uid` of the desired world info folder. schema: type: integer minimum: -2147483648 maximum: 2147483647 requestBody: required: true content: application/j...
26,311
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- get: summary: Retrieve information about the world info entry with the given UID tags: - world_info parameters: - name: uid in: path description: |-2 `uid` of the desired world info entry. schema: type: integer minimum: -2147483648 maximum: 2147483647 responses: 200: description: Successful request content: applica...
26,312
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- get: summary: Retrieve the comment of the world info entry with the given UID tags: - world_info parameters: - name: uid in: path description: |-2 `uid` of the desired world info entry. schema: type: integer minimum: -2147483648 maximum: 2147483647 responses: 200: description: Successful request content: applicatio...
26,313
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- put: summary: Set the comment of the world info entry with the given UID to the specified value tags: - world_info parameters: - name: uid in: path description: |-2 `uid` of the desired world info entry. schema: type: integer minimum: -2147483648 maximum: 2147483647 requestBody: required: true content: application/...
26,314
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- get: summary: Retrieve the content of the world info entry with the given UID tags: - world_info parameters: - name: uid in: path description: |-2 `uid` of the desired world info entry. schema: type: integer minimum: -2147483648 maximum: 2147483647 responses: 200: description: Successful request content: applicatio...
26,315
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- put: summary: Set the content of the world info entry with the given UID to the specified value tags: - world_info parameters: - name: uid in: path description: |-2 `uid` of the desired world info entry. schema: type: integer minimum: -2147483648 maximum: 2147483647 requestBody: required: true content: application/...
26,316
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- get: summary: Retrieve the keys or primary keys of the world info entry with the given UID tags: - world_info parameters: - name: uid in: path description: |-2 `uid` of the desired world info entry. schema: type: integer minimum: -2147483648 maximum: 2147483647 responses: 200: description: Successful request conten...
26,317
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- put: summary: Set the keys or primary keys of the world info entry with the given UID to the specified value tags: - world_info parameters: - name: uid in: path description: |-2 `uid` of the desired world info entry. schema: type: integer minimum: -2147483648 maximum: 2147483647 requestBody: required: true content:...
26,318
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- get: summary: Retrieve the secondary keys of the world info entry with the given UID tags: - world_info parameters: - name: uid in: path description: |-2 `uid` of the desired world info entry. schema: type: integer minimum: -2147483648 maximum: 2147483647 responses: 200: description: Successful request content: app...
26,319
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- put: summary: Set the secondary keys of the world info entry with the given UID to the specified value tags: - world_info parameters: - name: uid in: path description: |-2 `uid` of the desired world info entry. schema: type: integer minimum: -2147483648 maximum: 2147483647 requestBody: required: true content: appli...
26,320
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- get: summary: Retrieve the selective mode state of the world info entry with the given UID tags: - world_info parameters: - name: uid in: path description: |-2 `uid` of the desired world info entry. schema: type: integer minimum: -2147483648 maximum: 2147483647 responses: 200: description: Successful request conten...
26,321
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- put: summary: Set the selective mode state of the world info entry with the given UID to the specified value tags: - world_info parameters: - name: uid in: path description: |-2 `uid` of the desired world info entry. schema: type: integer minimum: -2147483648 maximum: 2147483647 requestBody: required: true content:...
26,322
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- get: summary: Retrieve the constant mode state of the world info entry with the given UID tags: - world_info parameters: - name: uid in: path description: |-2 `uid` of the desired world info entry. schema: type: integer minimum: -2147483648 maximum: 2147483647 responses: 200: description: Successful request content...
26,323
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- put: summary: Set the constant mode state of the world info entry with the given UID to the specified value tags: - world_info parameters: - name: uid in: path description: |-2 `uid` of the desired world info entry. schema: type: integer minimum: -2147483648 maximum: 2147483647 requestBody: required: true content: ...
26,324
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- post: summary: Create a new world info entry outside of a world info folder, at the end of the world info tags: - world_info requestBody: required: true content: application/json: schema: EmptySchema responses: 200: description: Successful request content: application/json: schema: BasicUIDSchema {api_validation_er...
26,325
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- post: summary: Create a new world info entry at the end of the world info folder with the given UID tags: - world_info parameters: - name: uid in: path description: |-2 `uid` of the desired world info folder. schema: type: integer minimum: -2147483648 maximum: 2147483647 requestBody: required: true content: applica...
26,326
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- delete: summary: Delete the world info entry with the given UID tags: - world_info parameters: - name: uid in: path description: |-2 `uid` of the desired world info entry. schema: type: integer minimum: -2147483648 maximum: 2147483647 responses: 200: description: Successful request content: application/json: schema...
26,327
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- post: summary: Create a new world info folder at the end of the world info tags: - world_info requestBody: required: true content: application/json: schema: EmptySchema responses: 200: description: Successful request content: application/json: schema: BasicUIDSchema {api_validation_error_response}
26,328
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- delete: summary: Delete the world info folder with the given UID tags: - world_info parameters: - name: uid in: path description: |-2 `uid` of the desired world info folder. schema: type: integer minimum: -2147483648 maximum: 2147483647 responses: 200: description: Successful request content: application/json: sche...
26,329
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
null
26,330
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- get: summary: Retrieve the current soft prompt name tags: - config responses: 200: description: Successful request content: application/json: schema: SoftPromptSettingSchema example: value: ""
26,331
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- get: summary: Retrieve all available softprompt filenames tags: - config responses: 200: description: Successful request content: application/json: schema: SoftPromptsListSchema example: values: []
26,332
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- put: summary: Set soft prompt by name tags: - config requestBody: required: true content: application/json: schema: SoftPromptSettingSchema example: value: "" responses: 200: description: Successful request content: application/json: schema: EmptySchema {api_validation_error_response}
26,333
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- get: summary: Retrieve the current global sampler seed value tags: - config responses: 200: description: Successful request content: application/json: schema: SamplerSeedSettingSchema example: value: 3475097509890965500
26,334
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
--- put: summary: Set the global sampler seed value tags: - config requestBody: required: true content: application/json: schema: SamplerSeedSettingSchema example: value: 3475097509890965500 responses: 200: description: Successful request content: application/json: schema: EmptySchema {api_validation_error_response}
26,335
import eventlet import os from eventlet import tpool import logging from logger import logger, set_logger_verbosity, quiesce_logger from os import path, getcwd import time import re import json import collections import zipfile import packaging import packaging.version import contextlib import traceback import threadin...
null
26,336
import sys from functools import partialmethod from loguru import logger STDOUT_LEVELS = ["GENERATION", "PROMPT"] verbosity = 20 quiet = 0 def is_stdout_log(record): if record["level"].name not in STDOUT_LEVELS: return(False) if record["level"].no < verbosity + quiet: return(False) return(T...
null
26,337
import sys from functools import partialmethod from loguru import logger INIT_LEVELS = ["INIT", "INIT_OK", "INIT_WARN", "INIT_ERR"] verbosity = 20 quiet = 0 def is_init_log(record): if record["level"].name not in INIT_LEVELS: return(False) if record["level"].no < verbosity + quiet: return(False...
null
26,338
import sys from functools import partialmethod from loguru import logger MESSAGE_LEVELS = ["MESSAGE"] verbosity = 20 quiet = 0 def is_msg_log(record): if record["level"].name not in MESSAGE_LEVELS: return(False) if record["level"].no < verbosity + quiet: return(False) return(True)
null
26,339
import sys from functools import partialmethod from loguru import logger STDOUT_LEVELS = ["GENERATION", "PROMPT"] INIT_LEVELS = ["INIT", "INIT_OK", "INIT_WARN", "INIT_ERR"] MESSAGE_LEVELS = ["MESSAGE"] verbosity = 20 quiet = 0 def is_stderr_log(record): if record["level"].name in STDOUT_LEVELS + INIT_LEVELS + MESS...
null
26,340
import sys from functools import partialmethod from loguru import logger logger.level("GENERATION", no=24, color="<cyan>") logger.level("PROMPT", no=23, color="<yellow>") logger.level("INIT", no=31, color="<white>") logger.level("INIT_OK", no=31, color="<green>") logger.level("INIT_WARN", no=31, color="<yellow>") logge...
null
26,341
import math import torch import torch.nn as nn import torch.nn.functional as F from einops import rearrange, repeat from lycoris.utils import default from lycoris.utils.xformers_utils import XFORMERS_AVAIL, memory_efficient_attention def vanilla_attention(q, k, v, mask, scale=None): if scale is None: scale...
null
26,342
from functools import cache from math import log2, ceil import torch import torch.nn as nn import torch.nn.functional as F from einops import rearrange from .base import ModuleCustomSD from lycoris.logging import logger def log_butterfly_factorize(dim, factor, result): logger.info( f"Use BOFT({int(log2(resu...
m = 2k n = 2**p m*n = dim
26,343
from typing import * import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from torchvision.transforms.functional import resize from timm import create_model from einops import rearrange from lycoris.modules.attention import TransformerBlock The provided code snippet includes necessary ...
Sinusoid position encoding table
26,344
import torch import torch.nn as nn from torch.utils.checkpoint import checkpoint from transformers import T5Tokenizer, T5EncoderModel, CLIPTokenizer, CLIPTextModel import open_clip The provided code snippet includes necessary dependencies for implementing the `disabled_train` function. Write a Python function `def dis...
Overwrite model.train with this function to make sure train/eval mode does not change anymore.
26,345
import math import torch import torch.nn as nn import torch.nn.functional as F from .base import ModuleCustomSD The provided code snippet includes necessary dependencies for implementing the `factorization` function. Write a Python function `def factorization(dimension: int, factor: int = -1) -> tuple[int, int]` to so...
return a tuple of two value of input dimension decomposed by the number closest to factor second value is higher or equal than first value. In LoRA with Kroneckor Product, first value is a value for weight scale. secon value is a value for weight. Becuase of non-commutative property, A⊗B ≠ B⊗A. Meaning of two matrices ...
26,346
import math import torch import torch.nn as nn import torch.nn.functional as F from .base import ModuleCustomSD def make_weight_cp(t, wa, wb): rebuild2 = torch.einsum("i j k l, i p, j r -> p r k l", t, wa, wb) # [c, d, k1, k2] return rebuild2
null
26,347
import math import torch import torch.nn as nn import torch.nn.functional as F from .base import ModuleCustomSD def make_kron(w1, w2, scale): if len(w2.shape) == 4: w1 = w1.unsqueeze(2).unsqueeze(2) w2 = w2.contiguous() rebuild = torch.kron(w1, w2) return rebuild * scale
null
26,348
import torch import torch.nn as nn import torch.nn.functional as F from .base import ModuleCustomSD class HadaWeight(torch.autograd.Function): def forward(ctx, w1a, w1b, w2a, w2b, scale=torch.tensor(1)): def backward(ctx, grad_out): def make_weight(w1a, w1b, w2a, w2b, scale): return HadaWeight.apply(w1a,...
null
26,349
import torch import torch.nn as nn import torch.nn.functional as F from .base import ModuleCustomSD class HadaWeightCP(torch.autograd.Function): def forward(ctx, t1, w1a, w1b, t2, w2a, w2b, scale=torch.tensor(1)): ctx.save_for_backward(t1, w1a, w1b, t2, w2a, w2b, scale) rebuild1 = torch.einsum("i j ...
null
26,350
from functools import cache import torch import torch.nn as nn import torch.nn.functional as F from einops import rearrange from .base import ModuleCustomSD from .lokr import factorization from ..logging import logger logger = logging.getLogger("LyCORIS") logger.propagate = False logger.setLevel(logging.INFO) if not...
null
26,351
import torch import torch.nn as nn import torch.nn.functional as F from .base import ModuleCustomSD The provided code snippet includes necessary dependencies for implementing the `factorization` function. Write a Python function `def factorization(dimension: int, factor: int = -1) -> tuple[int, int]` to solve the foll...
return a tuple of two value of input dimension decomposed by the number closest to factor second value is higher or equal than first value. In LoRA with Kroneckor Product, first value is a value for weight scale. secon value is a value for weight. Becuase of non-commutative property, A⊗B ≠ B⊗A. Meaning of two matrices ...
26,352
import torch import torch.nn as nn import torch.nn.functional as F from .base import ModuleCustomSD def make_weight_cp(t, wa, wb): rebuild2 = torch.einsum("i j k l, i p, j r -> p r k l", t, wa, wb) # [c, d, k1, k2] return rebuild2
null
26,353
import torch import torch.nn as nn import torch.nn.functional as F from .base import ModuleCustomSD def make_kron(w1, w2, scale): if len(w2.shape) == 4: w1 = w1.unsqueeze(2).unsqueeze(2) w2 = w2.contiguous() rebuild = torch.kron(w1, w2) return rebuild * scale
null
26,354
import math import os import regex as re import sys from typing import List import torch from .utils import * from .modules.locon import LoConModule from .modules.loha import LohaModule from .modules.lokr import LokrModule from .modules.dylora import DyLoraModule from .modules.glora import GLoRAModule from .modules.nor...
null
26,355
import math import os import regex as re import sys from typing import List import torch from .utils import * from .modules.locon import LoConModule from .modules.loha import LohaModule from .modules.lokr import LokrModule from .modules.dylora import DyLoraModule from .modules.glora import GLoRAModule from .modules.nor...
null
26,356
import torch from safetensors.torch import load_file, save_file from transformers import ( CLIPTextModel, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, ) from diffusers import AutoencoderKL, EulerDiscreteScheduler, UNet2DConditionModel from . import model_utils as model_util from . import ...
null
26,357
import torch from safetensors.torch import load_file, save_file from transformers import ( CLIPTextModel, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, ) from diffusers import AutoencoderKL, EulerDiscreteScheduler, UNet2DConditionModel from . import model_utils as model_util from . import ...
null
26,358
import torch from safetensors.torch import load_file, save_file from transformers import ( CLIPTextModel, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, ) from diffusers import AutoencoderKL, EulerDiscreteScheduler, UNet2DConditionModel from . import model_utils as model_util from . import ...
null
26,359
import torch from safetensors.torch import load_file, save_file from transformers import ( CLIPTextModel, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, ) from diffusers import AutoencoderKL, EulerDiscreteScheduler, UNet2DConditionModel from . import model_utils as model_util from . import ...
null
26,360
import hashlib import safetensors from io import BytesIO def addnet_hash_legacy(b): """Old model hash used by sd-webui-additional-networks for .safetensors format files""" m = hashlib.sha256() b.seek(0x100000) m.update(b.read(0x10000)) return m.hexdigest()[0:8] def addnet_hash_safetensors(b): ""...
Precalculate the model hashes needed by sd-webui-additional-networks to save time on indexing the model later.
26,361
import math from types import SimpleNamespace from typing import Optional import torch import torch.utils.checkpoint from torch import nn from torch.nn import functional as F from einops import rearrange def exists(val): return val is not None def default(val, d): return val if exists(val) else d
null
26,362
import math from types import SimpleNamespace from typing import Optional import torch import torch.utils.checkpoint from torch import nn from torch.nn import functional as F from einops import rearrange def get_parameter_dtype(parameter: torch.nn.Module): return next(parameter.parameters()).dtype
null
26,363
import math from types import SimpleNamespace from typing import Optional import torch import torch.utils.checkpoint from torch import nn from torch.nn import functional as F from einops import rearrange def get_parameter_device(parameter: torch.nn.Module): return next(parameter.parameters()).device
null
26,364
import math from types import SimpleNamespace from typing import Optional import torch import torch.utils.checkpoint from torch import nn from torch.nn import functional as F from einops import rearrange The provided code snippet includes necessary dependencies for implementing the `get_timestep_embedding` function. W...
This matches the implementation in Denoising Diffusion Probabilistic Models: Create sinusoidal timestep embeddings. :param timesteps: a 1-D Tensor of N indices, one per batch element. These may be fractional. :param embedding_dim: the dimension of the output. :param max_period: controls the minimum frequency of the emb...
26,365
import math import os import torch import diffusers from transformers import CLIPTextModel, CLIPTokenizer, CLIPTextConfig, logging from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionPipeline, ) from safetensors.torch import load_file, save_file from .original_unet import UNet2DConditionMo...
null
26,366
import math import os import torch import diffusers from transformers import CLIPTextModel, CLIPTokenizer, CLIPTextConfig, logging from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionPipeline, ) from safetensors.torch import load_file, save_file from .original_unet import UNet2DConditionMo...
null
26,367
import math import os import torch import diffusers from transformers import CLIPTextModel, CLIPTokenizer, CLIPTextConfig, logging from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionPipeline, ) from safetensors.torch import load_file, save_file from .original_unet import UNet2DConditionMo...
null
26,368
import math import os import torch import diffusers from transformers import CLIPTextModel, CLIPTokenizer, CLIPTextConfig, logging from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionPipeline, ) from safetensors.torch import load_file, save_file from .original_unet import UNet2DConditionMo...
null
26,369
import math import os import torch import diffusers from transformers import CLIPTextModel, CLIPTokenizer, CLIPTextConfig, logging from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionPipeline, ) from safetensors.torch import load_file, save_file from .original_unet import UNet2DConditionMo...
null
26,370
import math import os import torch import diffusers from transformers import CLIPTextModel, CLIPTokenizer, CLIPTextConfig, logging from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionPipeline, ) from safetensors.torch import load_file, save_file from .original_unet import UNet2DConditionMo...
null
26,371
import math import os import torch import diffusers from transformers import CLIPTextModel, CLIPTokenizer, CLIPTextConfig, logging from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionPipeline, ) from safetensors.torch import load_file, save_file from .original_unet import UNet2DConditionMo...
null
26,372
import math import os import torch import diffusers from transformers import CLIPTextModel, CLIPTokenizer, CLIPTextConfig, logging from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionPipeline, ) from safetensors.torch import load_file, save_file from .original_unet import UNet2DConditionMo...
null
26,373
import math from types import SimpleNamespace from typing import Dict, Optional, Tuple, Union import torch from torch import nn from torch.nn import functional as F from einops import rearrange def exists(val): return val is not None def default(val, d): return val if exists(val) else d
null
26,374
import math from types import SimpleNamespace from typing import Dict, Optional, Tuple, Union import torch from torch import nn from torch.nn import functional as F from einops import rearrange def get_parameter_dtype(parameter: torch.nn.Module): return next(parameter.parameters()).dtype
null
26,375
import math from types import SimpleNamespace from typing import Dict, Optional, Tuple, Union import torch from torch import nn from torch.nn import functional as F from einops import rearrange def get_parameter_device(parameter: torch.nn.Module): return next(parameter.parameters()).device
null
26,376
import math from types import SimpleNamespace from typing import Dict, Optional, Tuple, Union import torch from torch import nn from torch.nn import functional as F from einops import rearrange The provided code snippet includes necessary dependencies for implementing the `get_timestep_embedding` function. Write a Pyt...
This matches the implementation in Denoising Diffusion Probabilistic Models: Create sinusoidal timestep embeddings. :param timesteps: a 1-D Tensor of N indices, one per batch element. These may be fractional. :param embedding_dim: the dimension of the output. :param max_period: controls the minimum frequency of the emb...
26,377
import math from types import SimpleNamespace from typing import Dict, Optional, Tuple, Union import torch from torch import nn from torch.nn import functional as F from einops import rearrange class DownBlock2D(nn.Module): def __init__( self, in_channels: int, out_channels: int, add...
null
26,378
import math from types import SimpleNamespace from typing import Dict, Optional, Tuple, Union import torch from torch import nn from torch.nn import functional as F from einops import rearrange class UpBlock2D(nn.Module): def __init__( self, in_channels: int, prev_output_channel: int, ...
null
26,379
from math import log2, floor import torch from einops import rearrange def pow_of_2(value): while value > 1: if value & 1: return False value = value >> 1 return True
null
26,380
def linear_layer_mac(seq_len, in_dim, out_dim): return seq_len * in_dim * out_dim def mac_for_lin_bax(seq_len, in_dim, out_dim, rank): return linear_layer_mac(seq_len, in_dim, rank) + linear_layer_mac( seq_len, rank, out_dim )
null
26,381
def conv_layer_mac(in_h, in_w, in_dim, out_dim, kernel_size, stride, padding): conv_ops = (in_h + padding * 2) * (in_w + padding * 2) // stride filter_mac = kernel_size**2 * in_dim * out_dim return 2 * conv_ops * filter_mac def mac_for_conv_bax(in_h, in_w, in_dim, out_dim, rank): return conv_layer_mac(...
null
26,382
def mac_matmul(n, p, m): return n * p * m def mac_for_lin_wba(in_dim, out_dim, rank): return mac_matmul(in_dim, rank, out_dim)
null
26,383
def mac_matmul(n, p, m): return n * p * m def mac_for_conv_wba(in_dim, out_dim, rank): return mac_matmul(in_dim, rank, out_dim * 3**2)
null
26,384
import torch import torch.nn as nn import torch.nn.functional as F class HadaWeightCP(torch.autograd.Function): def forward(ctx, orig_weight, t1, w1a, w1b, t2, w2a, w2b, scale=torch.tensor(1)): ctx.save_for_backward(t1, w1a, w1b, t2, w2a, w2b, scale) temp = torch.einsum("i j k l, j r -> i r k l", t1...
null
26,385
import torch import torch.nn as nn import torch.nn.functional as F torch.mean(w1).backward() torch.mean(w2).backward() def make_cp(orig_weight, t1, w1a, w1b, t2, w2a, w2b, scale=torch.tensor(0.25)): temp = torch.einsum("i j k l, j r -> i r k l", t1, w1b) rebuild1 = torch.einsum("i j k l, i r -> r j k l", temp,...
null
26,386
import os, sys import torch import torch.nn as nn import torch.nn.functional as F from lycoris.utils import extract_conv from pytorch_lightning import seed_everything def make_sparse(t, sparsity=0.95): sparse_t = t.masked_fill(torch.abs(t) < torch.quantile(torch.abs(t), sparsity), 0) return sparse_t
null
26,387
import os, sys import torch import torch.nn as nn import torch.nn.functional as F from lycoris.utils import extract_conv from pytorch_lightning import seed_everything print(extract_a.shape, extract_b.shape, extract_c.shape) print() print("without sparse bias") print("MSE Loss: ", F.mse_loss(conv_orig.weight, conv_rebd....
null
26,388
from functools import cache from math import log2 def log_butterfly_factorize(dim, factor, result): print( f"Use BOFT({int(log2(result[1]))}, {result[0]//2}) (equivalent to factor={result[0]}) for {dim=} and {factor=}" ) The provided code snippet includes necessary dependencies for implementing the `bu...
m = 2k n = 2**p m*n = dim
26,389
import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from einops import rearrange def lokr_linear(h, a, b, c): vq = a.size(1) uq = c.size(1) h_in_group = rearrange(h, "b ... (uq vq) -> b ... uq vq", uq=uq, vq=vq) ha = F.linear(h_in_group, a) hb = F.linear(...
null
26,390
import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from einops import rearrange def lokr_rebuild(h, a, b, c): rebuild_weight = torch.kron(c, b @ a) return F.linear(h, rebuild_weight)
null
26,391
import importlib import argparse import gc import math import os import sys import random import time import json from multiprocessing import Value from tqdm import tqdm import torch from accelerate.utils import set_seed from diffusers import DDPMScheduler from library import model_util import library.train_util as tra...
null