index int64 0 50.7k | project_path stringclasses 279
values | completion_path stringlengths 57 199 | signature_postion stringlengths 3 11 | class_position stringlengths 3 11 | function_name stringlengths 1 62 | class_name stringlengths 0 55 | body_position stringlengths 3 11 | body_position_with_comments stringlengths 3 11 | masked_class stringlengths 14 8.32k | masked_class_with_comment stringlengths 14 8.32k | func_body stringlengths 9 6.72k | func_body_with_comment stringlengths 9 6.72k | len_func_body int64 1 643 | len_input int64 10 2.02k | len_output int64 4 1.9k | total int64 20 2.05k | file_code stringlengths 14 442k | file_code_with_comment stringlengths 14 442k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
240 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/paths.py | 8,9 | 1,65 | mute_sdxl_imports | 10,24 | 9,24 | import os
import sys
from modules.paths_internal import models_path, script_path, data_path, extensions_dir, extensions_builtin_dir, cwd # noqa: F401
import modules.safe # noqa: F401
def mute_sdxl_imports():
FILL_FUNC_BODYsys.path.insert(0, script_path)
# search for directory of stable diffusion in following plac... | import os
import sys
from modules.paths_internal import models_path, script_path, data_path, extensions_dir, extensions_builtin_dir, cwd # noqa: F401
import modules.safe # noqa: F401
def mute_sdxl_imports():
"""create fake modules that SDXL wants to import but doesn't actually use for our purposes"""
FILL_FUNC... |
class Dummy:
pass
module = Dummy()
module.LPIPS = None
sys.modules['taming.modules.losses.lpips'] = module
module = Dummy()
module.StableDataModuleFromConfig = None
sys.modules['sgm.data'] = module
# data_path = cmd_opts_pre.data
| """create fake modules that SDXL wants to import but doesn't actually use for our purposes"""
class Dummy:
pass
module = Dummy()
module.LPIPS = None
sys.modules['taming.modules.losses.lpips'] = module
module = Dummy()
module.StableDataModuleFromConfig = None
sys.modules['sgm.d... | 25 | 731 | 107 | 838 | import os
import sys
from modules.paths_internal import models_path, script_path, data_path, extensions_dir, extensions_builtin_dir, cwd # noqa: F401
import modules.safe # noqa: F401
def mute_sdxl_imports():
FILL_FUNC_BODYsys.path.insert(0, script_path)
# search for directory of stable diffusion in following plac... | import os
import sys
from modules.paths_internal import models_path, script_path, data_path, extensions_dir, extensions_builtin_dir, cwd # noqa: F401
import modules.safe # noqa: F401
def mute_sdxl_imports():
"""create fake modules that SDXL wants to import but doesn't actually use for our purposes"""
FILL_FUNC... | |
242 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/processing.py | 575,576 | 520,620 | js | Processed | 576,613 | 576,613 | class Processed:
def __init__(self, p: StableDiffusionProcessing, images_list, seed=-1, info="", subseed=None, all_prompts=None, all_negative_prompts=None, all_seeds=None, all_subseeds=None, index_of_first_image=0, infotexts=None, comments=""):
self.images = images_list
self.prompt = p.prompt
... | class Processed:
def __init__(self, p: StableDiffusionProcessing, images_list, seed=-1, info="", subseed=None, all_prompts=None, all_negative_prompts=None, all_seeds=None, all_subseeds=None, index_of_first_image=0, infotexts=None, comments=""):
self.images = images_list
self.prompt = p.prompt
... | obj = {
"prompt": self.all_prompts[0],
"all_prompts": self.all_prompts,
"negative_prompt": self.all_negative_prompts[0],
"all_negative_prompts": self.all_negative_prompts,
"seed": self.seed,
"all_seeds": self.all_seeds,
"subseed... | obj = {
"prompt": self.all_prompts[0],
"all_prompts": self.all_prompts,
"negative_prompt": self.all_negative_prompts[0],
"all_negative_prompts": self.all_negative_prompts,
"seed": self.seed,
"all_seeds": self.all_seeds,
"subseed... | 73 | 1,206 | 570 | 1,776 | from __future__ import annotations
import json
import logging
import math
import os
import sys
import hashlib
from dataclasses import dataclass, field
import torch
import numpy as np
from PIL import Image, ImageOps
import random
import cv2
from skimage import exposure
from typing import Any
import modules.sd_hijack
f... | from __future__ import annotations
import json
import logging
import math
import os
import sys
import hashlib
from dataclasses import dataclass, field
import torch
import numpy as np
from PIL import Image, ImageOps
import random
import cv2
from skimage import exposure
from typing import Any
import modules.sd_hijack
f... |
246 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/processing_scripts/comments.py | 37,38 | 1,50 | before_token_counter | 38,44 | 38,44 | from modules import scripts, shared, script_callbacks
import re
def strip_comments(text):
text = re.sub('(^|\n)#[^\n]*(\n|$)', '\n', text) # while line comment
text = re.sub('#[^\n]*(\n|$)', '\n', text) # in the middle of the line comment
return text
class ScriptStripComments(scripts.Script):
def... | from modules import scripts, shared, script_callbacks
import re
def strip_comments(text):
text = re.sub('(^|\n)#[^\n]*(\n|$)', '\n', text) # while line comment
text = re.sub('#[^\n]*(\n|$)', '\n', text) # in the middle of the line comment
return text
class ScriptStripComments(scripts.Script):
def... | if not shared.opts.enable_prompt_comments:
return
params.prompt = strip_comments(params.prompt)
| if not shared.opts.enable_prompt_comments:
return
params.prompt = strip_comments(params.prompt)
| 7 | 546 | 43 | 589 | from modules import scripts, shared, script_callbacks
import re
def strip_comments(text):
text = re.sub('(^|\n)#[^\n]*(\n|$)', '\n', text) # while line comment
text = re.sub('#[^\n]*(\n|$)', '\n', text) # in the middle of the line comment
return text
class ScriptStripComments(scripts.Script):
def... | from modules import scripts, shared, script_callbacks
import re
def strip_comments(text):
text = re.sub('(^|\n)#[^\n]*(\n|$)', '\n', text) # while line comment
text = re.sub('#[^\n]*(\n|$)', '\n', text) # in the middle of the line comment
return text
class ScriptStripComments(scripts.Script):
def... | |
247 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/processing_scripts/comments.py | 19,20 | 12,37 | process | ScriptStripComments | 20,37 | 20,37 | class ScriptStripComments(scripts.Script):
def title(self):
return "Comments"
def show(self, is_img2img):
return scripts.AlwaysVisible
def process(self, p, *args):
FILL_FUNC_BODY | class ScriptStripComments(scripts.Script):
def title(self):
return "Comments"
def show(self, is_img2img):
return scripts.AlwaysVisible
def process(self, p, *args):
FILL_FUNC_BODY | if not shared.opts.enable_prompt_comments:
return
p.all_prompts = [strip_comments(x) for x in p.all_prompts]
p.all_negative_prompts = [strip_comments(x) for x in p.all_negative_prompts]
p.main_prompt = strip_comments(p.main_prompt)
p.main_negative_prompt = strip_com... | if not shared.opts.enable_prompt_comments:
return
p.all_prompts = [strip_comments(x) for x in p.all_prompts]
p.all_negative_prompts = [strip_comments(x) for x in p.all_negative_prompts]
p.main_prompt = strip_comments(p.main_prompt)
p.main_negative_prompt = strip_com... | 48 | 71 | 272 | 343 | from modules import scripts, shared, script_callbacks
import re
def strip_comments(text):
text = re.sub('(^|\n)#[^\n]*(\n|$)', '\n', text) # while line comment
text = re.sub('#[^\n]*(\n|$)', '\n', text) # in the middle of the line comment
return text
class ScriptStripComments(scripts.Script):
def... | from modules import scripts, shared, script_callbacks
import re
def strip_comments(text):
text = re.sub('(^|\n)#[^\n]*(\n|$)', '\n', text) # while line comment
text = re.sub('#[^\n]*(\n|$)', '\n', text) # in the middle of the line comment
return text
class ScriptStripComments(scripts.Script):
def... |
248 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/processing_scripts/refiner.py | 22,23 | 9,51 | ui | ScriptRefiner | 23,42 | 23,42 | class ScriptRefiner(scripts.ScriptBuiltinUI):
section = "accordions"
create_group = False
def __init__(self):
pass
def title(self):
return "Refiner"
def show(self, is_img2img):
return scripts.AlwaysVisible
def ui(self, is_img2img):
FILL_FUNC_BODY def setup(self, p,... | class ScriptRefiner(scripts.ScriptBuiltinUI):
section = "accordions"
create_group = False
def __init__(self):
pass
def title(self):
return "Refiner"
def show(self, is_img2img):
return scripts.AlwaysVisible
def ui(self, is_img2img):
FILL_FUNC_BODY def setup(self, p,... | with InputAccordion(False, label="Refiner", elem_id=self.elem_id("enable")) as enable_refiner:
with gr.Row():
refiner_checkpoint = gr.Dropdown(label='Checkpoint', elem_id=self.elem_id("checkpoint"), choices=sd_models.checkpoint_tiles(), value='', tooltip="switch to another model in t... | with InputAccordion(False, label="Refiner", elem_id=self.elem_id("enable")) as enable_refiner:
with gr.Row():
refiner_checkpoint = gr.Dropdown(label='Checkpoint', elem_id=self.elem_id("checkpoint"), choices=sd_models.checkpoint_tiles(), value='', tooltip="switch to another model in t... | 94 | 236 | 443 | 679 | import gradio as gr
from modules import scripts, sd_models
from modules.infotext_utils import PasteField
from modules.ui_common import create_refresh_button
from modules.ui_components import InputAccordion
class ScriptRefiner(scripts.ScriptBuiltinUI):
section = "accordions"
create_group = False
def __in... | import gradio as gr
from modules import scripts, sd_models
from modules.infotext_utils import PasteField
from modules.ui_common import create_refresh_button
from modules.ui_components import InputAccordion
class ScriptRefiner(scripts.ScriptBuiltinUI):
section = "accordions"
create_group = False
def __in... |
249 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/processing_scripts/sampler.py | 19,20 | 8,46 | ui | ScriptSampler | 20,42 | 20,42 | class ScriptSampler(scripts.ScriptBuiltinUI):
section = "sampler"
def __init__(self):
self.steps = None
self.sampler_name = None
self.scheduler = None
def title(self):
return "Sampler"
def ui(self, is_img2img):
FILL_FUNC_BODY def setup(self, p, steps, sampler_name, ... | class ScriptSampler(scripts.ScriptBuiltinUI):
section = "sampler"
def __init__(self):
self.steps = None
self.sampler_name = None
self.scheduler = None
def title(self):
return "Sampler"
def ui(self, is_img2img):
FILL_FUNC_BODY def setup(self, p, steps, sampler_name, ... | sampler_names = [x.name for x in sd_samplers.visible_samplers()]
scheduler_names = [x.label for x in sd_schedulers.schedulers]
if shared.opts.samplers_in_dropdown:
with FormRow(elem_id=f"sampler_selection_{self.tabname}"):
self.sampler_name = gr.Dropdown(label='Sampl... | sampler_names = [x.name for x in sd_samplers.visible_samplers()]
scheduler_names = [x.label for x in sd_schedulers.schedulers]
if shared.opts.samplers_in_dropdown:
with FormRow(elem_id=f"sampler_selection_{self.tabname}"):
self.sampler_name = gr.Dropdown(label='Sampl... | 84 | 143 | 575 | 718 | import gradio as gr
from modules import scripts, sd_samplers, sd_schedulers, shared
from modules.infotext_utils import PasteField
from modules.ui_components import FormRow, FormGroup
class ScriptSampler(scripts.ScriptBuiltinUI):
section = "sampler"
def __init__(self):
self.steps = None
self.... | import gradio as gr
from modules import scripts, sd_samplers, sd_schedulers, shared
from modules.infotext_utils import PasteField
from modules.ui_components import FormRow, FormGroup
class ScriptSampler(scripts.ScriptBuiltinUI):
section = "sampler"
def __init__(self):
self.steps = None
self.... |
250 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/processing_scripts/seed.py | 81,82 | 1,106 | connect_reuse_seed | 85,106 | 82,106 | import json
import gradio as gr
from modules import scripts, ui, errors
from modules.infotext_utils import PasteField
from modules.shared import cmd_opts
from modules.ui_components import ToolButton
from modules import infotext_utils
class ScriptSeed(scripts.ScriptBuiltinUI):
section = "seed"
create_group =... | import json
import gradio as gr
from modules import scripts, ui, errors
from modules.infotext_utils import PasteField
from modules.shared import cmd_opts
from modules.ui_components import ToolButton
from modules import infotext_utils
class ScriptSeed(scripts.ScriptBuiltinUI):
section = "seed"
create_group =... |
def copy_seed(gen_info_string: str, index):
res = -1
try:
gen_info = json.loads(gen_info_string)
infotext = gen_info.get('infotexts')[index]
gen_parameters = infotext_utils.parse_generation_parameters(infotext, [])
res = int(gen_parameters.get('Variat... | """ Connects a 'reuse (sub)seed' button's click event so that it copies last used
(sub)seed value from generation info the to the seed field. If copying subseed and subseed strength
was 0, i.e. no variation seed was used, it copies the normal seed value instead."""
def copy_seed(gen_info_string... | 55 | 1,554 | 269 | 1,823 | import json
import gradio as gr
from modules import scripts, ui, errors
from modules.infotext_utils import PasteField
from modules.shared import cmd_opts
from modules.ui_components import ToolButton
from modules import infotext_utils
class ScriptSeed(scripts.ScriptBuiltinUI):
section = "seed"
create_group =... | import json
import gradio as gr
from modules import scripts, ui, errors
from modules.infotext_utils import PasteField
from modules.shared import cmd_opts
from modules.ui_components import ToolButton
from modules import infotext_utils
class ScriptSeed(scripts.ScriptBuiltinUI):
section = "seed"
create_group =... | |
251 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/processing_scripts/seed.py | 69,70 | 12,81 | setup | ScriptSeed | 70,81 | 70,81 | class ScriptSeed(scripts.ScriptBuiltinUI):
section = "seed"
create_group = False
def __init__(self):
self.seed = None
self.reuse_seed = None
self.reuse_subseed = None
def title(self):
return "Seed"
def show(self, is_img2img):
return scripts.AlwaysVisible
... | class ScriptSeed(scripts.ScriptBuiltinUI):
section = "seed"
create_group = False
def __init__(self):
self.seed = None
self.reuse_seed = None
self.reuse_subseed = None
def title(self):
return "Seed"
def show(self, is_img2img):
return scripts.AlwaysVisible
... | p.seed = seed
if seed_checkbox and subseed_strength > 0:
p.subseed = subseed
p.subseed_strength = subseed_strength
if seed_checkbox and seed_resize_from_w > 0 and seed_resize_from_h > 0:
p.seed_resize_from_w = seed_resize_from_w
p.seed_resize_fro... | p.seed = seed
if seed_checkbox and subseed_strength > 0:
p.subseed = subseed
p.subseed_strength = subseed_strength
if seed_checkbox and seed_resize_from_w > 0 and seed_resize_from_h > 0:
p.seed_resize_from_w = seed_resize_from_w
p.seed_resize_fro... | 31 | 1,265 | 126 | 1,391 | import json
import gradio as gr
from modules import scripts, ui, errors
from modules.infotext_utils import PasteField
from modules.shared import cmd_opts
from modules.ui_components import ToolButton
from modules import infotext_utils
class ScriptSeed(scripts.ScriptBuiltinUI):
section = "seed"
create_group =... | import json
import gradio as gr
from modules import scripts, ui, errors
from modules.infotext_utils import PasteField
from modules.shared import cmd_opts
from modules.ui_components import ToolButton
from modules import infotext_utils
class ScriptSeed(scripts.ScriptBuiltinUI):
section = "seed"
create_group =... |
252 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/progress.py | 87,88 | 1,153 | progressapi | 88,144 | 88,144 | import base64
import io
import time
import gradio as gr
from pydantic import BaseModel, Field
from modules.shared import opts
import modules.shared as shared
from collections import OrderedDict
import string
import random
from typing import List
current_task = None
pending_tasks = OrderedDict()
finished_tasks = []
... | import base64
import io
import time
import gradio as gr
from pydantic import BaseModel, Field
from modules.shared import opts
import modules.shared as shared
from collections import OrderedDict
import string
import random
from typing import List
current_task = None
pending_tasks = OrderedDict()
finished_tasks = []
... | active = req.id_task == current_task
queued = req.id_task in pending_tasks
completed = req.id_task in finished_tasks
if not active:
textinfo = "Waiting..."
if queued:
sorted_queued = sorted(pending_tasks.keys(), key=lambda x: pending_tasks[x])
queue_index = sorte... | active = req.id_task == current_task
queued = req.id_task in pending_tasks
completed = req.id_task in finished_tasks
if not active:
textinfo = "Waiting..."
if queued:
sorted_queued = sorted(pending_tasks.keys(), key=lambda x: pending_tasks[x])
queue_index = sorte... | 199 | 1,044 | 807 | 1,851 | import base64
import io
import time
import gradio as gr
from pydantic import BaseModel, Field
from modules.shared import opts
import modules.shared as shared
from collections import OrderedDict
import string
import random
from typing import List
current_task = None
pending_tasks = OrderedDict()
finished_tasks = []
... | import base64
import io
import time
import gradio as gr
from pydantic import BaseModel, Field
from modules.shared import opts
import modules.shared as shared
from collections import OrderedDict
import string
import random
from typing import List
current_task = None
pending_tasks = OrderedDict()
finished_tasks = []
... | |
254 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/prompt_parser.py | 104,105 | 100,120 | alternate | AtStep | 105,107 | 105,107 | class AtStep(lark.Transformer):
def scheduled(self, args):
before, after, _, when, _ = args
yield before or () if step <= when else after
def alternate(self, args):
FILL_FUNC_BODY def start(self, args):
def flatten(x):
... | class AtStep(lark.Transformer):
def scheduled(self, args):
before, after, _, when, _ = args
yield before or () if step <= when else after
def alternate(self, args):
FILL_FUNC_BODY def start(self, args):
def flatten(x):
... | args = ["" if not arg else arg for arg in args]
yield args[(step - 1) % len(args)]
| args = ["" if not arg else arg for arg in args]
yield args[(step - 1) % len(args)]
| 18 | 169 | 33 | 202 | from __future__ import annotations
import re
from collections import namedtuple
import lark
# a prompt like this: "fantasy landscape with a [mountain:lake:0.25] and [an oak:a christmas tree:0.75][ in foreground::0.6][: in background:0.25] [shoddy:masterful:0.5]"
# will be represented with prompt_schedule like this (a... | from __future__ import annotations
import re
from collections import namedtuple
import lark
# a prompt like this: "fantasy landscape with a [mountain:lake:0.25] and [an oak:a christmas tree:0.75][ in foreground::0.6][: in background:0.25] [shoddy:masterful:0.5]"
# will be represented with prompt_schedule like this (a... |
255 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/prompt_parser.py | 79,80 | 78,96 | scheduled | CollectSteps | 80,93 | 80,93 | class CollectSteps(lark.Visitor):
def scheduled(self, tree):
FILL_FUNC_BODY def alternate(self, tree):
res.extend(range(1, steps+1))
| class CollectSteps(lark.Visitor):
def scheduled(self, tree):
FILL_FUNC_BODY def alternate(self, tree):
res.extend(range(1, steps+1))
| s = tree.children[-2]
v = float(s)
if use_old_scheduling:
v = v*steps if v<1 else v
else:
if "." in s:
v = (v - flt_offset) * steps
else:
v = (v - i... | s = tree.children[-2]
v = float(s)
if use_old_scheduling:
v = v*steps if v<1 else v
else:
if "." in s:
v = (v - flt_offset) * steps
else:
v = (v - i... | 42 | 56 | 137 | 193 | from __future__ import annotations
import re
from collections import namedtuple
import lark
# a prompt like this: "fantasy landscape with a [mountain:lake:0.25] and [an oak:a christmas tree:0.75][ in foreground::0.6][: in background:0.25] [shoddy:masterful:0.5]"
# will be represented with prompt_schedule like this (a... | from __future__ import annotations
import re
from collections import namedtuple
import lark
# a prompt like this: "fantasy landscape with a [mountain:lake:0.25] and [an oak:a christmas tree:0.75][ in foreground::0.6][: in background:0.25] [shoddy:masterful:0.5]"
# will be represented with prompt_schedule like this (a... |
256 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/prompt_parser.py | 275,277 | 270,280 | shape | DictWithShape | 277,280 | 277,280 | class DictWithShape(dict):
def __init__(self, x, shape):
super().__init__()
self.update(x)
@property
def shape(self):
FILL_FUNC_BODY | class DictWithShape(dict):
def __init__(self, x, shape):
super().__init__()
self.update(x)
@property
def shape(self):
FILL_FUNC_BODY | return self["crossattn"].shape
| return self["crossattn"].shape
| 2 | 59 | 15 | 74 | from __future__ import annotations
import re
from collections import namedtuple
import lark
# a prompt like this: "fantasy landscape with a [mountain:lake:0.25] and [an oak:a christmas tree:0.75][ in foreground::0.6][: in background:0.25] [shoddy:masterful:0.5]"
# will be represented with prompt_schedule like this (a... | from __future__ import annotations
import re
from collections import namedtuple
import lark
# a prompt like this: "fantasy landscape with a [mountain:lake:0.25] and [an oak:a christmas tree:0.75][ in foreground::0.6][: in background:0.25] [shoddy:masterful:0.5]"
# will be represented with prompt_schedule like this (a... |
257 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/realesrgan_model.py | 67,68 | 1,106 | get_realesrgan_models | 68,106 | 68,106 | import os
from modules import modelloader, errors
from modules.shared import cmd_opts, opts
from modules.upscaler import Upscaler, UpscalerData
from modules.upscaler_utils import upscale_with_model
class UpscalerRealESRGAN(Upscaler):
def __init__(self, path):
self.name = "RealESRGAN"
self.user_pa... | import os
from modules import modelloader, errors
from modules.shared import cmd_opts, opts
from modules.upscaler import Upscaler, UpscalerData
from modules.upscaler_utils import upscale_with_model
class UpscalerRealESRGAN(Upscaler):
def __init__(self, path):
self.name = "RealESRGAN"
self.user_pa... | return [
UpscalerData(
name="R-ESRGAN General 4xV3",
path="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth",
scale=4,
upscaler=scaler,
),
UpscalerData(
name="R-ESRGAN General WDN 4xV3",
... | return [
UpscalerData(
name="R-ESRGAN General 4xV3",
path="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth",
scale=4,
upscaler=scaler,
),
UpscalerData(
name="R-ESRGAN General WDN 4xV3",
... | 49 | 783 | 600 | 1,383 | import os
from modules import modelloader, errors
from modules.shared import cmd_opts, opts
from modules.upscaler import Upscaler, UpscalerData
from modules.upscaler_utils import upscale_with_model
class UpscalerRealESRGAN(Upscaler):
def __init__(self, path):
self.name = "RealESRGAN"
self.user_pa... | import os
from modules import modelloader, errors
from modules.shared import cmd_opts, opts
from modules.upscaler import Upscaler, UpscalerData
from modules.upscaler_utils import upscale_with_model
class UpscalerRealESRGAN(Upscaler):
def __init__(self, path):
self.name = "RealESRGAN"
self.user_pa... | |
258 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/realesrgan_model.py | 29,30 | 9,67 | do_upscale | UpscalerRealESRGAN | 30,53 | 30,53 | class UpscalerRealESRGAN(Upscaler):
def __init__(self, path):
self.name = "RealESRGAN"
self.user_path = path
super().__init__()
self.enable = True
self.scalers = []
scalers = get_realesrgan_models(self)
local_model_paths = self.find_models(ext_filter=[".pth"]... | class UpscalerRealESRGAN(Upscaler):
def __init__(self, path):
self.name = "RealESRGAN"
self.user_path = path
super().__init__()
self.enable = True
self.scalers = []
scalers = get_realesrgan_models(self)
local_model_paths = self.find_models(ext_filter=[".pth"]... | if not self.enable:
return img
try:
info = self.load_model(path)
except Exception:
errors.report(f"Unable to load RealESRGAN model {path}", exc_info=True)
return img
model_descriptor = modelloader.load_spandrel_model(
info.loc... | if not self.enable:
return img
try:
info = self.load_model(path)
except Exception:
errors.report(f"Unable to load RealESRGAN model {path}", exc_info=True)
return img
model_descriptor = modelloader.load_spandrel_model(
info.loc... | 50 | 466 | 256 | 722 | import os
from modules import modelloader, errors
from modules.shared import cmd_opts, opts
from modules.upscaler import Upscaler, UpscalerData
from modules.upscaler_utils import upscale_with_model
class UpscalerRealESRGAN(Upscaler):
def __init__(self, path):
self.name = "RealESRGAN"
self.user_pa... | import os
from modules import modelloader, errors
from modules.shared import cmd_opts, opts
from modules.upscaler import Upscaler, UpscalerData
from modules.upscaler_utils import upscale_with_model
class UpscalerRealESRGAN(Upscaler):
def __init__(self, path):
self.name = "RealESRGAN"
self.user_pa... |
259 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/restart.py | 14,15 | 1,26 | restart_program | 16,24 | 15,24 | import os
from pathlib import Path
from modules.paths_internal import script_path
def is_restartable() -> bool:
"""
Return True if the webui is restartable (i.e. there is something watching to restart it with)
"""
return bool(os.environ.get('SD_WEBUI_RESTART'))
def restart_program() -> None:
FILL_F... | import os
from pathlib import Path
from modules.paths_internal import script_path
def is_restartable() -> bool:
"""
Return True if the webui is restartable (i.e. there is something watching to restart it with)
"""
return bool(os.environ.get('SD_WEBUI_RESTART'))
def restart_program() -> None:
""... |
tmpdir = Path(script_path) / "tmp"
tmpdir.mkdir(parents=True, exist_ok=True)
(tmpdir / "restart").touch()
stop_program()
| """creates file tmp/restart and immediately stops the process, which webui.bat/webui.sh interpret as a command to start webui again"""
tmpdir = Path(script_path) / "tmp"
tmpdir.mkdir(parents=True, exist_ok=True)
(tmpdir / "restart").touch()
stop_program()
| 11 | 167 | 63 | 230 | import os
from pathlib import Path
from modules.paths_internal import script_path
def is_restartable() -> bool:
"""
Return True if the webui is restartable (i.e. there is something watching to restart it with)
"""
return bool(os.environ.get('SD_WEBUI_RESTART'))
def restart_program() -> None:
FILL_F... | import os
from pathlib import Path
from modules.paths_internal import script_path
def is_restartable() -> bool:
"""
Return True if the webui is restartable (i.e. there is something watching to restart it with)
"""
return bool(os.environ.get('SD_WEBUI_RESTART'))
def restart_program() -> None:
""... | |
261 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/rng.py | 112,113 | 99,166 | first | ImageRNG | 113,153 | 113,153 | class ImageRNG:
def __init__(self, shape, seeds, subseeds=None, subseed_strength=0.0, seed_resize_from_h=0, seed_resize_from_w=0):
self.shape = tuple(map(int, shape))
self.seeds = seeds
self.subseeds = subseeds
self.subseed_strength = subseed_strength
self.seed_resize_from_h ... | class ImageRNG:
def __init__(self, shape, seeds, subseeds=None, subseed_strength=0.0, seed_resize_from_h=0, seed_resize_from_w=0):
self.shape = tuple(map(int, shape))
self.seeds = seeds
self.subseeds = subseeds
self.subseed_strength = subseed_strength
self.seed_resize_from_h ... | noise_shape = self.shape if self.seed_resize_from_h <= 0 or self.seed_resize_from_w <= 0 else (self.shape[0], int(self.seed_resize_from_h) // 8, int(self.seed_resize_from_w // 8))
xs = []
for i, (seed, generator) in enumerate(zip(self.seeds, self.generators)):
subnoise = None
... | noise_shape = self.shape if self.seed_resize_from_h <= 0 or self.seed_resize_from_w <= 0 else (self.shape[0], int(self.seed_resize_from_h) // 8, int(self.seed_resize_from_w // 8))
xs = []
for i, (seed, generator) in enumerate(zip(self.seeds, self.generators)):
subnoise = None
... | 190 | 285 | 601 | 886 | import torch
from modules import devices, rng_philox, shared
def randn(seed, shape, generator=None):
"""Generate a tensor with random numbers from a normal distribution using seed.
Uses the seed parameter to set the global torch seed; to generate more with that seed, use randn_like/randn_without_seed."""
... | import torch
from modules import devices, rng_philox, shared
def randn(seed, shape, generator=None):
"""Generate a tensor with random numbers from a normal distribution using seed.
Uses the seed parameter to set the global torch seed; to generate more with that seed, use randn_like/randn_without_seed."""
... |
262 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/rng_philox.py | 27,28 | 1,103 | uint32 | 29,32 | 28,32 | """RNG imitiating torch cuda randn on CPU. You are welcome.
Usage:
```
g = Generator(seed=0)
print(g.randn(shape=(3, 4)))
```
Expected output:
```
[[-0.92466259 -0.42534415 -2.6438457 0.14518388]
[-0.12086647 -0.57972564 -0.62285122 -0.32838709]
[-1.07454231 -0.36314407 -1.67105067 2.26550497]]
```
"""
import ... | """RNG imitiating torch cuda randn on CPU. You are welcome.
Usage:
```
g = Generator(seed=0)
print(g.randn(shape=(3, 4)))
```
Expected output:
```
[[-0.92466259 -0.42534415 -2.6438457 0.14518388]
[-0.12086647 -0.57972564 -0.62285122 -0.32838709]
[-1.07454231 -0.36314407 -1.67105067 2.26550497]]
```
"""
import ... | return x.view(np.uint32).reshape(-1, 2).transpose(1, 0)
| """Converts (N,) np.uint64 array into (2, N) np.unit32 array."""
return x.view(np.uint32).reshape(-1, 2).transpose(1, 0)
| 4 | 1,260 | 34 | 1,294 | """RNG imitiating torch cuda randn on CPU. You are welcome.
Usage:
```
g = Generator(seed=0)
print(g.randn(shape=(3, 4)))
```
Expected output:
```
[[-0.92466259 -0.42534415 -2.6438457 0.14518388]
[-0.12086647 -0.57972564 -0.62285122 -0.32838709]
[-1.07454231 -0.36314407 -1.67105067 2.26550497]]
```
"""
import ... | """RNG imitiating torch cuda randn on CPU. You are welcome.
Usage:
```
g = Generator(seed=0)
print(g.randn(shape=(3, 4)))
```
Expected output:
```
[[-0.92466259 -0.42534415 -2.6438457 0.14518388]
[-0.12086647 -0.57972564 -0.62285122 -0.32838709]
[-1.07454231 -0.36314407 -1.67105067 2.26550497]]
```
"""
import ... | |
263 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/rng_philox.py | 84,85 | 77,103 | randn | Generator | 86,103 | 85,103 | class Generator:
"""RNG that produces same outputs as torch.randn(..., device='cuda') on CPU"""
def __init__(self, seed):
self.seed = seed
self.offset = 0
def randn(self, shape):
FILL_FUNC_BODY | class Generator:
"""RNG that produces same outputs as torch.randn(..., device='cuda') on CPU"""
def __init__(self, seed):
self.seed = seed
self.offset = 0
def randn(self, shape):
"""Generate a sequence of n standard normal random variables using the Philox 4x32 random number genera... |
n = 1
for x in shape:
n *= x
counter = np.zeros((4, n), dtype=np.uint32)
counter[0] = self.offset
counter[2] = np.arange(n, dtype=np.uint32) # up to 2^32 numbers can be generated - if you want more you'd need to spill into counter[3]
self.offset += 1
... | """Generate a sequence of n standard normal random variables using the Philox 4x32 random number generator and the Box-Muller transform."""
n = 1
for x in shape:
n *= x
counter = np.zeros((4, n), dtype=np.uint32)
counter[0] = self.offset
counter[2] = np.aran... | 64 | 113 | 222 | 335 | """RNG imitiating torch cuda randn on CPU. You are welcome.
Usage:
```
g = Generator(seed=0)
print(g.randn(shape=(3, 4)))
```
Expected output:
```
[[-0.92466259 -0.42534415 -2.6438457 0.14518388]
[-0.12086647 -0.57972564 -0.62285122 -0.32838709]
[-1.07454231 -0.36314407 -1.67105067 2.26550497]]
```
"""
import ... | """RNG imitiating torch cuda randn on CPU. You are welcome.
Usage:
```
g = Generator(seed=0)
print(g.randn(shape=(3, 4)))
```
Expected output:
```
[[-0.92466259 -0.42534415 -2.6438457 0.14518388]
[-0.12086647 -0.57972564 -0.62285122 -0.32838709]
[-1.07454231 -0.36314407 -1.67105067 2.26550497]]
```
"""
import ... |
265 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/safe.py | 34,35 | 23,68 | find_class | RestrictedUnpickler | 35,68 | 35,68 | class RestrictedUnpickler(pickle.Unpickler):
extra_handler = None
def persistent_load(self, saved_id):
assert saved_id[0] == 'storage'
try:
return TypedStorage(_internal=True)
except TypeError:
return TypedStorage() # PyTorch before 2.0 does not have the _inter... | class RestrictedUnpickler(pickle.Unpickler):
extra_handler = None
def persistent_load(self, saved_id):
assert saved_id[0] == 'storage'
try:
return TypedStorage(_internal=True)
except TypeError:
return TypedStorage() # PyTorch before 2.0 does not have the _inter... | if self.extra_handler is not None:
res = self.extra_handler(module, name)
if res is not None:
return res
if module == 'collections' and name == 'OrderedDict':
return getattr(collections, name)
if module == 'torch._utils' and name in ['_rebuild... | if self.extra_handler is not None:
res = self.extra_handler(module, name)
if res is not None:
return res
if module == 'collections' and name == 'OrderedDict':
return getattr(collections, name)
if module == 'torch._utils' and name in ['_rebuild... | 155 | 123 | 563 | 686 | # this code is adapted from the script contributed by anon from /h/
import pickle
import collections
import torch
import numpy
import _codecs
import zipfile
import re
# PyTorch 1.13 and later have _TypedStorage renamed to TypedStorage
from modules import errors
TypedStorage = torch.storage.TypedStorage if hasattr(... | # this code is adapted from the script contributed by anon from /h/
import pickle
import collections
import torch
import numpy
import _codecs
import zipfile
import re
# PyTorch 1.13 and later have _TypedStorage renamed to TypedStorage
from modules import errors
TypedStorage = torch.storage.TypedStorage if hasattr(... |
267 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/script_loading.py | 19,20 | 1,36 | preload_extensions | 20,36 | 20,36 | import os
import importlib.util
from modules import errors
loaded_scripts = {}
def load_module(path):
module_spec = importlib.util.spec_from_file_location(os.path.basename(path), path)
module = importlib.util.module_from_spec(module_spec)
module_spec.loader.exec_module(module)
loaded_scripts[path]... | import os
import importlib.util
from modules import errors
loaded_scripts = {}
def load_module(path):
module_spec = importlib.util.spec_from_file_location(os.path.basename(path), path)
module = importlib.util.module_from_spec(module_spec)
module_spec.loader.exec_module(module)
loaded_scripts[path]... | if not os.path.isdir(extensions_dir):
return
extensions = extension_list if extension_list is not None else os.listdir(extensions_dir)
for dirname in sorted(extensions):
preload_script = os.path.join(extensions_dir, dirname, "preload.py")
if not os.path.isfile(preload_script):
... | if not os.path.isdir(extensions_dir):
return
extensions = extension_list if extension_list is not None else os.listdir(extensions_dir)
for dirname in sorted(extensions):
preload_script = os.path.join(extensions_dir, dirname, "preload.py")
if not os.path.isfile(preload_script):
... | 43 | 142 | 187 | 329 | import os
import importlib.util
from modules import errors
loaded_scripts = {}
def load_module(path):
module_spec = importlib.util.spec_from_file_location(os.path.basename(path), path)
module = importlib.util.module_from_spec(module_spec)
module_spec.loader.exec_module(module)
loaded_scripts[path]... | import os
import importlib.util
from modules import errors
loaded_scripts = {}
def load_module(path):
module_spec = importlib.util.spec_from_file_location(os.path.basename(path), path)
module = importlib.util.module_from_spec(module_spec)
module_spec.loader.exec_module(module)
loaded_scripts[path]... | |
270 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/scripts.py | 347,348 | 344,359 | elem_id | ScriptBuiltinUI | 349,355 | 348,355 | class ScriptBuiltinUI(Script):
setup_for_ui_only = True
def elem_id(self, item_id):
FILL_FUNC_BODY def show(self, is_img2img):
return AlwaysVisible
| class ScriptBuiltinUI(Script):
setup_for_ui_only = True
def elem_id(self, item_id):
"""helper function to generate id for a HTML element, constructs final id out of tab and user-supplied item_id"""
FILL_FUNC_BODY def show(self, is_img2img):
return AlwaysVisible
|
need_tabname = self.show(True) == self.show(False)
tabname = ('img2img' if self.is_img2img else 'txt2img') + "_" if need_tabname else ""
return f'{tabname}{item_id}'
| """helper function to generate id for a HTML element, constructs final id out of tab and user-supplied item_id"""
need_tabname = self.show(True) == self.show(False)
tabname = ('img2img' if self.is_img2img else 'txt2img') + "_" if need_tabname else ""
return f'{tabname}{item_id}'
| 20 | 94 | 76 | 170 | import os
import re
import sys
import inspect
from collections import namedtuple
from dataclasses import dataclass
import gradio as gr
from modules import shared, paths, script_callbacks, extensions, script_loading, scripts_postprocessing, errors, timer, util
topological_sort = util.topological_sort
AlwaysVisible =... | import os
import re
import sys
import inspect
from collections import namedtuple
from dataclasses import dataclass
import gradio as gr
from modules import shared, paths, script_callbacks, extensions, script_loading, scripts_postprocessing, errors, timer, util
topological_sort = util.topological_sort
AlwaysVisible =... |
272 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/scripts_auto_postprocessing.py | 29,30 | 1,43 | create_auto_preprocessing_script_data | 30,43 | 30,43 | from modules import scripts, scripts_postprocessing, shared
class ScriptPostprocessingForMainUI(scripts.Script):
def __init__(self, script_postproc):
self.script: scripts_postprocessing.ScriptPostprocessing = script_postproc
self.postprocessing_controls = None
def title(self):
return ... | from modules import scripts, scripts_postprocessing, shared
class ScriptPostprocessingForMainUI(scripts.Script):
def __init__(self, script_postproc):
self.script: scripts_postprocessing.ScriptPostprocessing = script_postproc
self.postprocessing_controls = None
def title(self):
return ... | from modules import scripts
res = []
for name in shared.opts.postprocessing_enable_in_main_ui:
script = next(iter([x for x in scripts.postprocessing_scripts_data if x.script_class.name == name]), None)
if script is None:
continue
constructor = lambda s=script: ScriptPo... | from modules import scripts
res = []
for name in shared.opts.postprocessing_enable_in_main_ui:
script = next(iter([x for x in scripts.postprocessing_scripts_data if x.script_class.name == name]), None)
if script is None:
continue
constructor = lambda s=script: ScriptPo... | 39 | 287 | 157 | 444 | from modules import scripts, scripts_postprocessing, shared
class ScriptPostprocessingForMainUI(scripts.Script):
def __init__(self, script_postproc):
self.script: scripts_postprocessing.ScriptPostprocessing = script_postproc
self.postprocessing_controls = None
def title(self):
return ... | from modules import scripts, scripts_postprocessing, shared
class ScriptPostprocessingForMainUI(scripts.Script):
def __init__(self, script_postproc):
self.script: scripts_postprocessing.ScriptPostprocessing = script_postproc
self.postprocessing_controls = None
def title(self):
return ... | |
273 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/scripts_auto_postprocessing.py | 19,20 | 4,29 | postprocess_image | ScriptPostprocessingForMainUI | 20,29 | 20,29 | class ScriptPostprocessingForMainUI(scripts.Script):
def __init__(self, script_postproc):
self.script: scripts_postprocessing.ScriptPostprocessing = script_postproc
self.postprocessing_controls = None
def title(self):
return self.script.name
def show(self, is_img2img):
retu... | class ScriptPostprocessingForMainUI(scripts.Script):
def __init__(self, script_postproc):
self.script: scripts_postprocessing.ScriptPostprocessing = script_postproc
self.postprocessing_controls = None
def title(self):
return self.script.name
def show(self, is_img2img):
retu... | args_dict = dict(zip(self.postprocessing_controls, args))
pp = scripts_postprocessing.PostprocessedImage(script_pp.image)
pp.info = {}
self.script.process(pp, **args_dict)
p.extra_generation_params.update(pp.info)
script_pp.image = pp.image
| args_dict = dict(zip(self.postprocessing_controls, args))
pp = scripts_postprocessing.PostprocessedImage(script_pp.image)
pp.info = {}
self.script.process(pp, **args_dict)
p.extra_generation_params.update(pp.info)
script_pp.image = pp.image
| 16 | 167 | 102 | 269 | from modules import scripts, scripts_postprocessing, shared
class ScriptPostprocessingForMainUI(scripts.Script):
def __init__(self, script_postproc):
self.script: scripts_postprocessing.ScriptPostprocessing = script_postproc
self.postprocessing_controls = None
def title(self):
return ... | from modules import scripts, scripts_postprocessing, shared
class ScriptPostprocessingForMainUI(scripts.Script):
def __init__(self, script_postproc):
self.script: scripts_postprocessing.ScriptPostprocessing = script_postproc
self.postprocessing_controls = None
def title(self):
return ... |
274 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/scripts_postprocessing.py | 101,102 | 1,231 | wrap_call | 102,111 | 102,111 | import dataclasses
import os
import gradio as gr
from modules import errors, shared
@dataclasses.dataclass
class PostprocessedImageSharedInfo:
target_width: int = None
target_height: int = None
class PostprocessedImage:
def __init__(self, image):
self.image = image
self.info = {}
... | import dataclasses
import os
import gradio as gr
from modules import errors, shared
@dataclasses.dataclass
class PostprocessedImageSharedInfo:
target_width: int = None
target_height: int = None
class PostprocessedImage:
def __init__(self, image):
self.image = image
self.info = {}
... | try:
res = func(*args, **kwargs)
return res
except Exception as e:
errors.display(e, f"calling {filename}/{funcname}")
return default
| try:
res = func(*args, **kwargs)
return res
except Exception as e:
errors.display(e, f"calling {filename}/{funcname}")
return default
| 16 | 1,883 | 62 | 1,945 | import dataclasses
import os
import gradio as gr
from modules import errors, shared
@dataclasses.dataclass
class PostprocessedImageSharedInfo:
target_width: int = None
target_height: int = None
class PostprocessedImage:
def __init__(self, image):
self.image = image
self.info = {}
... | import dataclasses
import os
import gradio as gr
from modules import errors, shared
@dataclasses.dataclass
class PostprocessedImageSharedInfo:
target_width: int = None
target_height: int = None
class PostprocessedImage:
def __init__(self, image):
self.image = image
self.info = {}
... | |
275 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/scripts_postprocessing.py | 24,25 | 14,56 | get_suffix | PostprocessedImage | 25,43 | 25,43 | class PostprocessedImage:
def __init__(self, image):
self.image = image
self.info = {}
self.shared = PostprocessedImageSharedInfo()
self.extra_images = []
self.nametags = []
self.disable_processing = False
self.caption = None
def get_suffix(self, used_suf... | class PostprocessedImage:
def __init__(self, image):
self.image = image
self.info = {}
self.shared = PostprocessedImageSharedInfo()
self.extra_images = []
self.nametags = []
self.disable_processing = False
self.caption = None
def get_suffix(self, used_suf... | used_suffixes = {} if used_suffixes is None else used_suffixes
suffix = "-".join(self.nametags)
if suffix:
suffix = "-" + suffix
if suffix not in used_suffixes:
used_suffixes[suffix] = 1
return suffix
for i in range(1, 100):
propo... | used_suffixes = {} if used_suffixes is None else used_suffixes
suffix = "-".join(self.nametags)
if suffix:
suffix = "-" + suffix
if suffix not in used_suffixes:
used_suffixes[suffix] = 1
return suffix
for i in range(1, 100):
propo... | 53 | 224 | 174 | 398 | import dataclasses
import os
import gradio as gr
from modules import errors, shared
@dataclasses.dataclass
class PostprocessedImageSharedInfo:
target_width: int = None
target_height: int = None
class PostprocessedImage:
def __init__(self, image):
self.image = image
self.info = {}
... | import dataclasses
import os
import gradio as gr
from modules import errors, shared
@dataclasses.dataclass
class PostprocessedImageSharedInfo:
target_width: int = None
target_height: int = None
class PostprocessedImage:
def __init__(self, image):
self.image = image
self.info = {}
... |
276 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/scripts_postprocessing.py | 172,173 | 111,231 | run | ScriptPostprocessingRunner | 173,210 | 173,210 | class ScriptPostprocessingRunner:
def __init__(self):
self.scripts = None
self.ui_created = False
def initialize_scripts(self, scripts_data):
self.scripts = []
for script_data in scripts_data:
script: ScriptPostprocessing = script_data.script_class()
scr... | class ScriptPostprocessingRunner:
def __init__(self):
self.scripts = None
self.ui_created = False
def initialize_scripts(self, scripts_data):
self.scripts = []
for script_data in scripts_data:
script: ScriptPostprocessing = script_data.script_class()
scr... | scripts = []
for script in self.scripts_in_preferred_order():
script_args = args[script.args_from:script.args_to]
process_args = {}
for (name, _component), value in zip(script.controls.items(), script_args):
process_args[name] = value
sc... | scripts = []
for script in self.scripts_in_preferred_order():
script_args = args[script.args_from:script.args_to]
process_args = {}
for (name, _component), value in zip(script.controls.items(), script_args):
process_args[name] = value
sc... | 71 | 797 | 343 | 1,140 | import dataclasses
import os
import gradio as gr
from modules import errors, shared
@dataclasses.dataclass
class PostprocessedImageSharedInfo:
target_width: int = None
target_height: int = None
class PostprocessedImage:
def __init__(self, image):
self.image = image
self.info = {}
... | import dataclasses
import os
import gradio as gr
from modules import errors, shared
@dataclasses.dataclass
class PostprocessedImageSharedInfo:
target_width: int = None
target_height: int = None
class PostprocessedImage:
def __init__(self, image):
self.image = image
self.info = {}
... |
277 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_disable_initialization.py | 67,68 | 30,115 | CLIPTextModel_from_pretrained | DisableInitialization | 68,72 | 68,72 | class DisableInitialization(ReplaceHelper):
"""
When an object of this class enters a `with` block, it starts:
- preventing torch's layer initialization functions from working
- changes CLIP and OpenCLIP to not download model weights
- changes CLIP to not make requests to check if there is a new ver... | class DisableInitialization(ReplaceHelper):
"""
When an object of this class enters a `with` block, it starts:
- preventing torch's layer initialization functions from working
- changes CLIP and OpenCLIP to not download model weights
- changes CLIP to not make requests to check if there is a new ver... | res = self.CLIPTextModel_from_pretrained(None, *model_args, config=pretrained_model_name_or_path, state_dict={}, **kwargs)
res.name_or_path = pretrained_model_name_or_path
return res
| res = self.CLIPTextModel_from_pretrained(None, *model_args, config=pretrained_model_name_or_path, state_dict={}, **kwargs)
res.name_or_path = pretrained_model_name_or_path
return res
| 12 | 1,303 | 74 | 1,377 | import ldm.modules.encoders.modules
import open_clip
import torch
import transformers.utils.hub
from modules import shared
class ReplaceHelper:
def __init__(self):
self.replaced = []
def replace(self, obj, field, func):
original = getattr(obj, field, None)
if original is None:
... | import ldm.modules.encoders.modules
import open_clip
import torch
import transformers.utils.hub
from modules import shared
class ReplaceHelper:
def __init__(self):
self.replaced = []
def replace(self, obj, field, func):
original = getattr(obj, field, None)
if original is None:
... |
278 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_disable_initialization.py | 132,133 | 115,145 | set_device | InitializeOnMeta | 133,136 | 133,136 | class InitializeOnMeta(ReplaceHelper):
"""
Context manager that causes all parameters for linear/conv2d/mha layers to be allocated on meta device,
which results in those parameters having no values and taking no memory. model.to() will be broken and
will need to be repaired by using LoadStateDictOnMeta ... | class InitializeOnMeta(ReplaceHelper):
"""
Context manager that causes all parameters for linear/conv2d/mha layers to be allocated on meta device,
which results in those parameters having no values and taking no memory. model.to() will be broken and
will need to be repaired by using LoadStateDictOnMeta ... | x["device"] = "meta"
return x
| x["device"] = "meta"
return x
| 5 | 385 | 18 | 403 | import ldm.modules.encoders.modules
import open_clip
import torch
import transformers.utils.hub
from modules import shared
class ReplaceHelper:
def __init__(self):
self.replaced = []
def replace(self, obj, field, func):
original = getattr(obj, field, None)
if original is None:
... | import ldm.modules.encoders.modules
import open_clip
import torch
import transformers.utils.hub
from modules import shared
class ReplaceHelper:
def __init__(self):
self.replaced = []
def replace(self, obj, field, func):
original = getattr(obj, field, None)
if original is None:
... |
279 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_disable_initialization.py | 206,207 | 145,233 | load_state_dict | LoadStateDictOnMeta | 217,223 | 207,223 | class LoadStateDictOnMeta(ReplaceHelper):
"""
Context manager that allows to read parameters from state_dict into a model that has some of its parameters in the meta device.
As those parameters are read from state_dict, they will be deleted from it, so by the end state_dict will be mostly empty, to save mem... | class LoadStateDictOnMeta(ReplaceHelper):
"""
Context manager that allows to read parameters from state_dict into a model that has some of its parameters in the meta device.
As those parameters are read from state_dict, they will be deleted from it, so by the end state_dict will be mostly empty, to save mem... |
if state_dict is sd:
state_dict = {k: v.to(device="meta", dtype=v.dtype) for k, v in state_dict.items()}
original(module, state_dict, strict=strict)
| """torch makes a lot of copies of the dictionary with weights, so just deleting entries from state_dict does not help
because the same values are stored in multiple copies of the dict. The trick used here is to give torch a dict with
all weights on meta device, i.e. deleted, and then... | 17 | 1,386 | 71 | 1,457 | import ldm.modules.encoders.modules
import open_clip
import torch
import transformers.utils.hub
from modules import shared
class ReplaceHelper:
def __init__(self):
self.replaced = []
def replace(self, obj, field, func):
original = getattr(obj, field, None)
if original is None:
... | import ldm.modules.encoders.modules
import open_clip
import torch
import transformers.utils.hub
from modules import shared
class ReplaceHelper:
def __init__(self):
self.replaced = []
def replace(self, obj, field, func):
original = getattr(obj, field, None)
if original is None:
... |
280 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_disable_initialization.py | 23,24 | 9,30 | restore | ReplaceHelper | 24,30 | 24,30 | class ReplaceHelper:
def __init__(self):
self.replaced = []
def replace(self, obj, field, func):
original = getattr(obj, field, None)
if original is None:
return None
self.replaced.append((obj, field, original))
setattr(obj, field, func)
return orig... | class ReplaceHelper:
def __init__(self):
self.replaced = []
def replace(self, obj, field, func):
original = getattr(obj, field, None)
if original is None:
return None
self.replaced.append((obj, field, original))
setattr(obj, field, func)
return orig... | for obj, field, original in self.replaced:
setattr(obj, field, original)
self.replaced.clear()
| for obj, field, original in self.replaced:
setattr(obj, field, original)
self.replaced.clear()
| 10 | 110 | 43 | 153 | import ldm.modules.encoders.modules
import open_clip
import torch
import transformers.utils.hub
from modules import shared
class ReplaceHelper:
def __init__(self):
self.replaced = []
def replace(self, obj, field, func):
original = getattr(obj, field, None)
if original is None:
... | import ldm.modules.encoders.modules
import open_clip
import torch
import transformers.utils.hub
from modules import shared
class ReplaceHelper:
def __init__(self):
self.replaced = []
def replace(self, obj, field, func):
original = getattr(obj, field, None)
if original is None:
... |
281 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_emphasis.py | 61,62 | 1,71 | get_options_descriptions | 62,65 | 62,65 | from __future__ import annotations
import torch
class Emphasis:
"""Emphasis class decides how to death with (emphasized:1.1) text in prompts"""
name: str = "Base"
description: str = ""
tokens: list[list[int]]
"""tokens from the chunk of the prompt"""
multipliers: torch.Tensor
"""tensor ... | from __future__ import annotations
import torch
class Emphasis:
"""Emphasis class decides how to death with (emphasized:1.1) text in prompts"""
name: str = "Base"
description: str = ""
tokens: list[list[int]]
"""tokens from the chunk of the prompt"""
multipliers: torch.Tensor
"""tensor ... | return ", ".join(f"{x.name}: {x.description}" for x in options)
| return ", ".join(f"{x.name}: {x.description}" for x in options)
| 8 | 612 | 29 | 641 | from __future__ import annotations
import torch
class Emphasis:
"""Emphasis class decides how to death with (emphasized:1.1) text in prompts"""
name: str = "Base"
description: str = ""
tokens: list[list[int]]
"""tokens from the chunk of the prompt"""
multipliers: torch.Tensor
"""tensor ... | from __future__ import annotations
import torch
class Emphasis:
"""Emphasis class decides how to death with (emphasized:1.1) text in prompts"""
name: str = "Base"
description: str = ""
tokens: list[list[int]]
"""tokens from the chunk of the prompt"""
multipliers: torch.Tensor
"""tensor ... | |
282 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_emphasis.py | 40,41 | 36,49 | after_transformers | EmphasisOriginal | 41,49 | 41,49 | class EmphasisOriginal(Emphasis):
name = "Original"
description = "the original emphasis implementation"
def after_transformers(self):
FILL_FUNC_BODY | class EmphasisOriginal(Emphasis):
name = "Original"
description = "the original emphasis implementation"
def after_transformers(self):
FILL_FUNC_BODY | original_mean = self.z.mean()
self.z = self.z * self.multipliers.reshape(self.multipliers.shape + (1,)).expand(self.z.shape)
# restoring original mean is likely not correct, but it seems to work well to prevent artifacts that happen otherwise
new_mean = self.z.mean()
self.z = se... | original_mean = self.z.mean()
self.z = self.z * self.multipliers.reshape(self.multipliers.shape + (1,)).expand(self.z.shape)
# restoring original mean is likely not correct, but it seems to work well to prevent artifacts that happen otherwise
new_mean = self.z.mean()
self.z = se... | 40 | 49 | 118 | 167 | from __future__ import annotations
import torch
class Emphasis:
"""Emphasis class decides how to death with (emphasized:1.1) text in prompts"""
name: str = "Base"
description: str = ""
tokens: list[list[int]]
"""tokens from the chunk of the prompt"""
multipliers: torch.Tensor
"""tensor ... | from __future__ import annotations
import torch
class Emphasis:
"""Emphasis class decides how to death with (emphasized:1.1) text in prompts"""
name: str = "Base"
description: str = ""
tokens: list[list[int]]
"""tokens from the chunk of the prompt"""
multipliers: torch.Tensor
"""tensor ... |
283 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_emphasis.py | 53,54 | 49,57 | after_transformers | EmphasisOriginalNoNorm | 54,57 | 54,57 | class EmphasisOriginalNoNorm(EmphasisOriginal):
name = "No norm"
description = "same as original, but without normalization (seems to work better for SDXL)"
def after_transformers(self):
FILL_FUNC_BODY | class EmphasisOriginalNoNorm(EmphasisOriginal):
name = "No norm"
description = "same as original, but without normalization (seems to work better for SDXL)"
def after_transformers(self):
FILL_FUNC_BODY | self.z = self.z * self.multipliers.reshape(self.multipliers.shape + (1,)).expand(self.z.shape)
| self.z = self.z * self.multipliers.reshape(self.multipliers.shape + (1,)).expand(self.z.shape)
| 7 | 66 | 44 | 110 | from __future__ import annotations
import torch
class Emphasis:
"""Emphasis class decides how to death with (emphasized:1.1) text in prompts"""
name: str = "Base"
description: str = ""
tokens: list[list[int]]
"""tokens from the chunk of the prompt"""
multipliers: torch.Tensor
"""tensor ... | from __future__ import annotations
import torch
class Emphasis:
"""Emphasis class decides how to death with (emphasized:1.1) text in prompts"""
name: str = "Base"
description: str = ""
tokens: list[list[int]]
"""tokens from the chunk of the prompt"""
multipliers: torch.Tensor
"""tensor ... |
285 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_hijack.py | 344,345 | 337,366 | forward | EmbeddingsWithFixes | 345,366 | 345,366 | class EmbeddingsWithFixes(torch.nn.Module):
def __init__(self, wrapped, embeddings, textual_inversion_key='clip_l'):
super().__init__()
self.wrapped = wrapped
self.embeddings = embeddings
self.textual_inversion_key = textual_inversion_key
def forward(self, input_ids):
FILL_FUNC_... | class EmbeddingsWithFixes(torch.nn.Module):
def __init__(self, wrapped, embeddings, textual_inversion_key='clip_l'):
super().__init__()
self.wrapped = wrapped
self.embeddings = embeddings
self.textual_inversion_key = textual_inversion_key
def forward(self, input_ids):
FILL_FUNC_... | batch_fixes = self.embeddings.fixes
self.embeddings.fixes = None
inputs_embeds = self.wrapped(input_ids)
if batch_fixes is None or len(batch_fixes) == 0 or max([len(x) for x in batch_fixes]) == 0:
return inputs_embeds
vecs = []
for fixes, tensor in zip(batc... | batch_fixes = self.embeddings.fixes
self.embeddings.fixes = None
inputs_embeds = self.wrapped(input_ids)
if batch_fixes is None or len(batch_fixes) == 0 or max([len(x) for x in batch_fixes]) == 0:
return inputs_embeds
vecs = []
for fixes, tensor in zip(batc... | 74 | 109 | 278 | 387 | import torch
from torch.nn.functional import silu
from types import MethodType
from modules import devices, sd_hijack_optimizations, shared, script_callbacks, errors, sd_unet, patches
from modules.hypernetworks import hypernetwork
from modules.shared import cmd_opts
from modules import sd_hijack_clip, sd_hijack_open_c... | import torch
from torch.nn.functional import silu
from types import MethodType
from modules import devices, sd_hijack_optimizations, shared, script_callbacks, errors, sd_unet, patches
from modules.hypernetworks import hypernetwork
from modules.shared import cmd_opts
from modules import sd_hijack_clip, sd_hijack_open_c... |
287 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_hijack_checkpoint.py | 11,12 | 1,47 | AttentionBlock_forward | 12,15 | 12,15 | from torch.utils.checkpoint import checkpoint
import ldm.modules.attention
import ldm.modules.diffusionmodules.openaimodel
def BasicTransformerBlock_forward(self, x, context=None):
return checkpoint(self._forward, x, context)
def AttentionBlock_forward(self, x):
FILL_FUNC_BODYdef ResBlock_forward(self, x, emb)... | from torch.utils.checkpoint import checkpoint
import ldm.modules.attention
import ldm.modules.diffusionmodules.openaimodel
def BasicTransformerBlock_forward(self, x, context=None):
return checkpoint(self._forward, x, context)
def AttentionBlock_forward(self, x):
FILL_FUNC_BODYdef ResBlock_forward(self, x, emb)... | return checkpoint(self._forward, x)
| return checkpoint(self._forward, x)
| 3 | 385 | 17 | 402 | from torch.utils.checkpoint import checkpoint
import ldm.modules.attention
import ldm.modules.diffusionmodules.openaimodel
def BasicTransformerBlock_forward(self, x, context=None):
return checkpoint(self._forward, x, context)
def AttentionBlock_forward(self, x):
FILL_FUNC_BODYdef ResBlock_forward(self, x, emb)... | from torch.utils.checkpoint import checkpoint
import ldm.modules.attention
import ldm.modules.diffusionmodules.openaimodel
def BasicTransformerBlock_forward(self, x, context=None):
return checkpoint(self._forward, x, context)
def AttentionBlock_forward(self, x):
FILL_FUNC_BODYdef ResBlock_forward(self, x, emb)... | |
288 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_hijack_clip.py | 353,354 | 349,362 | encode_with_transformers | FrozenCLIPEmbedderForSDXLWithCustomWords | 354,362 | 354,362 | class FrozenCLIPEmbedderForSDXLWithCustomWords(FrozenCLIPEmbedderWithCustomWords):
def __init__(self, wrapped, hijack):
super().__init__(wrapped, hijack)
def encode_with_transformers(self, tokens):
FILL_FUNC_BODY | class FrozenCLIPEmbedderForSDXLWithCustomWords(FrozenCLIPEmbedderWithCustomWords):
def __init__(self, wrapped, hijack):
super().__init__(wrapped, hijack)
def encode_with_transformers(self, tokens):
FILL_FUNC_BODY | outputs = self.wrapped.transformer(input_ids=tokens, output_hidden_states=self.wrapped.layer == "hidden")
if self.wrapped.layer == "last":
z = outputs.last_hidden_state
else:
z = outputs.hidden_states[self.wrapped.layer_idx]
return z
| outputs = self.wrapped.transformer(input_ids=tokens, output_hidden_states=self.wrapped.layer == "hidden")
if self.wrapped.layer == "last":
z = outputs.last_hidden_state
else:
z = outputs.hidden_states[self.wrapped.layer_idx]
return z
| 19 | 84 | 96 | 180 | import math
from collections import namedtuple
import torch
from modules import prompt_parser, devices, sd_hijack, sd_emphasis
from modules.shared import opts
class PromptChunk:
"""
This object contains token ids, weight (multipliers:1.4) and textual inversion embedding info for a chunk of prompt.
If a ... | import math
from collections import namedtuple
import torch
from modules import prompt_parser, devices, sd_hijack, sd_emphasis
from modules.shared import opts
class PromptChunk:
"""
This object contains token ids, weight (multipliers:1.4) and textual inversion embedding info for a chunk of prompt.
If a ... |
289 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_hijack_clip.py | 330,331 | 295,349 | encode_with_transformers | FrozenCLIPEmbedderWithCustomWords | 331,341 | 331,341 | class FrozenCLIPEmbedderWithCustomWords(FrozenCLIPEmbedderWithCustomWordsBase):
def __init__(self, wrapped, hijack):
super().__init__(wrapped, hijack)
self.tokenizer = wrapped.tokenizer
vocab = self.tokenizer.get_vocab()
self.comma_token = vocab.get(',</w>', None)
self.tok... | class FrozenCLIPEmbedderWithCustomWords(FrozenCLIPEmbedderWithCustomWordsBase):
def __init__(self, wrapped, hijack):
super().__init__(wrapped, hijack)
self.tokenizer = wrapped.tokenizer
vocab = self.tokenizer.get_vocab()
self.comma_token = vocab.get(',</w>', None)
self.tok... | outputs = self.wrapped.transformer(input_ids=tokens, output_hidden_states=-opts.CLIP_stop_at_last_layers)
if opts.CLIP_stop_at_last_layers > 1:
z = outputs.hidden_states[-opts.CLIP_stop_at_last_layers]
z = self.wrapped.transformer.text_model.final_layer_norm(z)
else:
... | outputs = self.wrapped.transformer(input_ids=tokens, output_hidden_states=-opts.CLIP_stop_at_last_layers)
if opts.CLIP_stop_at_last_layers > 1:
z = outputs.hidden_states[-opts.CLIP_stop_at_last_layers]
z = self.wrapped.transformer.text_model.final_layer_norm(z)
else:
... | 20 | 555 | 136 | 691 | import math
from collections import namedtuple
import torch
from modules import prompt_parser, devices, sd_hijack, sd_emphasis
from modules.shared import opts
class PromptChunk:
"""
This object contains token ids, weight (multipliers:1.4) and textual inversion embedding info for a chunk of prompt.
If a ... | import math
from collections import namedtuple
import torch
from modules import prompt_parser, devices, sd_hijack, sd_emphasis
from modules.shared import opts
class PromptChunk:
"""
This object contains token ids, weight (multipliers:1.4) and textual inversion embedding info for a chunk of prompt.
If a ... |
291 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_hijack_clip_old.py | 5,6 | 1,83 | process_text_old | 6,72 | 6,72 | from modules import sd_hijack_clip
from modules import shared
def process_text_old(self: sd_hijack_clip.FrozenCLIPEmbedderWithCustomWordsBase, texts):
FILL_FUNC_BODYdef forward_old(self: sd_hijack_clip.FrozenCLIPEmbedderWithCustomWordsBase, texts):
batch_multipliers, remade_batch_tokens, used_custom_terms, hijack... | from modules import sd_hijack_clip
from modules import shared
def process_text_old(self: sd_hijack_clip.FrozenCLIPEmbedderWithCustomWordsBase, texts):
FILL_FUNC_BODYdef forward_old(self: sd_hijack_clip.FrozenCLIPEmbedderWithCustomWordsBase, texts):
batch_multipliers, remade_batch_tokens, used_custom_terms, hijack... | id_start = self.id_start
id_end = self.id_end
maxlen = self.wrapped.max_length # you get to stay at 77
used_custom_terms = []
remade_batch_tokens = []
hijack_comments = []
hijack_fixes = []
token_count = 0
cache = {}
batch_tokens = self.tokenize(texts)
batch_multipliers = [... | id_start = self.id_start
id_end = self.id_end
maxlen = self.wrapped.max_length # you get to stay at 77
used_custom_terms = []
remade_batch_tokens = []
hijack_comments = []
hijack_fixes = []
token_count = 0
cache = {}
batch_tokens = self.tokenize(texts)
batch_multipliers = [... | 233 | 271 | 942 | 1,213 | from modules import sd_hijack_clip
from modules import shared
def process_text_old(self: sd_hijack_clip.FrozenCLIPEmbedderWithCustomWordsBase, texts):
FILL_FUNC_BODYdef forward_old(self: sd_hijack_clip.FrozenCLIPEmbedderWithCustomWordsBase, texts):
batch_multipliers, remade_batch_tokens, used_custom_terms, hijack... | from modules import sd_hijack_clip
from modules import shared
def process_text_old(self: sd_hijack_clip.FrozenCLIPEmbedderWithCustomWordsBase, texts):
FILL_FUNC_BODYdef forward_old(self: sd_hijack_clip.FrozenCLIPEmbedderWithCustomWordsBase, texts):
batch_multipliers, remade_batch_tokens, used_custom_terms, hijack... | |
292 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_hijack_ip2p.py | 4,5 | 1,11 | should_hijack_ip2p | 5,11 | 5,11 | import os.path
def should_hijack_ip2p(checkpoint_info):
FILL_FUNC_BODY | import os.path
def should_hijack_ip2p(checkpoint_info):
FILL_FUNC_BODY | from modules import sd_models_config
ckpt_basename = os.path.basename(checkpoint_info.filename).lower()
cfg_basename = os.path.basename(sd_models_config.find_checkpoint_config_near_filename(checkpoint_info)).lower()
return "pix2pix" in ckpt_basename and "pix2pix" not in cfg_basename
| from modules import sd_models_config
ckpt_basename = os.path.basename(checkpoint_info.filename).lower()
cfg_basename = os.path.basename(sd_models_config.find_checkpoint_config_near_filename(checkpoint_info)).lower()
return "pix2pix" in ckpt_basename and "pix2pix" not in cfg_basename
| 19 | 34 | 115 | 149 | import os.path
def should_hijack_ip2p(checkpoint_info):
FILL_FUNC_BODY | import os.path
def should_hijack_ip2p(checkpoint_info):
FILL_FUNC_BODY | |
293 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_hijack_open_clip.py | 49,50 | 40,72 | tokenize | FrozenOpenCLIPEmbedder2WithCustomWords | 50,56 | 50,56 | class FrozenOpenCLIPEmbedder2WithCustomWords(sd_hijack_clip.FrozenCLIPEmbedderWithCustomWordsBase):
def __init__(self, wrapped, hijack):
super().__init__(wrapped, hijack)
self.comma_token = [v for k, v in tokenizer.encoder.items() if k == ',</w>'][0]
self.id_start = tokenizer.encoder["<star... | class FrozenOpenCLIPEmbedder2WithCustomWords(sd_hijack_clip.FrozenCLIPEmbedderWithCustomWordsBase):
def __init__(self, wrapped, hijack):
super().__init__(wrapped, hijack)
self.comma_token = [v for k, v in tokenizer.encoder.items() if k == ',</w>'][0]
self.id_start = tokenizer.encoder["<star... | assert not opts.use_old_emphasis_implementation, 'Old emphasis implementation not supported for Open Clip'
tokenized = [tokenizer.encode(text) for text in texts]
return tokenized
| assert not opts.use_old_emphasis_implementation, 'Old emphasis implementation not supported for Open Clip'
tokenized = [tokenizer.encode(text) for text in texts]
return tokenized
| 20 | 376 | 59 | 435 | import open_clip.tokenizer
import torch
from modules import sd_hijack_clip, devices
from modules.shared import opts
tokenizer = open_clip.tokenizer._tokenizer
class FrozenOpenCLIPEmbedderWithCustomWords(sd_hijack_clip.FrozenCLIPEmbedderWithCustomWordsBase):
def __init__(self, wrapped, hijack):
super()._... | import open_clip.tokenizer
import torch
from modules import sd_hijack_clip, devices
from modules.shared import opts
tokenizer = open_clip.tokenizer._tokenizer
class FrozenOpenCLIPEmbedderWithCustomWords(sd_hijack_clip.FrozenCLIPEmbedderWithCustomWordsBase):
def __init__(self, wrapped, hijack):
super()._... |
294 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_hijack_open_clip.py | 26,27 | 10,40 | encode_with_transformers | FrozenOpenCLIPEmbedderWithCustomWords | 27,32 | 27,32 | class FrozenOpenCLIPEmbedderWithCustomWords(sd_hijack_clip.FrozenCLIPEmbedderWithCustomWordsBase):
def __init__(self, wrapped, hijack):
super().__init__(wrapped, hijack)
self.comma_token = [v for k, v in tokenizer.encoder.items() if k == ',</w>'][0]
self.id_start = tokenizer.encoder["<start... | class FrozenOpenCLIPEmbedderWithCustomWords(sd_hijack_clip.FrozenCLIPEmbedderWithCustomWordsBase):
def __init__(self, wrapped, hijack):
super().__init__(wrapped, hijack)
self.comma_token = [v for k, v in tokenizer.encoder.items() if k == ',</w>'][0]
self.id_start = tokenizer.encoder["<start... | # set self.wrapped.layer_idx here according to opts.CLIP_stop_at_last_layers
z = self.wrapped.encode_with_transformer(tokens)
return z
| # set self.wrapped.layer_idx here according to opts.CLIP_stop_at_last_layers
z = self.wrapped.encode_with_transformer(tokens)
return z
| 12 | 340 | 57 | 397 | import open_clip.tokenizer
import torch
from modules import sd_hijack_clip, devices
from modules.shared import opts
tokenizer = open_clip.tokenizer._tokenizer
class FrozenOpenCLIPEmbedderWithCustomWords(sd_hijack_clip.FrozenCLIPEmbedderWithCustomWordsBase):
def __init__(self, wrapped, hijack):
super()._... | import open_clip.tokenizer
import torch
from modules import sd_hijack_clip, devices
from modules.shared import opts
tokenizer = open_clip.tokenizer._tokenizer
class FrozenOpenCLIPEmbedderWithCustomWords(sd_hijack_clip.FrozenCLIPEmbedderWithCustomWordsBase):
def __init__(self, wrapped, hijack):
super()._... |
296 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_hijack_optimizations.py | 31,32 | 25,51 | title | SdOptimization | 32,37 | 32,37 | class SdOptimization:
name: str = None
label: str | None = None
cmd_opt: str | None = None
priority: int = 0
def title(self):
FILL_FUNC_BODY def is_available(self):
return True
def apply(self):
pass
def undo(self):
ldm.modules.attention.CrossAttention.forward = ... | class SdOptimization:
name: str = None
label: str | None = None
cmd_opt: str | None = None
priority: int = 0
def title(self):
FILL_FUNC_BODY def is_available(self):
return True
def apply(self):
pass
def undo(self):
ldm.modules.attention.CrossAttention.forward = ... | if self.label is None:
return self.name
return f"{self.name} - {self.label}"
| if self.label is None:
return self.name
return f"{self.name} - {self.label}"
| 10 | 211 | 38 | 249 | from __future__ import annotations
import math
import psutil
import platform
import torch
from torch import einsum
from ldm.util import default
from einops import rearrange
from modules import shared, errors, devices, sub_quadratic_attention
from modules.hypernetworks import hypernetwork
import ldm.modules.attentio... | from __future__ import annotations
import math
import psutil
import platform
import torch
from torch import einsum
from ldm.util import default
from einops import rearrange
from modules import shared, errors, devices, sub_quadratic_attention
from modules.hypernetworks import hypernetwork
import ldm.modules.attentio... |
297 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_hijack_optimizations.py | 139,140 | 134,146 | apply | SdOptimizationDoggettx | 140,146 | 140,146 | class SdOptimizationDoggettx(SdOptimization):
name = "Doggettx"
cmd_opt = "opt_split_attention"
priority = 90
def apply(self):
FILL_FUNC_BODY | class SdOptimizationDoggettx(SdOptimization):
name = "Doggettx"
cmd_opt = "opt_split_attention"
priority = 90
def apply(self):
FILL_FUNC_BODY | ldm.modules.attention.CrossAttention.forward = split_cross_attention_forward
ldm.modules.diffusionmodules.model.AttnBlock.forward = cross_attention_attnblock_forward
sgm.modules.attention.CrossAttention.forward = split_cross_attention_forward
sgm.modules.diffusionmodules.model.AttnBlock.... | ldm.modules.attention.CrossAttention.forward = split_cross_attention_forward
ldm.modules.diffusionmodules.model.AttnBlock.forward = cross_attention_attnblock_forward
sgm.modules.attention.CrossAttention.forward = split_cross_attention_forward
sgm.modules.diffusionmodules.model.AttnBlock.... | 12 | 65 | 110 | 175 | from __future__ import annotations
import math
import psutil
import platform
import torch
from torch import einsum
from ldm.util import default
from einops import rearrange
from modules import shared, errors, devices, sub_quadratic_attention
from modules.hypernetworks import hypernetwork
import ldm.modules.attentio... | from __future__ import annotations
import math
import psutil
import platform
import torch
from torch import einsum
from ldm.util import default
from einops import rearrange
from modules import shared, errors, devices, sub_quadratic_attention
from modules.hypernetworks import hypernetwork
import ldm.modules.attentio... |
298 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_hijack_optimizations.py | 125,127 | 121,134 | priority | SdOptimizationInvokeAI | 127,129 | 127,129 | class SdOptimizationInvokeAI(SdOptimization):
name = "InvokeAI"
cmd_opt = "opt_split_attention_invokeai"
@property
def priority(self):
FILL_FUNC_BODY def apply(self):
ldm.modules.attention.CrossAttention.forward = split_cross_attention_forward_invokeAI
sgm.modules.attention.CrossAtte... | class SdOptimizationInvokeAI(SdOptimization):
name = "InvokeAI"
cmd_opt = "opt_split_attention_invokeai"
@property
def priority(self):
FILL_FUNC_BODY def apply(self):
ldm.modules.attention.CrossAttention.forward = split_cross_attention_forward_invokeAI
sgm.modules.attention.CrossAtte... | return 1000 if shared.device.type != 'mps' and not torch.cuda.is_available() else 10
| return 1000 if shared.device.type != 'mps' and not torch.cuda.is_available() else 10
| 11 | 124 | 39 | 163 | from __future__ import annotations
import math
import psutil
import platform
import torch
from torch import einsum
from ldm.util import default
from einops import rearrange
from modules import shared, errors, devices, sub_quadratic_attention
from modules.hypernetworks import hypernetwork
import ldm.modules.attentio... | from __future__ import annotations
import math
import psutil
import platform
import torch
from torch import einsum
from ldm.util import default
from einops import rearrange
from modules import shared, errors, devices, sub_quadratic_attention
from modules.hypernetworks import hypernetwork
import ldm.modules.attentio... |
299 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_hijack_optimizations.py | 88,89 | 82,95 | apply | SdOptimizationSdp | 89,95 | 89,95 | class SdOptimizationSdp(SdOptimizationSdpNoMem):
name = "sdp"
label = "scaled dot product"
cmd_opt = "opt_sdp_attention"
priority = 70
def apply(self):
FILL_FUNC_BODY | class SdOptimizationSdp(SdOptimizationSdpNoMem):
name = "sdp"
label = "scaled dot product"
cmd_opt = "opt_sdp_attention"
priority = 70
def apply(self):
FILL_FUNC_BODY | ldm.modules.attention.CrossAttention.forward = scaled_dot_product_attention_forward
ldm.modules.diffusionmodules.model.AttnBlock.forward = sdp_attnblock_forward
sgm.modules.attention.CrossAttention.forward = scaled_dot_product_attention_forward
sgm.modules.diffusionmodules.model.AttnBloc... | ldm.modules.attention.CrossAttention.forward = scaled_dot_product_attention_forward
ldm.modules.diffusionmodules.model.AttnBlock.forward = sdp_attnblock_forward
sgm.modules.attention.CrossAttention.forward = scaled_dot_product_attention_forward
sgm.modules.diffusionmodules.model.AttnBloc... | 12 | 76 | 112 | 188 | from __future__ import annotations
import math
import psutil
import platform
import torch
from torch import einsum
from ldm.util import default
from einops import rearrange
from modules import shared, errors, devices, sub_quadratic_attention
from modules.hypernetworks import hypernetwork
import ldm.modules.attentio... | from __future__ import annotations
import math
import psutil
import platform
import torch
from torch import einsum
from ldm.util import default
from einops import rearrange
from modules import shared, errors, devices, sub_quadratic_attention
from modules.hypernetworks import hypernetwork
import ldm.modules.attentio... |
300 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_hijack_optimizations.py | 75,76 | 66,82 | apply | SdOptimizationSdpNoMem | 76,82 | 76,82 | class SdOptimizationSdpNoMem(SdOptimization):
name = "sdp-no-mem"
label = "scaled dot product without memory efficient attention"
cmd_opt = "opt_sdp_no_mem_attention"
priority = 80
def is_available(self):
return hasattr(torch.nn.functional, "scaled_dot_product_attention") and callable(torch... | class SdOptimizationSdpNoMem(SdOptimization):
name = "sdp-no-mem"
label = "scaled dot product without memory efficient attention"
cmd_opt = "opt_sdp_no_mem_attention"
priority = 80
def is_available(self):
return hasattr(torch.nn.functional, "scaled_dot_product_attention") and callable(torch... | ldm.modules.attention.CrossAttention.forward = scaled_dot_product_no_mem_attention_forward
ldm.modules.diffusionmodules.model.AttnBlock.forward = sdp_no_mem_attnblock_forward
sgm.modules.attention.CrossAttention.forward = scaled_dot_product_no_mem_attention_forward
sgm.modules.diffusionm... | ldm.modules.attention.CrossAttention.forward = scaled_dot_product_no_mem_attention_forward
ldm.modules.diffusionmodules.model.AttnBlock.forward = sdp_no_mem_attnblock_forward
sgm.modules.attention.CrossAttention.forward = scaled_dot_product_no_mem_attention_forward
sgm.modules.diffusionm... | 12 | 141 | 128 | 269 | from __future__ import annotations
import math
import psutil
import platform
import torch
from torch import einsum
from ldm.util import default
from einops import rearrange
from modules import shared, errors, devices, sub_quadratic_attention
from modules.hypernetworks import hypernetwork
import ldm.modules.attentio... | from __future__ import annotations
import math
import psutil
import platform
import torch
from torch import einsum
from ldm.util import default
from einops import rearrange
from modules import shared, errors, devices, sub_quadratic_attention
from modules.hypernetworks import hypernetwork
import ldm.modules.attentio... |
301 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_hijack_optimizations.py | 99,101 | 95,110 | priority | SdOptimizationSubQuad | 101,103 | 101,103 | class SdOptimizationSubQuad(SdOptimization):
name = "sub-quadratic"
cmd_opt = "opt_sub_quad_attention"
@property
def priority(self):
FILL_FUNC_BODY def apply(self):
ldm.modules.attention.CrossAttention.forward = sub_quad_attention_forward
ldm.modules.diffusionmodules.model.AttnBlock.... | class SdOptimizationSubQuad(SdOptimization):
name = "sub-quadratic"
cmd_opt = "opt_sub_quad_attention"
@property
def priority(self):
FILL_FUNC_BODY def apply(self):
ldm.modules.attention.CrossAttention.forward = sub_quad_attention_forward
ldm.modules.diffusionmodules.model.AttnBlock.... | return 1000 if shared.device.type == 'mps' else 10
| return 1000 if shared.device.type == 'mps' else 10
| 8 | 176 | 26 | 202 | from __future__ import annotations
import math
import psutil
import platform
import torch
from torch import einsum
from ldm.util import default
from einops import rearrange
from modules import shared, errors, devices, sub_quadratic_attention
from modules.hypernetworks import hypernetwork
import ldm.modules.attentio... | from __future__ import annotations
import math
import psutil
import platform
import torch
from torch import einsum
from ldm.util import default
from einops import rearrange
from modules import shared, errors, devices, sub_quadratic_attention
from modules.hypernetworks import hypernetwork
import ldm.modules.attentio... |
302 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_hijack_optimizations.py | 116,117 | 110,121 | apply | SdOptimizationV1 | 117,121 | 117,121 | class SdOptimizationV1(SdOptimization):
name = "V1"
label = "original v1"
cmd_opt = "opt_split_attention_v1"
priority = 10
def apply(self):
FILL_FUNC_BODY | class SdOptimizationV1(SdOptimization):
name = "V1"
label = "original v1"
cmd_opt = "opt_split_attention_v1"
priority = 10
def apply(self):
FILL_FUNC_BODY | ldm.modules.attention.CrossAttention.forward = split_cross_attention_forward_v1
sgm.modules.attention.CrossAttention.forward = split_cross_attention_forward_v1
| ldm.modules.attention.CrossAttention.forward = split_cross_attention_forward_v1
sgm.modules.attention.CrossAttention.forward = split_cross_attention_forward_v1
| 6 | 73 | 57 | 130 | from __future__ import annotations
import math
import psutil
import platform
import torch
from torch import einsum
from ldm.util import default
from einops import rearrange
from modules import shared, errors, devices, sub_quadratic_attention
from modules.hypernetworks import hypernetwork
import ldm.modules.attentio... | from __future__ import annotations
import math
import psutil
import platform
import torch
from torch import einsum
from ldm.util import default
from einops import rearrange
from modules import shared, errors, devices, sub_quadratic_attention
from modules.hypernetworks import hypernetwork
import ldm.modules.attentio... |
303 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_hijack_optimizations.py | 56,57 | 51,66 | is_available | SdOptimizationXformers | 57,59 | 57,59 | class SdOptimizationXformers(SdOptimization):
name = "xformers"
cmd_opt = "xformers"
priority = 100
def is_available(self):
FILL_FUNC_BODY def apply(self):
ldm.modules.attention.CrossAttention.forward = xformers_attention_forward
ldm.modules.diffusionmodules.model.AttnBlock.forward =... | class SdOptimizationXformers(SdOptimization):
name = "xformers"
cmd_opt = "xformers"
priority = 100
def is_available(self):
FILL_FUNC_BODY def apply(self):
ldm.modules.attention.CrossAttention.forward = xformers_attention_forward
ldm.modules.diffusionmodules.model.AttnBlock.forward =... | return shared.cmd_opts.force_enable_xformers or (shared.xformers_available and torch.cuda.is_available() and (6, 0) <= torch.cuda.get_device_capability(shared.device) <= (9, 0))
| return shared.cmd_opts.force_enable_xformers or (shared.xformers_available and torch.cuda.is_available() and (6, 0) <= torch.cuda.get_device_capability(shared.device) <= (9, 0))
| 14 | 175 | 71 | 246 | from __future__ import annotations
import math
import psutil
import platform
import torch
from torch import einsum
from ldm.util import default
from einops import rearrange
from modules import shared, errors, devices, sub_quadratic_attention
from modules.hypernetworks import hypernetwork
import ldm.modules.attentio... | from __future__ import annotations
import math
import psutil
import platform
import torch
from torch import einsum
from ldm.util import default
from einops import rearrange
from modules import shared, errors, devices, sub_quadratic_attention
from modules.hypernetworks import hypernetwork
import ldm.modules.attentio... |
304 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_hijack_unet.py | 38,39 | 1,86 | apply_model | 39,51 | 39,51 | import torch
from packaging import version
from modules import devices
from modules.sd_hijack_utils import CondFunc
class TorchHijackForUnet:
"""
This is torch, but with cat that resizes tensors to appropriate dimensions if they do not match;
this makes it possible to create pictures with dimensions that... | import torch
from packaging import version
from modules import devices
from modules.sd_hijack_utils import CondFunc
class TorchHijackForUnet:
"""
This is torch, but with cat that resizes tensors to appropriate dimensions if they do not match;
this makes it possible to create pictures with dimensions that... |
if isinstance(cond, dict):
for y in cond.keys():
if isinstance(cond[y], list):
cond[y] = [x.to(devices.dtype_unet) if isinstance(x, torch.Tensor) else x for x in cond[y]]
else:
cond[y] = cond[y].to(devices.dtype_unet) if isinstance(cond[y], torch.Tens... |
if isinstance(cond, dict):
for y in cond.keys():
if isinstance(cond[y], list):
cond[y] = [x.to(devices.dtype_unet) if isinstance(x, torch.Tensor) else x for x in cond[y]]
else:
cond[y] = cond[y].to(devices.dtype_unet) if isinstance(cond[y], torch.Tens... | 39 | 1,446 | 184 | 1,630 | import torch
from packaging import version
from modules import devices
from modules.sd_hijack_utils import CondFunc
class TorchHijackForUnet:
"""
This is torch, but with cat that resizes tensors to appropriate dimensions if they do not match;
this makes it possible to create pictures with dimensions that... | import torch
from packaging import version
from modules import devices
from modules.sd_hijack_utils import CondFunc
class TorchHijackForUnet:
"""
This is torch, but with cat that resizes tensors to appropriate dimensions if they do not match;
this makes it possible to create pictures with dimensions that... | |
305 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_hijack_unet.py | 54,55 | 51,61 | forward | GELUHijack | 55,61 | 55,61 | class GELUHijack(torch.nn.GELU, torch.nn.Module):
def __init__(self, *args, **kwargs):
torch.nn.GELU.__init__(self, *args, **kwargs)
def forward(self, x):
FILL_FUNC_BODY | class GELUHijack(torch.nn.GELU, torch.nn.Module):
def __init__(self, *args, **kwargs):
torch.nn.GELU.__init__(self, *args, **kwargs)
def forward(self, x):
FILL_FUNC_BODY | if devices.unet_needs_upcast:
return torch.nn.GELU.forward(self.float(), x.float()).to(devices.dtype_unet)
else:
return torch.nn.GELU.forward(self, x)
| if devices.unet_needs_upcast:
return torch.nn.GELU.forward(self.float(), x.float()).to(devices.dtype_unet)
else:
return torch.nn.GELU.forward(self, x)
| 9 | 79 | 76 | 155 | import torch
from packaging import version
from modules import devices
from modules.sd_hijack_utils import CondFunc
class TorchHijackForUnet:
"""
This is torch, but with cat that resizes tensors to appropriate dimensions if they do not match;
this makes it possible to create pictures with dimensions that... | import torch
from packaging import version
from modules import devices
from modules.sd_hijack_utils import CondFunc
class TorchHijackForUnet:
"""
This is torch, but with cat that resizes tensors to appropriate dimensions if they do not match;
this makes it possible to create pictures with dimensions that... |
306 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_hijack_unet.py | 23,24 | 8,34 | cat | TorchHijackForUnet | 24,34 | 24,34 | class TorchHijackForUnet:
"""
This is torch, but with cat that resizes tensors to appropriate dimensions if they do not match;
this makes it possible to create pictures with dimensions that are multiples of 8 rather than 64
"""
def __getattr__(self, item):
if item == 'cat':
retu... | class TorchHijackForUnet:
"""
This is torch, but with cat that resizes tensors to appropriate dimensions if they do not match;
this makes it possible to create pictures with dimensions that are multiples of 8 rather than 64
"""
def __getattr__(self, item):
if item == 'cat':
retu... | if len(tensors) == 2:
a, b = tensors
if a.shape[-2:] != b.shape[-2:]:
a = torch.nn.functional.interpolate(a, b.shape[-2:], mode="nearest")
tensors = (a, b)
return torch.cat(tensors, *args, **kwargs)
| if len(tensors) == 2:
a, b = tensors
if a.shape[-2:] != b.shape[-2:]:
a = torch.nn.functional.interpolate(a, b.shape[-2:], mode="nearest")
tensors = (a, b)
return torch.cat(tensors, *args, **kwargs)
| 25 | 168 | 111 | 279 | import torch
from packaging import version
from modules import devices
from modules.sd_hijack_utils import CondFunc
class TorchHijackForUnet:
"""
This is torch, but with cat that resizes tensors to appropriate dimensions if they do not match;
this makes it possible to create pictures with dimensions that... | import torch
from packaging import version
from modules import devices
from modules.sd_hijack_utils import CondFunc
class TorchHijackForUnet:
"""
This is torch, but with cat that resizes tensors to appropriate dimensions if they do not match;
this makes it possible to create pictures with dimensions that... |
307 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_hijack_xlmr.py | 16,17 | 6,33 | encode_with_transformers | FrozenXLMREmbedderWithCustomWords | 17,27 | 17,27 | class FrozenXLMREmbedderWithCustomWords(sd_hijack_clip.FrozenCLIPEmbedderWithCustomWords):
def __init__(self, wrapped, hijack):
super().__init__(wrapped, hijack)
self.id_start = wrapped.config.bos_token_id
self.id_end = wrapped.config.eos_token_id
self.id_pad = wrapped.config.pad_to... | class FrozenXLMREmbedderWithCustomWords(sd_hijack_clip.FrozenCLIPEmbedderWithCustomWords):
def __init__(self, wrapped, hijack):
super().__init__(wrapped, hijack)
self.id_start = wrapped.config.bos_token_id
self.id_end = wrapped.config.eos_token_id
self.id_pad = wrapped.config.pad_to... | # there's no CLIP Skip here because all hidden layers have size of 1024 and the last one uses a
# trained layer to transform those 1024 into 768 for unet; so you can't choose which transformer
# layer to work with - you have to use the last
attention_mask = (tokens != self.id_pad).to(de... | # there's no CLIP Skip here because all hidden layers have size of 1024 and the last one uses a
# trained layer to transform those 1024 into 768 for unet; so you can't choose which transformer
# layer to work with - you have to use the last
attention_mask = (tokens != self.id_pad).to(de... | 64 | 305 | 162 | 467 | import torch
from modules import sd_hijack_clip, devices
class FrozenXLMREmbedderWithCustomWords(sd_hijack_clip.FrozenCLIPEmbedderWithCustomWords):
def __init__(self, wrapped, hijack):
super().__init__(wrapped, hijack)
self.id_start = wrapped.config.bos_token_id
self.id_end = wrapped.con... | import torch
from modules import sd_hijack_clip, devices
class FrozenXLMREmbedderWithCustomWords(sd_hijack_clip.FrozenCLIPEmbedderWithCustomWords):
def __init__(self, wrapped, hijack):
super().__init__(wrapped, hijack)
self.id_start = wrapped.config.bos_token_id
self.id_end = wrapped.con... |
308 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_models_config.py | 69,70 | 1,132 | guess_model_config_from_state_dict | 70,111 | 70,111 | import os
import torch
from modules import shared, paths, sd_disable_initialization, devices
sd_configs_path = shared.sd_configs_path
sd_repo_configs_path = os.path.join(paths.paths['Stable Diffusion'], "configs", "stable-diffusion")
sd_xl_repo_configs_path = os.path.join(paths.paths['Stable Diffusion XL'], "configs... | import os
import torch
from modules import shared, paths, sd_disable_initialization, devices
sd_configs_path = shared.sd_configs_path
sd_repo_configs_path = os.path.join(paths.paths['Stable Diffusion'], "configs", "stable-diffusion")
sd_xl_repo_configs_path = os.path.join(paths.paths['Stable Diffusion XL'], "configs... | sd2_cond_proj_weight = sd.get('cond_stage_model.model.transformer.resblocks.0.attn.in_proj_weight', None)
diffusion_model_input = sd.get('model.diffusion_model.input_blocks.0.0.weight', None)
sd2_variations_weight = sd.get('embedder.model.ln_final.weight', None)
if sd.get('conditioner.embedders.1.model... | sd2_cond_proj_weight = sd.get('cond_stage_model.model.transformer.resblocks.0.attn.in_proj_weight', None)
diffusion_model_input = sd.get('model.diffusion_model.input_blocks.0.0.weight', None)
sd2_variations_weight = sd.get('embedder.model.ln_final.weight', None)
if sd.get('conditioner.embedders.1.model... | 120 | 1,316 | 654 | 1,970 | import os
import torch
from modules import shared, paths, sd_disable_initialization, devices
sd_configs_path = shared.sd_configs_path
sd_repo_configs_path = os.path.join(paths.paths['Stable Diffusion'], "configs", "stable-diffusion")
sd_xl_repo_configs_path = os.path.join(paths.paths['Stable Diffusion XL'], "configs... | import os
import torch
from modules import shared, paths, sd_disable_initialization, devices
sd_configs_path = shared.sd_configs_path
sd_repo_configs_path = os.path.join(paths.paths['Stable Diffusion'], "configs", "stable-diffusion")
sd_xl_repo_configs_path = os.path.join(paths.paths['Stable Diffusion XL'], "configs... | |
309 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_models_xl.py | 74,75 | 1,116 | process_texts | 75,79 | 75,79 | from __future__ import annotations
import torch
import sgm.models.diffusion
import sgm.modules.diffusionmodules.denoiser_scaling
import sgm.modules.diffusionmodules.discretizer
from modules import devices, shared, prompt_parser
from modules import torch_utils
def get_learned_conditioning(self: sgm.models.diffusion.... | from __future__ import annotations
import torch
import sgm.models.diffusion
import sgm.modules.diffusionmodules.denoiser_scaling
import sgm.modules.diffusionmodules.discretizer
from modules import devices, shared, prompt_parser
from modules import torch_utils
def get_learned_conditioning(self: sgm.models.diffusion.... | for embedder in [embedder for embedder in self.embedders if hasattr(embedder, 'process_texts')]:
return embedder.process_texts(texts)
| for embedder in [embedder for embedder in self.embedders if hasattr(embedder, 'process_texts')]:
return embedder.process_texts(texts)
| 13 | 1,638 | 51 | 1,689 | from __future__ import annotations
import torch
import sgm.models.diffusion
import sgm.modules.diffusionmodules.denoiser_scaling
import sgm.modules.diffusionmodules.discretizer
from modules import devices, shared, prompt_parser
from modules import torch_utils
def get_learned_conditioning(self: sgm.models.diffusion.... | from __future__ import annotations
import torch
import sgm.models.diffusion
import sgm.modules.diffusionmodules.denoiser_scaling
import sgm.modules.diffusionmodules.discretizer
from modules import devices, shared, prompt_parser
from modules import torch_utils
def get_learned_conditioning(self: sgm.models.diffusion.... | |
313 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_samplers_common.py | 265,266 | 229,356 | launch_sampling | Sampler | 266,283 | 266,283 | class Sampler:
def __init__(self, funcname):
self.funcname = funcname
self.func = funcname
self.extra_params = []
self.sampler_noises = None
self.stop_at = None
self.eta = None
self.config: SamplerData = None # set by the function calling the constructor
... | class Sampler:
def __init__(self, funcname):
self.funcname = funcname
self.func = funcname
self.extra_params = []
self.sampler_noises = None
self.stop_at = None
self.eta = None
self.config: SamplerData = None # set by the function calling the constructor
... | self.model_wrap_cfg.steps = steps
self.model_wrap_cfg.total_steps = self.config.total_steps(steps)
state.sampling_steps = steps
state.sampling_step = 0
try:
return func()
except RecursionError:
print(
'Encountered RecursionError du... | self.model_wrap_cfg.steps = steps
self.model_wrap_cfg.total_steps = self.config.total_steps(steps)
state.sampling_steps = steps
state.sampling_step = 0
try:
return func()
except RecursionError:
print(
'Encountered RecursionError du... | 54 | 1,559 | 176 | 1,735 | import inspect
from collections import namedtuple
import numpy as np
import torch
from PIL import Image
from modules import devices, images, sd_vae_approx, sd_samplers, sd_vae_taesd, shared, sd_models
from modules.shared import opts, state
import k_diffusion.sampling
SamplerDataTuple = namedtuple('SamplerData', ['nam... | import inspect
from collections import namedtuple
import numpy as np
import torch
from PIL import Image
from modules import devices, images, sd_vae_approx, sd_samplers, sd_vae_taesd, shared, sd_models
from modules.shared import opts, state
import k_diffusion.sampling
SamplerDataTuple = namedtuple('SamplerData', ['nam... |
314 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_samplers_common.py | 15,16 | 14,22 | total_steps | SamplerData | 16,22 | 16,22 | class SamplerData(SamplerDataTuple):
def total_steps(self, steps):
FILL_FUNC_BODY | class SamplerData(SamplerDataTuple):
def total_steps(self, steps):
FILL_FUNC_BODY | if self.options.get("second_order", False):
steps = steps * 2
return steps
| if self.options.get("second_order", False):
steps = steps * 2
return steps
| 10 | 33 | 36 | 69 | import inspect
from collections import namedtuple
import numpy as np
import torch
from PIL import Image
from modules import devices, images, sd_vae_approx, sd_samplers, sd_vae_taesd, shared, sd_models
from modules.shared import opts, state
import k_diffusion.sampling
SamplerDataTuple = namedtuple('SamplerData', ['nam... | import inspect
from collections import namedtuple
import numpy as np
import torch
from PIL import Image
from modules import devices, images, sd_vae_approx, sd_samplers, sd_vae_taesd, shared, sd_models
from modules.shared import opts, state
import k_diffusion.sampling
SamplerDataTuple = namedtuple('SamplerData', ['nam... |
315 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_samplers_common.py | 225,226 | 205,229 | randn_like | TorchHijack | 226,229 | 226,229 | class TorchHijack:
"""This is here to replace torch.randn_like of k-diffusion.
k-diffusion has random_sampler argument for most samplers, but not for all, so
this is needed to properly replace every use of torch.randn_like.
We need to replace to make images generated in batches to be same as images ge... | class TorchHijack:
"""This is here to replace torch.randn_like of k-diffusion.
k-diffusion has random_sampler argument for most samplers, but not for all, so
this is needed to properly replace every use of torch.randn_like.
We need to replace to make images generated in batches to be same as images ge... | return self.rng.next()
| return self.rng.next()
| 2 | 224 | 15 | 239 | import inspect
from collections import namedtuple
import numpy as np
import torch
from PIL import Image
from modules import devices, images, sd_vae_approx, sd_samplers, sd_vae_taesd, shared, sd_models
from modules.shared import opts, state
import k_diffusion.sampling
SamplerDataTuple = namedtuple('SamplerData', ['nam... | import inspect
from collections import namedtuple
import numpy as np
import torch
from PIL import Image
from modules import devices, images, sd_vae_approx, sd_samplers, sd_vae_taesd, shared, sd_models
from modules.shared import opts, state
import k_diffusion.sampling
SamplerDataTuple = namedtuple('SamplerData', ['nam... |
316 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_samplers_extra.py | 6,8 | 1,75 | restart_sampler | 12,75 | 8,75 | import torch
import tqdm
import k_diffusion.sampling
@torch.no_grad()
def restart_sampler(model, x, sigmas, extra_args=None, callback=None, disable=None, s_noise=1., restart_list=None):
FILL_FUNC_BODY | import torch
import tqdm
import k_diffusion.sampling
@torch.no_grad()
def restart_sampler(model, x, sigmas, extra_args=None, callback=None, disable=None, s_noise=1., restart_list=None):
"""Implements restart sampling in Restart Sampling for Improving Generative Processes (2023)
Restart_list format: {min_sigma... | extra_args = {} if extra_args is None else extra_args
s_in = x.new_ones([x.shape[0]])
step_id = 0
from k_diffusion.sampling import to_d, get_sigmas_karras
def heun_step(x, old_sigma, new_sigma, second_order=True):
nonlocal step_id
denoised = model(x, old_sigma * s_in, **extra_args)
... | """Implements restart sampling in Restart Sampling for Improving Generative Processes (2023)
Restart_list format: {min_sigma: [ restart_steps, restart_times, max_sigma]}
If restart_list is None: will choose restart_list automatically, otherwise will use the given restart_list
"""
extra_args = {} if ... | 286 | 158 | 961 | 1,119 | import torch
import tqdm
import k_diffusion.sampling
@torch.no_grad()
def restart_sampler(model, x, sigmas, extra_args=None, callback=None, disable=None, s_noise=1., restart_list=None):
FILL_FUNC_BODY | import torch
import tqdm
import k_diffusion.sampling
@torch.no_grad()
def restart_sampler(model, x, sigmas, extra_args=None, callback=None, disable=None, s_noise=1., restart_list=None):
"""Implements restart sampling in Restart Sampling for Improving Generative Processes (2023)
Restart_list format: {min_sigma... | |
317 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_samplers_kdiffusion.py | 53,55 | 52,62 | inner_model | CFGDenoiserKDiffusion | 55,62 | 55,62 | class CFGDenoiserKDiffusion(sd_samplers_cfg_denoiser.CFGDenoiser):
@property
def inner_model(self):
FILL_FUNC_BODY | class CFGDenoiserKDiffusion(sd_samplers_cfg_denoiser.CFGDenoiser):
@property
def inner_model(self):
FILL_FUNC_BODY | if self.model_wrap is None:
denoiser = k_diffusion.external.CompVisVDenoiser if shared.sd_model.parameterization == "v" else k_diffusion.external.CompVisDenoiser
self.model_wrap = denoiser(shared.sd_model, quantize=shared.opts.enable_quantization)
return self.model_wrap
| if self.model_wrap is None:
denoiser = k_diffusion.external.CompVisVDenoiser if shared.sd_model.parameterization == "v" else k_diffusion.external.CompVisDenoiser
self.model_wrap = denoiser(shared.sd_model, quantize=shared.opts.enable_quantization)
return self.model_wrap
| 19 | 50 | 103 | 153 | import torch
import inspect
import k_diffusion.sampling
from modules import sd_samplers_common, sd_samplers_extra, sd_samplers_cfg_denoiser, sd_schedulers
from modules.sd_samplers_cfg_denoiser import CFGDenoiser # noqa: F401
from modules.script_callbacks import ExtraNoiseParams, extra_noise_callback
from modules.shar... | import torch
import inspect
import k_diffusion.sampling
from modules import sd_samplers_common, sd_samplers_extra, sd_samplers_cfg_denoiser, sd_schedulers
from modules.sd_samplers_cfg_denoiser import CFGDenoiser # noqa: F401
from modules.script_callbacks import ExtraNoiseParams, extra_noise_callback
from modules.shar... |
319 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_samplers_lcm.py | 66,67 | 1,105 | sample_lcm | 67,83 | 67,83 | import torch
from k_diffusion import utils, sampling
from k_diffusion.external import DiscreteEpsDDPMDenoiser
from k_diffusion.sampling import default_noise_sampler, trange
from modules import shared, sd_samplers_cfg_denoiser, sd_samplers_kdiffusion, sd_samplers_common
class LCMCompVisDenoiser(DiscreteEpsDDPMDenois... | import torch
from k_diffusion import utils, sampling
from k_diffusion.external import DiscreteEpsDDPMDenoiser
from k_diffusion.sampling import default_noise_sampler, trange
from modules import shared, sd_samplers_cfg_denoiser, sd_samplers_kdiffusion, sd_samplers_common
class LCMCompVisDenoiser(DiscreteEpsDDPMDenois... | extra_args = {} if extra_args is None else extra_args
noise_sampler = default_noise_sampler(x) if noise_sampler is None else noise_sampler
s_in = x.new_ones([x.shape[0]])
for i in trange(len(sigmas) - 1, disable=disable):
denoised = model(x, sigmas[i] * s_in, **extra_args)
if callback ... | extra_args = {} if extra_args is None else extra_args
noise_sampler = default_noise_sampler(x) if noise_sampler is None else noise_sampler
s_in = x.new_ones([x.shape[0]])
for i in trange(len(sigmas) - 1, disable=disable):
denoised = model(x, sigmas[i] * s_in, **extra_args)
if callback ... | 71 | 1,240 | 233 | 1,473 | import torch
from k_diffusion import utils, sampling
from k_diffusion.external import DiscreteEpsDDPMDenoiser
from k_diffusion.sampling import default_noise_sampler, trange
from modules import shared, sd_samplers_cfg_denoiser, sd_samplers_kdiffusion, sd_samplers_common
class LCMCompVisDenoiser(DiscreteEpsDDPMDenois... | import torch
from k_diffusion import utils, sampling
from k_diffusion.external import DiscreteEpsDDPMDenoiser
from k_diffusion.sampling import default_noise_sampler, trange
from modules import shared, sd_samplers_cfg_denoiser, sd_samplers_kdiffusion, sd_samplers_common
class LCMCompVisDenoiser(DiscreteEpsDDPMDenois... | |
320 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_samplers_lcm.py | 84,86 | 83,93 | inner_model | CFGDenoiserLCM | 86,93 | 86,93 | class CFGDenoiserLCM(sd_samplers_cfg_denoiser.CFGDenoiser):
@property
def inner_model(self):
FILL_FUNC_BODY | class CFGDenoiserLCM(sd_samplers_cfg_denoiser.CFGDenoiser):
@property
def inner_model(self):
FILL_FUNC_BODY | if self.model_wrap is None:
denoiser = LCMCompVisDenoiser
self.model_wrap = denoiser(shared.sd_model)
return self.model_wrap
| if self.model_wrap is None:
denoiser = LCMCompVisDenoiser
self.model_wrap = denoiser(shared.sd_model)
return self.model_wrap
| 12 | 49 | 60 | 109 | import torch
from k_diffusion import utils, sampling
from k_diffusion.external import DiscreteEpsDDPMDenoiser
from k_diffusion.sampling import default_noise_sampler, trange
from modules import shared, sd_samplers_cfg_denoiser, sd_samplers_kdiffusion, sd_samplers_common
class LCMCompVisDenoiser(DiscreteEpsDDPMDenois... | import torch
from k_diffusion import utils, sampling
from k_diffusion.external import DiscreteEpsDDPMDenoiser
from k_diffusion.sampling import default_noise_sampler, trange
from modules import shared, sd_samplers_cfg_denoiser, sd_samplers_kdiffusion, sd_samplers_common
class LCMCompVisDenoiser(DiscreteEpsDDPMDenois... |
321 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_samplers_lcm.py | 50,51 | 10,66 | get_scaled_out | LCMCompVisDenoiser | 51,60 | 51,60 | class LCMCompVisDenoiser(DiscreteEpsDDPMDenoiser):
def __init__(self, model):
timesteps = 1000
original_timesteps = 50 # LCM Original Timesteps (default=50, for current version of LCM)
self.skip_steps = timesteps // original_timesteps
alphas_cumprod_valid = torch.zeros((original... | class LCMCompVisDenoiser(DiscreteEpsDDPMDenoiser):
def __init__(self, model):
timesteps = 1000
original_timesteps = 50 # LCM Original Timesteps (default=50, for current version of LCM)
self.skip_steps = timesteps // original_timesteps
alphas_cumprod_valid = torch.zeros((original... | sigma_data = 0.5
scaled_timestep = utils.append_dims(self.sigma_to_t(sigma), output.ndim) * 10.0
c_skip = sigma_data**2 / (scaled_timestep**2 + sigma_data**2)
c_out = scaled_timestep / (scaled_timestep**2 + sigma_data**2) ** 0.5
return c_out * output + c_skip * input
| sigma_data = 0.5
scaled_timestep = utils.append_dims(self.sigma_to_t(sigma), output.ndim) * 10.0
c_skip = sigma_data**2 / (scaled_timestep**2 + sigma_data**2)
c_out = scaled_timestep / (scaled_timestep**2 + sigma_data**2) ** 0.5
return c_out * output + c_skip * input
| 33 | 689 | 138 | 827 | import torch
from k_diffusion import utils, sampling
from k_diffusion.external import DiscreteEpsDDPMDenoiser
from k_diffusion.sampling import default_noise_sampler, trange
from modules import shared, sd_samplers_cfg_denoiser, sd_samplers_kdiffusion, sd_samplers_common
class LCMCompVisDenoiser(DiscreteEpsDDPMDenois... | import torch
from k_diffusion import utils, sampling
from k_diffusion.external import DiscreteEpsDDPMDenoiser
from k_diffusion.sampling import default_noise_sampler, trange
from modules import shared, sd_samplers_cfg_denoiser, sd_samplers_kdiffusion, sd_samplers_common
class LCMCompVisDenoiser(DiscreteEpsDDPMDenois... |
322 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_samplers_timesteps.py | 65,67 | 47,74 | inner_model | CFGDenoiserTimesteps | 67,74 | 67,74 | class CFGDenoiserTimesteps(CFGDenoiser):
def __init__(self, sampler):
super().__init__(sampler)
self.alphas = shared.sd_model.alphas_cumprod
self.mask_before_denoising = True
def get_pred_x0(self, x_in, x_out, sigma):
ts = sigma.to(dtype=int)
a_t = self.alphas[ts][:, ... | class CFGDenoiserTimesteps(CFGDenoiser):
def __init__(self, sampler):
super().__init__(sampler)
self.alphas = shared.sd_model.alphas_cumprod
self.mask_before_denoising = True
def get_pred_x0(self, x_in, x_out, sigma):
ts = sigma.to(dtype=int)
a_t = self.alphas[ts][:, ... | if self.model_wrap is None:
denoiser = CompVisTimestepsVDenoiser if shared.sd_model.parameterization == "v" else CompVisTimestepsDenoiser
self.model_wrap = denoiser(shared.sd_model)
return self.model_wrap
| if self.model_wrap is None:
denoiser = CompVisTimestepsVDenoiser if shared.sd_model.parameterization == "v" else CompVisTimestepsDenoiser
self.model_wrap = denoiser(shared.sd_model)
return self.model_wrap
| 18 | 215 | 83 | 298 | import torch
import inspect
import sys
from modules import devices, sd_samplers_common, sd_samplers_timesteps_impl
from modules.sd_samplers_cfg_denoiser import CFGDenoiser
from modules.script_callbacks import ExtraNoiseParams, extra_noise_callback
from modules.shared import opts
import modules.shared as shared
sample... | import torch
import inspect
import sys
from modules import devices, sd_samplers_common, sd_samplers_timesteps_impl
from modules.sd_samplers_cfg_denoiser import CFGDenoiser
from modules.script_callbacks import ExtraNoiseParams, extra_noise_callback
from modules.shared import opts
import modules.shared as shared
sample... |
323 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_samplers_timesteps.py | 140,141 | 74,165 | sample | CompVisSampler | 141,165 | 141,165 | class CompVisSampler(sd_samplers_common.Sampler):
def __init__(self, funcname, sd_model):
super().__init__(funcname)
self.eta_option_field = 'eta_ddim'
self.eta_infotext_field = 'Eta DDIM'
self.eta_default = 0.0
self.model_wrap_cfg = CFGDenoiserTimesteps(self)
self.... | class CompVisSampler(sd_samplers_common.Sampler):
def __init__(self, funcname, sd_model):
super().__init__(funcname)
self.eta_option_field = 'eta_ddim'
self.eta_infotext_field = 'Eta DDIM'
self.eta_default = 0.0
self.model_wrap_cfg = CFGDenoiserTimesteps(self)
self.... | steps = steps or p.steps
timesteps = self.get_timesteps(p, steps)
extra_params_kwargs = self.initialize(p)
parameters = inspect.signature(self.func).parameters
if 'timesteps' in parameters:
extra_params_kwargs['timesteps'] = timesteps
self.last_latent = x
... | steps = steps or p.steps
timesteps = self.get_timesteps(p, steps)
extra_params_kwargs = self.initialize(p)
parameters = inspect.signature(self.func).parameters
if 'timesteps' in parameters:
extra_params_kwargs['timesteps'] = timesteps
self.last_latent = x
... | 52 | 993 | 279 | 1,272 | import torch
import inspect
import sys
from modules import devices, sd_samplers_common, sd_samplers_timesteps_impl
from modules.sd_samplers_cfg_denoiser import CFGDenoiser
from modules.script_callbacks import ExtraNoiseParams, extra_noise_callback
from modules.shared import opts
import modules.shared as shared
sample... | import torch
import inspect
import sys
from modules import devices, sd_samplers_common, sd_samplers_timesteps_impl
from modules.sd_samplers_cfg_denoiser import CFGDenoiser
from modules.script_callbacks import ExtraNoiseParams, extra_noise_callback
from modules.shared import opts
import modules.shared as shared
sample... |
324 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_samplers_timesteps.py | 29,30 | 24,33 | forward | CompVisTimestepsDenoiser | 30,33 | 30,33 | class CompVisTimestepsDenoiser(torch.nn.Module):
def __init__(self, model, *args, **kwargs):
super().__init__(*args, **kwargs)
self.inner_model = model
def forward(self, input, timesteps, **kwargs):
FILL_FUNC_BODY | class CompVisTimestepsDenoiser(torch.nn.Module):
def __init__(self, model, *args, **kwargs):
super().__init__(*args, **kwargs)
self.inner_model = model
def forward(self, input, timesteps, **kwargs):
FILL_FUNC_BODY | return self.inner_model.apply_model(input, timesteps, **kwargs)
| return self.inner_model.apply_model(input, timesteps, **kwargs)
| 4 | 83 | 27 | 110 | import torch
import inspect
import sys
from modules import devices, sd_samplers_common, sd_samplers_timesteps_impl
from modules.sd_samplers_cfg_denoiser import CFGDenoiser
from modules.script_callbacks import ExtraNoiseParams, extra_noise_callback
from modules.shared import opts
import modules.shared as shared
sample... | import torch
import inspect
import sys
from modules import devices, sd_samplers_common, sd_samplers_timesteps_impl
from modules.sd_samplers_cfg_denoiser import CFGDenoiser
from modules.script_callbacks import ExtraNoiseParams, extra_noise_callback
from modules.shared import opts
import modules.shared as shared
sample... |
325 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_samplers_timesteps.py | 41,42 | 33,47 | forward | CompVisTimestepsVDenoiser | 42,47 | 42,47 | class CompVisTimestepsVDenoiser(torch.nn.Module):
def __init__(self, model, *args, **kwargs):
super().__init__(*args, **kwargs)
self.inner_model = model
def predict_eps_from_z_and_v(self, x_t, t, v):
return torch.sqrt(self.inner_model.alphas_cumprod)[t.to(torch.int), None, None, None] *... | class CompVisTimestepsVDenoiser(torch.nn.Module):
def __init__(self, model, *args, **kwargs):
super().__init__(*args, **kwargs)
self.inner_model = model
def predict_eps_from_z_and_v(self, x_t, t, v):
return torch.sqrt(self.inner_model.alphas_cumprod)[t.to(torch.int), None, None, None] *... | model_output = self.inner_model.apply_model(input, timesteps, **kwargs)
e_t = self.predict_eps_from_z_and_v(input, timesteps, model_output)
return e_t
| model_output = self.inner_model.apply_model(input, timesteps, **kwargs)
e_t = self.predict_eps_from_z_and_v(input, timesteps, model_output)
return e_t
| 12 | 187 | 68 | 255 | import torch
import inspect
import sys
from modules import devices, sd_samplers_common, sd_samplers_timesteps_impl
from modules.sd_samplers_cfg_denoiser import CFGDenoiser
from modules.script_callbacks import ExtraNoiseParams, extra_noise_callback
from modules.shared import opts
import modules.shared as shared
sample... | import torch
import inspect
import sys
from modules import devices, sd_samplers_common, sd_samplers_timesteps_impl
from modules.sd_samplers_cfg_denoiser import CFGDenoiser
from modules.script_callbacks import ExtraNoiseParams, extra_noise_callback
from modules.shared import opts
import modules.shared as shared
sample... |
327 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_samplers_timesteps_impl.py | 121,122 | 104,129 | model | UniPCCFG | 122,129 | 122,129 | class UniPCCFG(uni_pc.UniPC):
def __init__(self, cfg_model, extra_args, callback, *args, **kwargs):
super().__init__(None, *args, **kwargs)
def after_update(x, model_x):
callback({'x': x, 'i': self.index, 'sigma': 0, 'sigma_hat': 0, 'denoised': model_x})
self.index += 1
... | class UniPCCFG(uni_pc.UniPC):
def __init__(self, cfg_model, extra_args, callback, *args, **kwargs):
super().__init__(None, *args, **kwargs)
def after_update(x, model_x):
callback({'x': x, 'i': self.index, 'sigma': 0, 'sigma_hat': 0, 'denoised': model_x})
self.index += 1
... | t_input = self.get_model_input_time(t)
res = self.cfg_model(x, t_input, **self.extra_args)
return res
| t_input = self.get_model_input_time(t)
res = self.cfg_model(x, t_input, **self.extra_args)
return res
| 10 | 238 | 56 | 294 | import torch
import tqdm
import k_diffusion.sampling
import numpy as np
from modules import shared
from modules.models.diffusion.uni_pc import uni_pc
@torch.no_grad()
def ddim(model, x, timesteps, extra_args=None, callback=None, disable=None, eta=0.0):
alphas_cumprod = model.inner_model.inner_model.alphas_cumpro... | import torch
import tqdm
import k_diffusion.sampling
import numpy as np
from modules import shared
from modules.models.diffusion.uni_pc import uni_pc
@torch.no_grad()
def ddim(model, x, timesteps, extra_args=None, callback=None, disable=None, eta=0.0):
alphas_cumprod = model.inner_model.inner_model.alphas_cumpro... |
328 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_schedulers.py | 23,24 | 1,44 | sgm_uniform | 24,34 | 24,34 | import dataclasses
import torch
import k_diffusion
@dataclasses.dataclass
class Scheduler:
name: str
label: str
function: any
default_rho: float = -1
need_inner_model: bool = False
aliases: list = None
def uniform(n, sigma_min, sigma_max, inner_model, device):
return inner_model.get_s... | import dataclasses
import torch
import k_diffusion
@dataclasses.dataclass
class Scheduler:
name: str
label: str
function: any
default_rho: float = -1
need_inner_model: bool = False
aliases: list = None
def uniform(n, sigma_min, sigma_max, inner_model, device):
return inner_model.get_s... | start = inner_model.sigma_to_t(torch.tensor(sigma_max))
end = inner_model.sigma_to_t(torch.tensor(sigma_min))
sigs = [
inner_model.t_to_sigma(ts)
for ts in torch.linspace(start, end, n + 1)[:-1]
]
sigs += [0.0]
return torch.FloatTensor(sigs).to(device)
| start = inner_model.sigma_to_t(torch.tensor(sigma_max))
end = inner_model.sigma_to_t(torch.tensor(sigma_min))
sigs = [
inner_model.t_to_sigma(ts)
for ts in torch.linspace(start, end, n + 1)[:-1]
]
sigs += [0.0]
return torch.FloatTensor(sigs).to(device)
| 24 | 390 | 130 | 520 | import dataclasses
import torch
import k_diffusion
@dataclasses.dataclass
class Scheduler:
name: str
label: str
function: any
default_rho: float = -1
need_inner_model: bool = False
aliases: list = None
def uniform(n, sigma_min, sigma_max, inner_model, device):
return inner_model.get_s... | import dataclasses
import torch
import k_diffusion
@dataclasses.dataclass
class Scheduler:
name: str
label: str
function: any
default_rho: float = -1
need_inner_model: bool = False
aliases: list = None
def uniform(n, sigma_min, sigma_max, inner_model, device):
return inner_model.get_s... | |
329 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_unet.py | 17,18 | 1,95 | get_unet_option | 18,33 | 18,33 | import torch.nn
from modules import script_callbacks, shared, devices
unet_options = []
current_unet_option = None
current_unet = None
original_forward = None # not used, only left temporarily for compatibility
def list_unets():
new_unets = script_callbacks.list_unets_callback()
unet_options.clear()
un... | import torch.nn
from modules import script_callbacks, shared, devices
unet_options = []
current_unet_option = None
current_unet = None
original_forward = None # not used, only left temporarily for compatibility
def list_unets():
new_unets = script_callbacks.list_unets_callback()
unet_options.clear()
un... | option = option or shared.opts.sd_unet
if option == "None":
return None
if option == "Automatic":
name = shared.sd_model.sd_checkpoint_info.model_name
options = [x for x in unet_options if x.model_name == name]
option = options[0].label if options else "None"
return ... | option = option or shared.opts.sd_unet
if option == "None":
return None
if option == "Automatic":
name = shared.sd_model.sd_checkpoint_info.model_name
options = [x for x in unet_options if x.model_name == name]
option = options[0].label if options else "None"
return ... | 47 | 705 | 139 | 844 | import torch.nn
from modules import script_callbacks, shared, devices
unet_options = []
current_unet_option = None
current_unet = None
original_forward = None # not used, only left temporarily for compatibility
def list_unets():
new_unets = script_callbacks.list_unets_callback()
unet_options.clear()
un... | import torch.nn
from modules import script_callbacks, shared, devices
unet_options = []
current_unet_option = None
current_unet = None
original_forward = None # not used, only left temporarily for compatibility
def list_unets():
new_unets = script_callbacks.list_unets_callback()
unet_options.clear()
un... | |
330 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_unet.py | 76,77 | 75,86 | forward | SdUnet | 77,79 | 77,79 | class SdUnet(torch.nn.Module):
def forward(self, x, timesteps, context, *args, **kwargs):
FILL_FUNC_BODY def activate(self):
pass
def deactivate(self):
pass
| class SdUnet(torch.nn.Module):
def forward(self, x, timesteps, context, *args, **kwargs):
FILL_FUNC_BODY def activate(self):
pass
def deactivate(self):
pass
| raise NotImplementedError()
| raise NotImplementedError()
| 2 | 70 | 12 | 82 | import torch.nn
from modules import script_callbacks, shared, devices
unet_options = []
current_unet_option = None
current_unet = None
original_forward = None # not used, only left temporarily for compatibility
def list_unets():
new_unets = script_callbacks.list_unets_callback()
unet_options.clear()
un... | import torch.nn
from modules import script_callbacks, shared, devices
unet_options = []
current_unet_option = None
current_unet = None
original_forward = None # not used, only left temporarily for compatibility
def list_unets():
new_unets = script_callbacks.list_unets_callback()
unet_options.clear()
un... |
331 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_unet.py | 70,71 | 63,75 | create_unet | SdUnetOption | 72,75 | 71,75 | class SdUnetOption:
model_name = None
"""name of related checkpoint - this option will be selected automatically for unet if the name of checkpoint matches this"""
label = None
"""name of the unet in UI"""
def create_unet(self):
FILL_FUNC_BODY | class SdUnetOption:
model_name = None
"""name of related checkpoint - this option will be selected automatically for unet if the name of checkpoint matches this"""
label = None
"""name of the unet in UI"""
def create_unet(self):
"""returns SdUnet object to be used as a Unet instead of buil... | raise NotImplementedError()
| """returns SdUnet object to be used as a Unet instead of built-in unet when making pictures"""
raise NotImplementedError()
| 2 | 107 | 14 | 121 | import torch.nn
from modules import script_callbacks, shared, devices
unet_options = []
current_unet_option = None
current_unet = None
original_forward = None # not used, only left temporarily for compatibility
def list_unets():
new_unets = script_callbacks.list_unets_callback()
unet_options.clear()
un... | import torch.nn
from modules import script_callbacks, shared, devices
unet_options = []
current_unet_option = None
current_unet = None
original_forward = None # not used, only left temporarily for compatibility
def list_unets():
new_unets = script_callbacks.list_unets_callback()
unet_options.clear()
un... |
333 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_vae.py | 124,125 | 118,128 | tuple | VaeResolution | 125,128 | 125,128 | @dataclass
class VaeResolution:
vae: str = None
source: str = None
resolved: bool = True
def tuple(self):
FILL_FUNC_BODY | @dataclass
class VaeResolution:
vae: str = None
source: str = None
resolved: bool = True
def tuple(self):
FILL_FUNC_BODY | return self.vae, self.source
| return self.vae, self.source
| 3 | 52 | 16 | 68 | import os
import collections
from dataclasses import dataclass
from modules import paths, shared, devices, script_callbacks, sd_models, extra_networks, lowvram, sd_hijack, hashes
import glob
from copy import deepcopy
vae_path = os.path.abspath(os.path.join(paths.models_path, "VAE"))
vae_ignore_keys = {"model_ema.de... | import os
import collections
from dataclasses import dataclass
from modules import paths, shared, devices, script_callbacks, sd_models, extra_networks, lowvram, sd_hijack, hashes
import glob
from copy import deepcopy
vae_path = os.path.abspath(os.path.join(paths.models_path, "VAE"))
vae_ignore_keys = {"model_ema.de... |
334 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_vae_approx.py | 64,65 | 1,87 | cheap_approximation | 65,87 | 65,87 | import os
import torch
from torch import nn
from modules import devices, paths, shared
sd_vae_approx_models = {}
class VAEApprox(nn.Module):
def __init__(self):
super(VAEApprox, self).__init__()
self.conv1 = nn.Conv2d(4, 8, (7, 7))
self.conv2 = nn.Conv2d(8, 16, (5, 5))
self.conv3... | import os
import torch
from torch import nn
from modules import devices, paths, shared
sd_vae_approx_models = {}
class VAEApprox(nn.Module):
def __init__(self):
super(VAEApprox, self).__init__()
self.conv1 = nn.Conv2d(4, 8, (7, 7))
self.conv2 = nn.Conv2d(8, 16, (5, 5))
self.conv3... | # https://discuss.huggingface.co/t/decoding-latents-to-rgb-without-upscaling/23204/2
if shared.sd_model.is_sdxl:
coeffs = [
[ 0.3448, 0.4168, 0.4395],
[-0.1953, -0.0290, 0.0250],
[ 0.1074, 0.0886, -0.0163],
[-0.3730, -0.2499, -0.2088],
]
e... | # https://discuss.huggingface.co/t/decoding-latents-to-rgb-without-upscaling/23204/2
if shared.sd_model.is_sdxl:
coeffs = [
[ 0.3448, 0.4168, 0.4395],
[-0.1953, -0.0290, 0.0250],
[ 0.1074, 0.0886, -0.0163],
[-0.3730, -0.2499, -0.2088],
]
e... | 53 | 937 | 364 | 1,301 | import os
import torch
from torch import nn
from modules import devices, paths, shared
sd_vae_approx_models = {}
class VAEApprox(nn.Module):
def __init__(self):
super(VAEApprox, self).__init__()
self.conv1 = nn.Conv2d(4, 8, (7, 7))
self.conv2 = nn.Conv2d(8, 16, (5, 5))
self.conv3... | import os
import torch
from torch import nn
from modules import devices, paths, shared
sd_vae_approx_models = {}
class VAEApprox(nn.Module):
def __init__(self):
super(VAEApprox, self).__init__()
self.conv1 = nn.Conv2d(4, 8, (7, 7))
self.conv2 = nn.Conv2d(8, 16, (5, 5))
self.conv3... | |
335 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_vae_approx.py | 22,23 | 10,34 | forward | VAEApprox | 23,34 | 23,34 | class VAEApprox(nn.Module):
def __init__(self):
super(VAEApprox, self).__init__()
self.conv1 = nn.Conv2d(4, 8, (7, 7))
self.conv2 = nn.Conv2d(8, 16, (5, 5))
self.conv3 = nn.Conv2d(16, 32, (3, 3))
self.conv4 = nn.Conv2d(32, 64, (3, 3))
self.conv5 = nn.Conv2d(64, 32, (3... | class VAEApprox(nn.Module):
def __init__(self):
super(VAEApprox, self).__init__()
self.conv1 = nn.Conv2d(4, 8, (7, 7))
self.conv2 = nn.Conv2d(8, 16, (5, 5))
self.conv3 = nn.Conv2d(16, 32, (3, 3))
self.conv4 = nn.Conv2d(32, 64, (3, 3))
self.conv5 = nn.Conv2d(64, 32, (3... | extra = 11
x = nn.functional.interpolate(x, (x.shape[2] * 2, x.shape[3] * 2))
x = nn.functional.pad(x, (extra, extra, extra, extra))
for layer in [self.conv1, self.conv2, self.conv3, self.conv4, self.conv5, self.conv6, self.conv7, self.conv8, ]:
x = layer(x)
x = ... | extra = 11
x = nn.functional.interpolate(x, (x.shape[2] * 2, x.shape[3] * 2))
x = nn.functional.pad(x, (extra, extra, extra, extra))
for layer in [self.conv1, self.conv2, self.conv3, self.conv4, self.conv5, self.conv6, self.conv7, self.conv8, ]:
x = layer(x)
x = ... | 40 | 274 | 164 | 438 | import os
import torch
from torch import nn
from modules import devices, paths, shared
sd_vae_approx_models = {}
class VAEApprox(nn.Module):
def __init__(self):
super(VAEApprox, self).__init__()
self.conv1 = nn.Conv2d(4, 8, (7, 7))
self.conv2 = nn.Conv2d(8, 16, (5, 5))
self.conv3... | import os
import torch
from torch import nn
from modules import devices, paths, shared
sd_vae_approx_models = {}
class VAEApprox(nn.Module):
def __init__(self):
super(VAEApprox, self).__init__()
self.conv1 = nn.Conv2d(4, 8, (7, 7))
self.conv2 = nn.Conv2d(8, 16, (5, 5))
self.conv3... |
336 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_vae_taesd.py | 89,90 | 1,125 | decoder_model | 90,108 | 90,108 | """
Tiny AutoEncoder for Stable Diffusion
(DNN for encoding / decoding SD's latent space)
https://github.com/madebyollin/taesd
"""
import os
import torch
import torch.nn as nn
from modules import devices, paths_internal, shared
sd_vae_taesd_models = {}
def conv(n_in, n_out, **kwargs):
return nn.Conv2d(n_in, n_... | """
Tiny AutoEncoder for Stable Diffusion
(DNN for encoding / decoding SD's latent space)
https://github.com/madebyollin/taesd
"""
import os
import torch
import torch.nn as nn
from modules import devices, paths_internal, shared
sd_vae_taesd_models = {}
def conv(n_in, n_out, **kwargs):
return nn.Conv2d(n_in, n_... | model_name = "taesdxl_decoder.pth" if getattr(shared.sd_model, 'is_sdxl', False) else "taesd_decoder.pth"
loaded_model = sd_vae_taesd_models.get(model_name)
if loaded_model is None:
model_path = os.path.join(paths_internal.models_path, "VAE-taesd", model_name)
download_model(model_path, 'ht... | model_name = "taesdxl_decoder.pth" if getattr(shared.sd_model, 'is_sdxl', False) else "taesd_decoder.pth"
loaded_model = sd_vae_taesd_models.get(model_name)
if loaded_model is None:
model_path = os.path.join(paths_internal.models_path, "VAE-taesd", model_name)
download_model(model_path, 'ht... | 44 | 1,438 | 277 | 1,715 | """
Tiny AutoEncoder for Stable Diffusion
(DNN for encoding / decoding SD's latent space)
https://github.com/madebyollin/taesd
"""
import os
import torch
import torch.nn as nn
from modules import devices, paths_internal, shared
sd_vae_taesd_models = {}
def conv(n_in, n_out, **kwargs):
return nn.Conv2d(n_in, n_... | """
Tiny AutoEncoder for Stable Diffusion
(DNN for encoding / decoding SD's latent space)
https://github.com/madebyollin/taesd
"""
import os
import torch
import torch.nn as nn
from modules import devices, paths_internal, shared
sd_vae_taesd_models = {}
def conv(n_in, n_out, **kwargs):
return nn.Conv2d(n_in, n_... | |
337 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_vae_taesd.py | 33,34 | 26,37 | forward | Block | 34,37 | 34,37 | class Block(nn.Module):
def __init__(self, n_in, n_out):
super().__init__()
self.conv = nn.Sequential(conv(n_in, n_out), nn.ReLU(), conv(n_out, n_out), nn.ReLU(), conv(n_out, n_out))
self.skip = nn.Conv2d(n_in, n_out, 1, bias=False) if n_in != n_out else nn.Identity()
self.fuse = nn.... | class Block(nn.Module):
def __init__(self, n_in, n_out):
super().__init__()
self.conv = nn.Sequential(conv(n_in, n_out), nn.ReLU(), conv(n_out, n_out), nn.ReLU(), conv(n_out, n_out))
self.skip = nn.Conv2d(n_in, n_out, 1, bias=False) if n_in != n_out else nn.Identity()
self.fuse = nn.... | return self.fuse(self.conv(x) + self.skip(x))
| return self.fuse(self.conv(x) + self.skip(x))
| 4 | 167 | 26 | 193 | """
Tiny AutoEncoder for Stable Diffusion
(DNN for encoding / decoding SD's latent space)
https://github.com/madebyollin/taesd
"""
import os
import torch
import torch.nn as nn
from modules import devices, paths_internal, shared
sd_vae_taesd_models = {}
def conv(n_in, n_out, **kwargs):
return nn.Conv2d(n_in, n_... | """
Tiny AutoEncoder for Stable Diffusion
(DNN for encoding / decoding SD's latent space)
https://github.com/madebyollin/taesd
"""
import os
import torch
import torch.nn as nn
from modules import devices, paths_internal, shared
sd_vae_taesd_models = {}
def conv(n_in, n_out, **kwargs):
return nn.Conv2d(n_in, n_... |
338 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sd_vae_taesd.py | 21,23 | 20,26 | forward | Clamp | 23,26 | 23,26 | class Clamp(nn.Module):
@staticmethod
def forward(x):
FILL_FUNC_BODY | class Clamp(nn.Module):
@staticmethod
def forward(x):
FILL_FUNC_BODY | return torch.tanh(x / 3) * 3
| return torch.tanh(x / 3) * 3
| 6 | 31 | 22 | 53 | """
Tiny AutoEncoder for Stable Diffusion
(DNN for encoding / decoding SD's latent space)
https://github.com/madebyollin/taesd
"""
import os
import torch
import torch.nn as nn
from modules import devices, paths_internal, shared
sd_vae_taesd_models = {}
def conv(n_in, n_out, **kwargs):
return nn.Conv2d(n_in, n_... | """
Tiny AutoEncoder for Stable Diffusion
(DNN for encoding / decoding SD's latent space)
https://github.com/madebyollin/taesd
"""
import os
import torch
import torch.nn as nn
from modules import devices, paths_internal, shared
sd_vae_taesd_models = {}
def conv(n_in, n_out, **kwargs):
return nn.Conv2d(n_in, n_... |
339 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/shared_gradio_themes.py | 44,45 | 1,72 | reload_gradio_theme | 45,72 | 45,72 | import os
import gradio as gr
from modules import errors, shared
from modules.paths_internal import script_path
# https://huggingface.co/datasets/freddyaboulton/gradio-theme-subdomains/resolve/main/subdomains.json
gradio_hf_hub_themes = [
"gradio/base",
"gradio/glass",
"gradio/monochrome",
"gradio/s... | import os
import gradio as gr
from modules import errors, shared
from modules.paths_internal import script_path
# https://huggingface.co/datasets/freddyaboulton/gradio-theme-subdomains/resolve/main/subdomains.json
gradio_hf_hub_themes = [
"gradio/base",
"gradio/glass",
"gradio/monochrome",
"gradio/s... | if not theme_name:
theme_name = shared.opts.gradio_theme
default_theme_args = dict(
font=["Source Sans Pro", 'ui-sans-serif', 'system-ui', 'sans-serif'],
font_mono=['IBM Plex Mono', 'ui-monospace', 'Consolas', 'monospace'],
)
if theme_name == "Default":
shared.gradio_th... | if not theme_name:
theme_name = shared.opts.gradio_theme
default_theme_args = dict(
font=["Source Sans Pro", 'ui-sans-serif', 'system-ui', 'sans-serif'],
font_mono=['IBM Plex Mono', 'ui-monospace', 'Consolas', 'monospace'],
)
if theme_name == "Default":
shared.gradio_th... | 77 | 466 | 494 | 960 | import os
import gradio as gr
from modules import errors, shared
from modules.paths_internal import script_path
# https://huggingface.co/datasets/freddyaboulton/gradio-theme-subdomains/resolve/main/subdomains.json
gradio_hf_hub_themes = [
"gradio/base",
"gradio/glass",
"gradio/monochrome",
"gradio/s... | import os
import gradio as gr
from modules import errors, shared
from modules.paths_internal import script_path
# https://huggingface.co/datasets/freddyaboulton/gradio-theme-subdomains/resolve/main/subdomains.json
gradio_hf_hub_themes = [
"gradio/base",
"gradio/glass",
"gradio/monochrome",
"gradio/s... | |
340 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/shared_init.py | 9,10 | 1,53 | initialize | 14,53 | 10,53 | import os
import torch
from modules import shared
from modules.shared import cmd_opts
def initialize():
FILL_FUNC_BODY | import os
import torch
from modules import shared
from modules.shared import cmd_opts
def initialize():
"""Initializes fields inside the shared module in a controlled manner.
Should be called early because some other modules you can import mingt need these fields to be already set.
"""
FILL_FUNC_BODY |
os.makedirs(cmd_opts.hypernetwork_dir, exist_ok=True)
from modules import options, shared_options
shared.options_templates = shared_options.options_templates
shared.opts = options.Options(shared_options.options_templates, shared_options.restricted_opts)
shared.restricted_opts = shared_options.rest... | """Initializes fields inside the shared module in a controlled manner.
Should be called early because some other modules you can import mingt need these fields to be already set.
"""
os.makedirs(cmd_opts.hypernetwork_dir, exist_ok=True)
from modules import options, shared_options
shared.optio... | 127 | 81 | 563 | 644 | import os
import torch
from modules import shared
from modules.shared import cmd_opts
def initialize():
FILL_FUNC_BODY | import os
import torch
from modules import shared
from modules.shared import cmd_opts
def initialize():
"""Initializes fields inside the shared module in a controlled manner.
Should be called early because some other modules you can import mingt need these fields to be already set.
"""
FILL_FUNC_BODY | |
341 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/shared_items.py | 49,50 | 1,185 | refresh_unet_list | 50,55 | 50,55 | import html
import sys
from modules import script_callbacks, scripts, ui_components
from modules.options import OptionHTML, OptionInfo
from modules.shared_cmd_options import cmd_opts
def realesrgan_models_names():
import modules.realesrgan_model
return [x.name for x in modules.realesrgan_model.get_realesrgan... | import html
import sys
from modules import script_callbacks, scripts, ui_components
from modules.options import OptionHTML, OptionInfo
from modules.shared_cmd_options import cmd_opts
def realesrgan_models_names():
import modules.realesrgan_model
return [x.name for x in modules.realesrgan_model.get_realesrgan... | import modules.sd_unet
modules.sd_unet.list_unets()
| import modules.sd_unet
modules.sd_unet.list_unets()
| 3 | 1,540 | 31 | 1,571 | import html
import sys
from modules import script_callbacks, scripts, ui_components
from modules.options import OptionHTML, OptionInfo
from modules.shared_cmd_options import cmd_opts
def realesrgan_models_names():
import modules.realesrgan_model
return [x.name for x in modules.realesrgan_model.get_realesrgan... | import html
import sys
from modules import script_callbacks, scripts, ui_components
from modules.options import OptionHTML, OptionInfo
from modules.shared_cmd_options import cmd_opts
def realesrgan_models_names():
import modules.realesrgan_model
return [x.name for x in modules.realesrgan_model.get_realesrgan... | |
342 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/shared_items.py | 171,173 | 163,184 | sd_model | Shared | 173,177 | 173,177 | class Shared(sys.modules[__name__].__class__):
"""
this class is here to provide sd_model field as a property, so that it can be created and loaded on demand rather than
at program startup.
"""
sd_model_val = None
@property
def sd_model(self):
FILL_FUNC_BODY @sd_model.setter
def sd_... | class Shared(sys.modules[__name__].__class__):
"""
this class is here to provide sd_model field as a property, so that it can be created and loaded on demand rather than
at program startup.
"""
sd_model_val = None
@property
def sd_model(self):
FILL_FUNC_BODY @sd_model.setter
def sd_... | import modules.sd_models
return modules.sd_models.model_data.get_sd_model()
| import modules.sd_models
return modules.sd_models.model_data.get_sd_model()
| 4 | 146 | 33 | 179 | import html
import sys
from modules import script_callbacks, scripts, ui_components
from modules.options import OptionHTML, OptionInfo
from modules.shared_cmd_options import cmd_opts
def realesrgan_models_names():
import modules.realesrgan_model
return [x.name for x in modules.realesrgan_model.get_realesrgan... | import html
import sys
from modules import script_callbacks, scripts, ui_components
from modules.options import OptionHTML, OptionInfo
from modules.shared_cmd_options import cmd_opts
def realesrgan_models_names():
import modules.realesrgan_model
return [x.name for x in modules.realesrgan_model.get_realesrgan... |
343 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/shared_state.py | 137,138 | 12,169 | set_current_image | State | 139,145 | 138,145 | class State:
skipped = False
interrupted = False
stopping_generation = False
job = ""
job_no = 0
job_count = 0
processing_has_refined_job_count = False
job_timestamp = '0'
sampling_step = 0
sampling_steps = 0
current_latent = None
current_image = None
current_image_sa... | class State:
skipped = False
interrupted = False
stopping_generation = False
job = ""
job_no = 0
job_count = 0
processing_has_refined_job_count = False
job_timestamp = '0'
sampling_step = 0
sampling_steps = 0
current_latent = None
current_image = None
current_image_sa... | if not shared.parallel_processing_allowed:
return
if self.sampling_step - self.current_image_sampling_step >= shared.opts.show_progress_every_n_steps and shared.opts.live_previews_enable and shared.opts.show_progress_every_n_steps != -1:
self.do_set_current_image()
| """if enough sampling steps have been made after the last call to this, sets self.current_image from self.current_latent, and modifies self.id_live_preview accordingly"""
if not shared.parallel_processing_allowed:
return
if self.sampling_step - self.current_image_sampling_step >= sh... | 17 | 1,471 | 99 | 1,570 | import datetime
import logging
import threading
import time
from modules import errors, shared, devices
from typing import Optional
log = logging.getLogger(__name__)
class State:
skipped = False
interrupted = False
stopping_generation = False
job = ""
job_no = 0
job_count = 0
processing_... | import datetime
import logging
import threading
import time
from modules import errors, shared, devices
from typing import Optional
log = logging.getLogger(__name__)
class State:
skipped = False
interrupted = False
stopping_generation = False
job = ""
job_no = 0
job_count = 0
processing_... |
344 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/shared_total_tqdm.py | 25,26 | 6,38 | updateTotal | TotalTQDM | 26,32 | 26,32 | class TotalTQDM:
def __init__(self):
self._tqdm = None
def reset(self):
self._tqdm = tqdm.tqdm(
desc="Total progress",
total=shared.state.job_count * shared.state.sampling_steps,
position=1,
file=shared.progress_print_out
)
def update... | class TotalTQDM:
def __init__(self):
self._tqdm = None
def reset(self):
self._tqdm = tqdm.tqdm(
desc="Total progress",
total=shared.state.job_count * shared.state.sampling_steps,
position=1,
file=shared.progress_print_out
)
def update... | if not shared.opts.multiple_tqdm or shared.cmd_opts.disable_console_progressbars:
return
if self._tqdm is None:
self.reset()
self._tqdm.total = new_total
| if not shared.opts.multiple_tqdm or shared.cmd_opts.disable_console_progressbars:
return
if self._tqdm is None:
self.reset()
self._tqdm.total = new_total
| 14 | 236 | 68 | 304 | import tqdm
from modules import shared
class TotalTQDM:
def __init__(self):
self._tqdm = None
def reset(self):
self._tqdm = tqdm.tqdm(
desc="Total progress",
total=shared.state.job_count * shared.state.sampling_steps,
position=1,
file=shared.pr... | import tqdm
from modules import shared
class TotalTQDM:
def __init__(self):
self._tqdm = None
def reset(self):
self._tqdm = tqdm.tqdm(
desc="Total progress",
total=shared.state.job_count * shared.state.sampling_steps,
position=1,
file=shared.pr... |
346 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/styles.py | 101,102 | 82,235 | reload | StyleDatabase | 106,132 | 102,132 | class StyleDatabase:
def __init__(self, paths: list[str | Path]):
self.no_style = PromptStyle("None", "", "", None)
self.styles = {}
self.paths = paths
self.all_styles_files: list[Path] = []
folder, file = os.path.split(self.paths[0])
if '*' in file or '?' in file:
... | class StyleDatabase:
def __init__(self, paths: list[str | Path]):
self.no_style = PromptStyle("None", "", "", None)
self.styles = {}
self.paths = paths
self.all_styles_files: list[Path] = []
folder, file = os.path.split(self.paths[0])
if '*' in file or '?' in file:
... | self.styles.clear()
# scans for all styles files
all_styles_files = []
for pattern in self.paths:
folder, file = os.path.split(pattern)
if '*' in file or '?' in file:
found_files = Path(folder).glob(file)
[all_styles_files.append(f... | """
Clears the style database and reloads the styles from the CSV file(s)
matching the path used to initialize the database.
"""
self.styles.clear()
# scans for all styles files
all_styles_files = []
for pattern in self.paths:
folder, file = o... | 96 | 1,455 | 336 | 1,791 | from __future__ import annotations
from pathlib import Path
from modules import errors
import csv
import os
import typing
import shutil
class PromptStyle(typing.NamedTuple):
name: str
prompt: str | None
negative_prompt: str | None
path: str | None = None
def merge_prompts(style_prompt: str, prompt: ... | from __future__ import annotations
from pathlib import Path
from modules import errors
import csv
import os
import typing
import shutil
class PromptStyle(typing.NamedTuple):
name: str
prompt: str | None
negative_prompt: str | None
path: str | None = None
def merge_prompts(style_prompt: str, prompt: ... |
348 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/sysinfo.py | 61,62 | 1,161 | check | 62,72 | 62,72 | import json
import os
import sys
import platform
import hashlib
import pkg_resources
import psutil
import re
import launch
from modules import paths_internal, timer, shared, extensions, errors
checksum_token = "DontStealMyGamePlz__WINNERS_DONT_USE_DRUGS__DONT_COPY_THAT_FLOPPY"
environment_whitelist = {
"GIT",
... | import json
import os
import sys
import platform
import hashlib
import pkg_resources
import psutil
import re
import launch
from modules import paths_internal, timer, shared, extensions, errors
checksum_token = "DontStealMyGamePlz__WINNERS_DONT_USE_DRUGS__DONT_COPY_THAT_FLOPPY"
environment_whitelist = {
"GIT",
... | m = re.search(re_checksum, x)
if not m:
return False
replaced = re.sub(re_checksum, f'"Checksum": "{checksum_token}"', x)
h = hashlib.sha256(replaced.encode("utf8"))
return h.hexdigest() == m.group(1)
| m = re.search(re_checksum, x)
if not m:
return False
replaced = re.sub(re_checksum, f'"Checksum": "{checksum_token}"', x)
h = hashlib.sha256(replaced.encode("utf8"))
return h.hexdigest() == m.group(1)
| 22 | 1,412 | 107 | 1,519 | import json
import os
import sys
import platform
import hashlib
import pkg_resources
import psutil
import re
import launch
from modules import paths_internal, timer, shared, extensions, errors
checksum_token = "DontStealMyGamePlz__WINNERS_DONT_USE_DRUGS__DONT_COPY_THAT_FLOPPY"
environment_whitelist = {
"GIT",
... | import json
import os
import sys
import platform
import hashlib
import pkg_resources
import psutil
import re
import launch
from modules import paths_internal, timer, shared, extensions, errors
checksum_token = "DontStealMyGamePlz__WINNERS_DONT_USE_DRUGS__DONT_COPY_THAT_FLOPPY"
environment_whitelist = {
"GIT",
... | |
350 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/textual_inversion/autocrop.py | 327,328 | 320,336 | bounding | PointOfInterest | 328,336 | 328,336 | class PointOfInterest:
def __init__(self, x, y, weight=1.0, size=10):
self.x = x
self.y = y
self.weight = weight
self.size = size
def bounding(self, size):
FILL_FUNC_BODY | class PointOfInterest:
def __init__(self, x, y, weight=1.0, size=10):
self.x = x
self.y = y
self.weight = weight
self.size = size
def bounding(self, size):
FILL_FUNC_BODY | return [
self.x - size // 2,
self.y - size // 2,
self.x + size // 2,
self.y + size // 2
]
| return [
self.x - size // 2,
self.y - size // 2,
self.x + size // 2,
self.y + size // 2
]
| 23 | 78 | 60 | 138 | import cv2
import requests
import os
import numpy as np
from PIL import ImageDraw
from modules import paths_internal
from pkg_resources import parse_version
GREEN = "#0F0"
BLUE = "#00F"
RED = "#F00"
def crop_image(im, settings):
""" Intelligently crop an image to the subject matter """
scale_by = 1
if i... | import cv2
import requests
import os
import numpy as np
from PIL import ImageDraw
from modules import paths_internal
from pkg_resources import parse_version
GREEN = "#0F0"
BLUE = "#00F"
RED = "#F00"
def crop_image(im, settings):
""" Intelligently crop an image to the subject matter """
scale_by = 1
if i... |
352 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/textual_inversion/dataset.py | 230,231 | 218,234 | pin_memory | BatchLoader | 231,234 | 231,234 | class BatchLoader:
def __init__(self, data):
self.cond_text = [entry.cond_text for entry in data]
self.cond = [entry.cond for entry in data]
self.latent_sample = torch.stack([entry.latent_sample for entry in data]).squeeze(1)
if all(entry.weight is not None for entry in data):
... | class BatchLoader:
def __init__(self, data):
self.cond_text = [entry.cond_text for entry in data]
self.cond = [entry.cond for entry in data]
self.latent_sample = torch.stack([entry.latent_sample for entry in data]).squeeze(1)
if all(entry.weight is not None for entry in data):
... | self.latent_sample = self.latent_sample.pin_memory()
return self
| self.latent_sample = self.latent_sample.pin_memory()
return self
| 5 | 189 | 28 | 217 | import os
import numpy as np
import PIL
import torch
from torch.utils.data import Dataset, DataLoader, Sampler
from torchvision import transforms
from collections import defaultdict
from random import shuffle, choices
import random
import tqdm
from modules import devices, shared, images
import re
from ldm.modules.dis... | import os
import numpy as np
import PIL
import torch
from torch.utils.data import Dataset, DataLoader, Sampler
from torchvision import transforms
from collections import defaultdict
from random import shuffle, choices
import random
import tqdm
from modules import devices, shared, images
import re
from ldm.modules.dis... |
353 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/textual_inversion/dataset.py | 241,242 | 237,244 | pin_memory | BatchLoaderRandom | 242,244 | 242,244 | class BatchLoaderRandom(BatchLoader):
def __init__(self, data):
super().__init__(data)
def pin_memory(self):
FILL_FUNC_BODY | class BatchLoaderRandom(BatchLoader):
def __init__(self, data):
super().__init__(data)
def pin_memory(self):
FILL_FUNC_BODY | return self
| return self
| 2 | 49 | 7 | 56 | import os
import numpy as np
import PIL
import torch
from torch.utils.data import Dataset, DataLoader, Sampler
from torchvision import transforms
from collections import defaultdict
from random import shuffle, choices
import random
import tqdm
from modules import devices, shared, images
import re
from ldm.modules.dis... | import os
import numpy as np
import PIL
import torch
from torch.utils.data import Dataset, DataLoader, Sampler
from torchvision import transforms
from collections import defaultdict
from random import shuffle, choices
import random
import tqdm
from modules import devices, shared, images
import re
from ldm.modules.dis... |
354 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/textual_inversion/dataset.py | 152,153 | 32,175 | create_text | PersonalizedBase | 153,163 | 153,163 | class PersonalizedBase(Dataset):
def __init__(self, data_root, width, height, repeats, flip_p=0.5, placeholder_token="*", model=None, cond_model=None, device=None, template_file=None, include_cond=False, batch_size=1, gradient_step=1, shuffle_tags=False, tag_drop_out=0, latent_sampling_method='once', varsize=False,... | class PersonalizedBase(Dataset):
def __init__(self, data_root, width, height, repeats, flip_p=0.5, placeholder_token="*", model=None, cond_model=None, device=None, template_file=None, include_cond=False, batch_size=1, gradient_step=1, shuffle_tags=False, tag_drop_out=0, latent_sampling_method='once', varsize=False,... | text = random.choice(self.lines)
tags = filename_text.split(',')
if self.tag_drop_out != 0:
tags = [t for t in tags if random.random() > self.tag_drop_out]
if self.shuffle_tags:
random.shuffle(tags)
text = text.replace("[filewords]", ','.join(tags))
... | text = random.choice(self.lines)
tags = filename_text.split(',')
if self.tag_drop_out != 0:
tags = [t for t in tags if random.random() > self.tag_drop_out]
if self.shuffle_tags:
random.shuffle(tags)
text = text.replace("[filewords]", ','.join(tags))
... | 34 | 1,778 | 135 | 1,913 | import os
import numpy as np
import PIL
import torch
from torch.utils.data import Dataset, DataLoader, Sampler
from torchvision import transforms
from collections import defaultdict
from random import shuffle, choices
import random
import tqdm
from modules import devices, shared, images
import re
from ldm.modules.dis... | import os
import numpy as np
import PIL
import torch
from torch.utils.data import Dataset, DataLoader, Sampler
from torchvision import transforms
from collections import defaultdict
from random import shuffle, choices
import random
import tqdm
from modules import devices, shared, images
import re
from ldm.modules.dis... |
356 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/textual_inversion/image_embedding.py | 26,27 | 22,32 | object_hook | EmbeddingDecoder | 27,32 | 27,32 | class EmbeddingDecoder(json.JSONDecoder):
def __init__(self, *args, **kwargs):
json.JSONDecoder.__init__(self, *args, object_hook=self.object_hook, **kwargs)
def object_hook(self, d):
FILL_FUNC_BODY | class EmbeddingDecoder(json.JSONDecoder):
def __init__(self, *args, **kwargs):
json.JSONDecoder.__init__(self, *args, object_hook=self.object_hook, **kwargs)
def object_hook(self, d):
FILL_FUNC_BODY | if 'TORCHTENSOR' in d:
return torch.from_numpy(np.array(d['TORCHTENSOR']))
return d
| if 'TORCHTENSOR' in d:
return torch.from_numpy(np.array(d['TORCHTENSOR']))
return d
| 8 | 77 | 51 | 128 | import base64
import json
import os.path
import warnings
import logging
import numpy as np
import zlib
from PIL import Image, ImageDraw
import torch
logger = logging.getLogger(__name__)
class EmbeddingEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, torch.Tensor):
return... | import base64
import json
import os.path
import warnings
import logging
import numpy as np
import zlib
from PIL import Image, ImageDraw
import torch
logger = logging.getLogger(__name__)
class EmbeddingEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, torch.Tensor):
return... |
357 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/textual_inversion/image_embedding.py | 16,17 | 15,22 | default | EmbeddingEncoder | 17,22 | 17,22 | class EmbeddingEncoder(json.JSONEncoder):
def default(self, obj):
FILL_FUNC_BODY | class EmbeddingEncoder(json.JSONEncoder):
def default(self, obj):
FILL_FUNC_BODY | if isinstance(obj, torch.Tensor):
return {'TORCHTENSOR': obj.cpu().detach().numpy().tolist()}
return json.JSONEncoder.default(self, obj)
| if isinstance(obj, torch.Tensor):
return {'TORCHTENSOR': obj.cpu().detach().numpy().tolist()}
return json.JSONEncoder.default(self, obj)
| 9 | 32 | 63 | 95 | import base64
import json
import os.path
import warnings
import logging
import numpy as np
import zlib
from PIL import Image, ImageDraw
import torch
logger = logging.getLogger(__name__)
class EmbeddingEncoder(json.JSONEncoder):
def default(self, obj):
FILL_FUNC_BODYclass EmbeddingDecoder(json.JSONDecoder):
... | import base64
import json
import os.path
import warnings
import logging
import numpy as np
import zlib
from PIL import Image, ImageDraw
import torch
logger = logging.getLogger(__name__)
class EmbeddingEncoder(json.JSONEncoder):
def default(self, obj):
FILL_FUNC_BODYclass EmbeddingDecoder(json.JSONDecoder):
... |
358 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/textual_inversion/learn_schedule.py | 61,62 | 50,82 | step | LearnRateScheduler | 62,72 | 62,72 | class LearnRateScheduler:
def __init__(self, learn_rate, max_steps, cur_step=0, verbose=True):
self.schedules = LearnScheduleIterator(learn_rate, max_steps, cur_step)
(self.learn_rate, self.end_step) = next(self.schedules)
self.verbose = verbose
if self.verbose:
print(f... | class LearnRateScheduler:
def __init__(self, learn_rate, max_steps, cur_step=0, verbose=True):
self.schedules = LearnScheduleIterator(learn_rate, max_steps, cur_step)
(self.learn_rate, self.end_step) = next(self.schedules)
self.verbose = verbose
if self.verbose:
print(f... | if step_number < self.end_step:
return False
try:
(self.learn_rate, self.end_step) = next(self.schedules)
except StopIteration:
self.finished = True
return False
return True
| if step_number < self.end_step:
return False
try:
(self.learn_rate, self.end_step) = next(self.schedules)
except StopIteration:
self.finished = True
return False
return True
| 20 | 259 | 78 | 337 | import tqdm
class LearnScheduleIterator:
def __init__(self, learn_rate, max_steps, cur_step=0):
"""
specify learn_rate as "0.001:100, 0.00001:1000, 1e-5:10000" to have lr of 0.001 until step 100, 0.00001 until 1000, and 1e-5 until 10000
"""
pairs = learn_rate.split(',')
se... | import tqdm
class LearnScheduleIterator:
def __init__(self, learn_rate, max_steps, cur_step=0):
"""
specify learn_rate as "0.001:100, 0.00001:1000, 1e-5:10000" to have lr of 0.001 until step 100, 0.00001 until 1000, and 1e-5 until 10000
"""
pairs = learn_rate.split(',')
se... |
359 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/textual_inversion/saving_settings.py | 52,53 | 1,65 | save_settings_to_file | 53,65 | 53,65 | import datetime
import json
import os
saved_params_shared = {
"batch_size",
"clip_grad_mode",
"clip_grad_value",
"create_image_every",
"data_root",
"gradient_step",
"initial_step",
"latent_sampling_method",
"learn_rate",
"log_directory",
"model_hash",
"model_name",
"... | import datetime
import json
import os
saved_params_shared = {
"batch_size",
"clip_grad_mode",
"clip_grad_value",
"create_image_every",
"data_root",
"gradient_step",
"initial_step",
"latent_sampling_method",
"learn_rate",
"log_directory",
"model_hash",
"model_name",
"... | now = datetime.datetime.now()
params = {"datetime": now.strftime("%Y-%m-%d %H:%M:%S")}
keys = saved_params_all
if all_params.get('preview_from_txt2img'):
keys = keys | saved_params_previews
params.update({k: v for k, v in all_params.items() if k in keys})
filename = f'settings-{now.st... | now = datetime.datetime.now()
params = {"datetime": now.strftime("%Y-%m-%d %H:%M:%S")}
keys = saved_params_all
if all_params.get('preview_from_txt2img'):
keys = keys | saved_params_previews
params.update({k: v for k, v in all_params.items() if k in keys})
filename = f'settings-{now.st... | 41 | 418 | 193 | 611 | import datetime
import json
import os
saved_params_shared = {
"batch_size",
"clip_grad_mode",
"clip_grad_value",
"create_image_every",
"data_root",
"gradient_step",
"initial_step",
"latent_sampling_method",
"learn_rate",
"log_directory",
"model_hash",
"model_name",
"... | import datetime
import json
import os
saved_params_shared = {
"batch_size",
"clip_grad_mode",
"clip_grad_value",
"create_image_every",
"data_root",
"gradient_step",
"initial_step",
"latent_sampling_method",
"learn_rate",
"log_directory",
"model_hash",
"model_name",
"... | |
360 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/textual_inversion/ui.py | 17,18 | 1,39 | train_embedding | 18,39 | 18,39 | import html
import gradio as gr
import modules.textual_inversion.textual_inversion
from modules import sd_hijack, shared
def create_embedding(name, initialization_text, nvpt, overwrite_old):
filename = modules.textual_inversion.textual_inversion.create_embedding(name, nvpt, overwrite_old, init_text=initializati... | import html
import gradio as gr
import modules.textual_inversion.textual_inversion
from modules import sd_hijack, shared
def create_embedding(name, initialization_text, nvpt, overwrite_old):
filename = modules.textual_inversion.textual_inversion.create_embedding(name, nvpt, overwrite_old, init_text=initializati... |
assert not shared.cmd_opts.lowvram, 'Training models with lowvram not possible'
apply_optimizations = shared.opts.training_xattention_optimizations
try:
if not apply_optimizations:
sd_hijack.undo_optimizations()
embedding, filename = modules.textual_inversion.textual_inversion... |
assert not shared.cmd_opts.lowvram, 'Training models with lowvram not possible'
apply_optimizations = shared.opts.training_xattention_optimizations
try:
if not apply_optimizations:
sd_hijack.undo_optimizations()
embedding, filename = modules.textual_inversion.textual_inversion... | 49 | 209 | 212 | 421 | import html
import gradio as gr
import modules.textual_inversion.textual_inversion
from modules import sd_hijack, shared
def create_embedding(name, initialization_text, nvpt, overwrite_old):
filename = modules.textual_inversion.textual_inversion.create_embedding(name, nvpt, overwrite_old, init_text=initializati... | import html
import gradio as gr
import modules.textual_inversion.textual_inversion
from modules import sd_hijack, shared
def create_embedding(name, initialization_text, nvpt, overwrite_old):
filename = modules.textual_inversion.textual_inversion.create_embedding(name, nvpt, overwrite_old, init_text=initializati... | |
361 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/timer.py | 49,50 | 28,85 | record | Timer | 50,59 | 50,59 | class Timer:
def __init__(self, print_log=False):
self.start = time.time()
self.records = {}
self.total = 0
self.base_category = ''
self.print_log = print_log
self.subcategory_level = 0
def elapsed(self):
end = time.time()
res = end - self.start
... | class Timer:
def __init__(self, print_log=False):
self.start = time.time()
self.records = {}
self.total = 0
self.base_category = ''
self.print_log = print_log
self.subcategory_level = 0
def elapsed(self):
end = time.time()
res = end - self.start
... | e = self.elapsed()
self.add_time_to_record(self.base_category + category, e + extra_time)
self.total += e + extra_time
if self.print_log and not disable_log:
print(f"{' ' * self.subcategory_level}{category}: done in {e + extra_time:.3f}s")
| e = self.elapsed()
self.add_time_to_record(self.base_category + category, e + extra_time)
self.total += e + extra_time
if self.print_log and not disable_log:
print(f"{' ' * self.subcategory_level}{category}: done in {e + extra_time:.3f}s")
| 28 | 405 | 106 | 511 | import time
import argparse
class TimerSubcategory:
def __init__(self, timer, category):
self.timer = timer
self.category = category
self.start = None
self.original_base_category = timer.base_category
def __enter__(self):
self.start = time.time()
self.timer.bas... | import time
import argparse
class TimerSubcategory:
def __init__(self, timer, category):
self.timer = timer
self.category = category
self.start = None
self.original_base_category = timer.base_category
def __enter__(self):
self.start = time.time()
self.timer.bas... |
362 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/torch_utils.py | 6,7 | 1,18 | get_param | 10,18 | 7,18 | from __future__ import annotations
import torch.nn
def get_param(model) -> torch.nn.Parameter:
FILL_FUNC_BODY | from __future__ import annotations
import torch.nn
def get_param(model) -> torch.nn.Parameter:
"""
Find the first parameter in a model or module.
"""
FILL_FUNC_BODY | if hasattr(model, "model") and hasattr(model.model, "parameters"):
# Unpeel a model descriptor to get at the actual Torch module.
model = model.model
for param in model.parameters():
return param
raise ValueError(f"No parameters found in model {model!r}")
| """
Find the first parameter in a model or module.
"""
if hasattr(model, "model") and hasattr(model.model, "parameters"):
# Unpeel a model descriptor to get at the actual Torch module.
model = model.model
for param in model.parameters():
return param
raise ValueError(f"... | 34 | 62 | 90 | 152 | from __future__ import annotations
import torch.nn
def get_param(model) -> torch.nn.Parameter:
FILL_FUNC_BODY | from __future__ import annotations
import torch.nn
def get_param(model) -> torch.nn.Parameter:
"""
Find the first parameter in a model or module.
"""
FILL_FUNC_BODY | |
363 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/txt2img.py | 14,15 | 1,121 | txt2img_create_processing | 15,58 | 15,58 | import json
from contextlib import closing
import modules.scripts
from modules import processing, infotext_utils
from modules.infotext_utils import create_override_settings_dict, parse_generation_parameters
from modules.shared import opts
import modules.shared as shared
from modules.ui import plaintext_to_html
from PI... | import json
from contextlib import closing
import modules.scripts
from modules import processing, infotext_utils
from modules.infotext_utils import create_override_settings_dict, parse_generation_parameters
from modules.shared import opts
import modules.shared as shared
from modules.ui import plaintext_to_html
from PI... | override_settings = create_override_settings_dict(override_settings_texts)
if force_enable_hr:
enable_hr = True
p = processing.StableDiffusionProcessingTxt2Img(
sd_model=shared.sd_model,
outpath_samples=opts.outdir_samples or opts.outdir_txt2img_samples,
outpath_grids=opts.... | override_settings = create_override_settings_dict(override_settings_texts)
if force_enable_hr:
enable_hr = True
p = processing.StableDiffusionProcessingTxt2Img(
sd_model=shared.sd_model,
outpath_samples=opts.outdir_samples or opts.outdir_txt2img_samples,
outpath_grids=opts.... | 80 | 1,099 | 571 | 1,670 | import json
from contextlib import closing
import modules.scripts
from modules import processing, infotext_utils
from modules.infotext_utils import create_override_settings_dict, parse_generation_parameters
from modules.shared import opts
import modules.shared as shared
from modules.ui import plaintext_to_html
from PI... | import json
from contextlib import closing
import modules.scripts
from modules import processing, infotext_utils
from modules.infotext_utils import create_override_settings_dict, parse_generation_parameters
from modules.shared import opts
import modules.shared as shared
from modules.ui import plaintext_to_html
from PI... | |
365 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/ui_extra_networks_checkpoints.py | 17,18 | 8,52 | create_item | ExtraNetworksPageCheckpoints | 18,39 | 18,39 | class ExtraNetworksPageCheckpoints(ui_extra_networks.ExtraNetworksPage):
def __init__(self):
super().__init__('Checkpoints')
self.allow_prompt = False
def refresh(self):
shared.refresh_checkpoints()
def create_item(self, name, index=None, enable_filter=True):
FILL_FUNC_BODY def... | class ExtraNetworksPageCheckpoints(ui_extra_networks.ExtraNetworksPage):
def __init__(self):
super().__init__('Checkpoints')
self.allow_prompt = False
def refresh(self):
shared.refresh_checkpoints()
def create_item(self, name, index=None, enable_filter=True):
FILL_FUNC_BODY def... | checkpoint: sd_models.CheckpointInfo = sd_models.checkpoint_aliases.get(name)
if checkpoint is None:
return
path, ext = os.path.splitext(checkpoint.filename)
search_terms = [self.search_terms_from_path(checkpoint.filename)]
if checkpoint.sha256:
search_te... | checkpoint: sd_models.CheckpointInfo = sd_models.checkpoint_aliases.get(name)
if checkpoint is None:
return
path, ext = os.path.splitext(checkpoint.filename)
search_terms = [self.search_terms_from_path(checkpoint.filename)]
if checkpoint.sha256:
search_te... | 45 | 262 | 306 | 568 | import html
import os
from modules import shared, ui_extra_networks, sd_models
from modules.ui_extra_networks_checkpoints_user_metadata import CheckpointUserMetadataEditor
class ExtraNetworksPageCheckpoints(ui_extra_networks.ExtraNetworksPage):
def __init__(self):
super().__init__('Checkpoints')
... | import html
import os
from modules import shared, ui_extra_networks, sd_models
from modules.ui_extra_networks_checkpoints_user_metadata import CheckpointUserMetadataEditor
class ExtraNetworksPageCheckpoints(ui_extra_networks.ExtraNetworksPage):
def __init__(self):
super().__init__('Checkpoints')
... |
366 | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui | /home/hieuvd/dung_repo/raw/stars_01/AUTOMATIC1111_stable-diffusion-webui/stable-diffusion-webui/modules/ui_extra_networks_hypernets.py | 15,16 | 8,49 | create_item | ExtraNetworksPageHypernetworks | 16,38 | 16,38 | class ExtraNetworksPageHypernetworks(ui_extra_networks.ExtraNetworksPage):
def __init__(self):
super().__init__('Hypernetworks')
def refresh(self):
shared.reload_hypernetworks()
def create_item(self, name, index=None, enable_filter=True):
FILL_FUNC_BODY def list_items(self):
# i... | class ExtraNetworksPageHypernetworks(ui_extra_networks.ExtraNetworksPage):
def __init__(self):
super().__init__('Hypernetworks')
def refresh(self):
shared.reload_hypernetworks()
def create_item(self, name, index=None, enable_filter=True):
FILL_FUNC_BODY def list_items(self):
# i... | full_path = shared.hypernetworks.get(name)
if full_path is None:
return
path, ext = os.path.splitext(full_path)
sha256 = sha256_from_cache(full_path, f'hypernet/{name}')
shorthash = sha256[0:10] if sha256 else None
search_terms = [self.search_terms_from_path(... | full_path = shared.hypernetworks.get(name)
if full_path is None:
return
path, ext = os.path.splitext(full_path)
sha256 = sha256_from_cache(full_path, f'hypernet/{name}')
shorthash = sha256[0:10] if sha256 else None
search_terms = [self.search_terms_from_path(... | 62 | 199 | 330 | 529 | import os
from modules import shared, ui_extra_networks
from modules.ui_extra_networks import quote_js
from modules.hashes import sha256_from_cache
class ExtraNetworksPageHypernetworks(ui_extra_networks.ExtraNetworksPage):
def __init__(self):
super().__init__('Hypernetworks')
def refresh(self):
... | import os
from modules import shared, ui_extra_networks
from modules.ui_extra_networks import quote_js
from modules.hashes import sha256_from_cache
class ExtraNetworksPageHypernetworks(ui_extra_networks.ExtraNetworksPage):
def __init__(self):
super().__init__('Hypernetworks')
def refresh(self):
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.