file_name stringlengths 3 116 | file_path stringlengths 14 221 | content stringlengths 17 59.1k | language stringclasses 1
value |
|---|---|---|---|
webui.py | AUTOMATIC1111_stable-diffusion-webui/webui.py | def create_api(app):
from modules.api.api import Api
from modules.call_queue import queue_lock
api = Api(app, queue_lock)
return api
def api_only():
from fastapi import FastAPI
from modules.shared_cmd_options import cmd_opts
initialize.initialize()
app = FastAPI()
initialize_util.set... | Python |
launch.py | AUTOMATIC1111_stable-diffusion-webui/launch.py | def main():
if args.dump_sysinfo:
filename = launch_utils.dump_sysinfo()
print(f'Sysinfo saved as {filename}. Exiting...')
exit(0)
launch_utils.startup_timer.record('initial startup')
with launch_utils.startup_timer.subcategory('prepare environment'):
if not args.skip_prepare... | Python |
test_img2img.py | AUTOMATIC1111_stable-diffusion-webui/test/test_img2img.py | @pytest.fixture()
def url_img2img(base_url):
return f'{base_url}/sdapi/v1/img2img'
@pytest.fixture()
def simple_img2img_request(img2img_basic_image_base64):
return {'batch_size': 1, 'cfg_scale': 7, 'denoising_strength': 0.75, 'eta': 0, 'height': 64, 'include_init_images': False, 'init_images': [img2img_basic_im... | Python |
conftest.py | AUTOMATIC1111_stable-diffusion-webui/test/conftest.py | def pytest_configure(config):
os.environ.setdefault('IGNORE_CMD_ARGS_ERRORS', '1')
def file_to_base64(filename):
with open(filename, 'rb') as file:
data = file.read()
base64_str = str(base64.b64encode(data), 'utf-8')
return 'data:image/png;base64,' + base64_str
@pytest.fixture(scope='session')
d... | Python |
test_txt2img.py | AUTOMATIC1111_stable-diffusion-webui/test/test_txt2img.py | @pytest.fixture()
def url_txt2img(base_url):
return f'{base_url}/sdapi/v1/txt2img'
@pytest.fixture()
def simple_txt2img_request():
return {'batch_size': 1, 'cfg_scale': 7, 'denoising_strength': 0, 'enable_hr': False, 'eta': 0, 'firstphase_height': 0, 'firstphase_width': 0, 'height': 64, 'n_iter': 1, 'negative_p... | Python |
test_torch_utils.py | AUTOMATIC1111_stable-diffusion-webui/test/test_torch_utils.py | @pytest.mark.parametrize('wrapped', [True, False])
def test_get_param(wrapped):
mod = torch.nn.Linear(1, 1)
cpu = torch.device('cpu')
mod.to(dtype=torch.float16, device=cpu)
if wrapped:
mod = types.SimpleNamespace(model=mod)
p = torch_utils.get_param(mod)
assert p.dtype == torch.float16
... | Python |
test_utils.py | AUTOMATIC1111_stable-diffusion-webui/test/test_utils.py | def test_options_write(base_url):
url_options = f'{base_url}/sdapi/v1/options'
response = requests.get(url_options)
assert response.status_code == 200
pre_value = response.json()['send_seed']
assert requests.post(url_options, json={'send_seed': not pre_value}).status_code == 200
response = reque... | Python |
test_face_restorers.py | AUTOMATIC1111_stable-diffusion-webui/test/test_face_restorers.py | @pytest.mark.usefixtures('initialize')
@pytest.mark.parametrize('restorer_name', ['gfpgan', 'codeformer'])
def test_face_restorers(restorer_name):
from modules import shared
if restorer_name == 'gfpgan':
from modules import gfpgan_model
gfpgan_model.setup_model(shared.cmd_opts.gfpgan_models_path... | Python |
test_extras.py | AUTOMATIC1111_stable-diffusion-webui/test/test_extras.py | def test_simple_upscaling_performed(base_url, img2img_basic_image_base64):
payload = {'resize_mode': 0, 'show_extras_results': True, 'gfpgan_visibility': 0, 'codeformer_visibility': 0, 'codeformer_weight': 0, 'upscaling_resize': 2, 'upscaling_resize_w': 128, 'upscaling_resize_h': 128, 'upscaling_crop': True, 'upsca... | Python |
shared_gradio_themes.py | AUTOMATIC1111_stable-diffusion-webui/modules/shared_gradio_themes.py | def reload_gradio_theme(theme_name=None):
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':
... | Python |
sd_samplers_timesteps_impl.py | AUTOMATIC1111_stable-diffusion-webui/modules/sd_samplers_timesteps_impl.py | @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_cumprod
alphas = alphas_cumprod[timesteps]
alphas_prev = alphas_cumprod[torch.nn.functional.pad(timesteps[:-1], pad=(1, 0))].to(float64(x))
sqrt_on... | Python |
sd_hijack_xlmr.py | AUTOMATIC1111_stable-diffusion-webui/modules/sd_hijack_xlmr.py | 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_token_id
self.comma_token = self.tokenizer.get_vocab().get(',', None)
def encode_with_transformers(self, token... | Python |
sd_vae.py | AUTOMATIC1111_stable-diffusion-webui/modules/sd_vae.py | def get_loaded_vae_name():
if loaded_vae_file is None:
return None
return os.path.basename(loaded_vae_file)
def get_loaded_vae_hash():
if loaded_vae_file is None:
return None
sha256 = hashes.sha256(loaded_vae_file, 'vae')
return sha256[0:10] if sha256 else None
def get_base_vae(model... | Python |
sd_hijack_optimizations.py | AUTOMATIC1111_stable-diffusion-webui/modules/sd_hijack_optimizations.py | def title(self):
if self.label is None:
return self.name
return f'{self.name} - {self.label}'
def is_available(self):
return True
def apply(self):
pass
def undo(self):
ldm.modules.attention.CrossAttention.forward = hypernetwork.attention_CrossAttention_forward
ldm.modules.diffusionmodule... | Python |
script_callbacks.py | AUTOMATIC1111_stable-diffusion-webui/modules/script_callbacks.py | def report_exception(c, job):
errors.report(f'Error executing callback {job} for {c.script}', exc_info=True)
def __init__(self, image, p, filename, pnginfo):
self.image = image
'the PIL image itself'
self.p = p
'p object with processing parameters; either StableDiffusionProcessing or an object with ... | Python |
img2img.py | AUTOMATIC1111_stable-diffusion-webui/modules/img2img.py | def process_batch(p, input, output_dir, inpaint_mask_dir, args, to_scale=False, scale_by=1.0, use_png_info=False, png_info_props=None, png_info_dir=None):
output_dir = output_dir.strip()
processing.fix_seed(p)
if isinstance(input, str):
batch_images = list(shared.walk_files(input, allowed_extensions... | Python |
scripts_postprocessing.py | AUTOMATIC1111_stable-diffusion-webui/modules/scripts_postprocessing.py | 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_suffixes=None):
used_suffixes = {} if used_suffixes is None el... | Python |
ui_extra_networks_hypernets.py | AUTOMATIC1111_stable-diffusion-webui/modules/ui_extra_networks_hypernets.py | def __init__(self):
super().__init__('Hypernetworks')
def refresh(self):
shared.reload_hypernetworks()
def create_item(self, name, index=None, enable_filter=True):
full_path = shared.hypernetworks.get(name)
if full_path is None:
return
path, ext = os.path.splitext(full_path)
sha256 = sha... | Python |
shared_total_tqdm.py | AUTOMATIC1111_stable-diffusion-webui/modules/shared_total_tqdm.py | 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(self):
if not shared.opts.multiple_tqdm or shared.cmd_opts.disable_console_progressbars:
... | Python |
errors.py | AUTOMATIC1111_stable-diffusion-webui/modules/errors.py | def format_traceback(tb):
return [[f'{x.filename}, line {x.lineno}, {x.name}', x.line] for x in traceback.extract_tb(tb)]
def format_exception(e, tb):
return {'exception': str(e), 'traceback': format_traceback(tb)}
def get_exceptions():
try:
return list(reversed(exception_records))
except Except... | Python |
extra_networks.py | AUTOMATIC1111_stable-diffusion-webui/modules/extra_networks.py | def initialize():
extra_network_registry.clear()
extra_network_aliases.clear()
def register_extra_network(extra_network):
extra_network_registry[extra_network.name] = extra_network
def register_extra_network_alias(extra_network, alias):
extra_network_aliases[alias] = extra_network
def register_default_e... | Python |
memmon.py | AUTOMATIC1111_stable-diffusion-webui/modules/memmon.py | def __init__(self, name, device, opts):
threading.Thread.__init__(self)
self.name = name
self.device = device
self.opts = opts
self.daemon = True
self.run_flag = threading.Event()
self.data = defaultdict(int)
try:
self.cuda_mem_get_info()
torch.cuda.memory_stats(self.devi... | Python |
util.py | AUTOMATIC1111_stable-diffusion-webui/modules/util.py | def natural_sort_key(s, regex=re.compile('([0-9]+)')):
return [int(text) if text.isdigit() else text.lower() for text in regex.split(s)]
def listfiles(dirname):
filenames = [os.path.join(dirname, x) for x in sorted(os.listdir(dirname), key=natural_sort_key) if not x.startswith('.')]
return [file for file in... | Python |
extensions.py | AUTOMATIC1111_stable-diffusion-webui/modules/extensions.py | def active():
if shared.cmd_opts.disable_all_extensions or shared.opts.disable_all_extensions == 'all':
return []
elif shared.cmd_opts.disable_extra_extensions or shared.opts.disable_all_extensions == 'extra':
return [x for x in extensions if x.enabled and x.is_builtin]
else:
return ... | Python |
ui_settings.py | AUTOMATIC1111_stable-diffusion-webui/modules/ui_settings.py | def get_value_for_setting(key):
value = getattr(opts, key)
info = opts.data_labels[key]
args = info.component_args() if callable(info.component_args) else info.component_args or {}
args = {k: v for k, v in args.items() if k not in {'precision'}}
return gr.update(value=value, **args)
def create_setti... | Python |
esrgan_model.py | AUTOMATIC1111_stable-diffusion-webui/modules/esrgan_model.py | def __init__(self, dirname):
self.name = 'ESRGAN'
self.model_url = 'https://github.com/cszn/KAIR/releases/download/v1.0/ESRGAN.pth'
self.model_name = 'ESRGAN_4x'
self.scalers = []
self.user_path = dirname
super().__init__()
model_paths = self.find_models(ext_filter=['.pt', '.pth'])
scale... | Python |
ui_prompt_styles.py | AUTOMATIC1111_stable-diffusion-webui/modules/ui_prompt_styles.py | def select_style(name):
style = shared.prompt_styles.styles.get(name)
existing = style is not None
empty = not name
prompt = style.prompt if style else gr.update()
negative_prompt = style.negative_prompt if style else gr.update()
return (prompt, negative_prompt, gr.update(visible=existing), gr.u... | Python |
launch_utils.py | AUTOMATIC1111_stable-diffusion-webui/modules/launch_utils.py | def check_python_version():
is_windows = platform.system() == 'Windows'
major = sys.version_info.major
minor = sys.version_info.minor
micro = sys.version_info.micro
if is_windows:
supported_minors = [10]
else:
supported_minors = [7, 8, 9, 10, 11]
if not (major == 3 and minor ... | Python |
patches.py | AUTOMATIC1111_stable-diffusion-webui/modules/patches.py | def patch(key, obj, field, replacement):
"""Replaces a function in a module or a class.
Also stores the original function in this module, possible to be retrieved via original(key, obj, field).
If the function is already replaced by this caller (key), an exception is raised -- use undo() before that.
... | Python |
shared_init.py | AUTOMATIC1111_stable-diffusion-webui/modules/shared_init.py | 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.
"""
os.makedirs(cmd_opts.hypernetwork_dir, exist_ok=True)
from modules import options, shared_options
... | Python |
logging_config.py | AUTOMATIC1111_stable-diffusion-webui/modules/logging_config.py | def __init__(self, fallback_handler: logging.Handler):
super().__init__()
self.fallback_handler = fallback_handler
def emit(self, record):
try:
if tqdm._instances:
tqdm.write(self.format(record))
else:
self.fallback_handler.emit(record)
except Exception:
s... | Python |
sd_samplers.py | AUTOMATIC1111_stable-diffusion-webui/modules/sd_samplers.py | def find_sampler_config(name):
if name is not None:
config = all_samplers_map.get(name, None)
else:
config = all_samplers[0]
return config
def create_sampler(name, model):
config = find_sampler_config(name)
assert config is not None, f'bad sampler name: {name}'
if model.is_sdxl a... | Python |
ui_components.py | AUTOMATIC1111_stable-diffusion-webui/modules/ui_components.py | def get_expected_parent(self):
return gr.components.Form
def __init__(self, *args, **kwargs):
classes = kwargs.pop('elem_classes', [])
super().__init__(*args, elem_classes=['tool', *classes], **kwargs)
def get_block_name(self):
return 'button'
def __init__(self, **kwargs):
super().__init__(**kwargs)... | Python |
script_loading.py | AUTOMATIC1111_stable-diffusion-webui/modules/script_loading.py | 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] = module
return module
def preload_extensions(extensions_dir, parser, extension_... | Python |
torch_utils.py | AUTOMATIC1111_stable-diffusion-webui/modules/torch_utils.py | def get_param(model) -> torch.nn.Parameter:
"""
Find the first parameter in a model or module.
"""
if hasattr(model, 'model') and hasattr(model.model, 'parameters'):
model = model.model
for param in model.parameters():
return param
raise ValueError(f'No parameters found in model ... | Python |
upscaler.py | AUTOMATIC1111_stable-diffusion-webui/modules/upscaler.py | def __init__(self, create_dirs=False):
self.mod_pad_h = None
self.tile_size = modules.shared.opts.ESRGAN_tile
self.tile_pad = modules.shared.opts.ESRGAN_tile_overlap
self.device = modules.shared.device
self.img = None
self.output = None
self.scale = 1
self.half = not modules.shared.cmd_o... | Python |
ngrok.py | AUTOMATIC1111_stable-diffusion-webui/modules/ngrok.py | def connect(token, port, options):
account = None
if token is None:
token = 'None'
elif ':' in token:
token, username, password = token.split(':', 2)
account = f'{username}:{password}'
if not options.get('authtoken_from_env'):
options['authtoken'] = token
if account:
... | Python |
extra_networks_hypernet.py | AUTOMATIC1111_stable-diffusion-webui/modules/extra_networks_hypernet.py | def __init__(self):
super().__init__('hypernet')
def activate(self, p, params_list):
additional = shared.opts.sd_hypernetwork
if additional != 'None' and additional in shared.hypernetworks and (not any((x for x in params_list if x.items[0] == additional))):
hypernet_prompt_text = f'<hypernet:{additi... | Python |
ui_extra_networks_checkpoints.py | AUTOMATIC1111_stable-diffusion-webui/modules/ui_extra_networks_checkpoints.py | 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):
checkpoint: sd_models.CheckpointInfo = sd_models.checkpoint_aliases.get(name)
if checkpoint is None:
retu... | Python |
sd_hijack_utils.py | AUTOMATIC1111_stable-diffusion-webui/modules/sd_hijack_utils.py | def __new__(cls, orig_func, sub_func, cond_func=always_true_func):
self = super(CondFunc, cls).__new__(cls)
if isinstance(orig_func, str):
func_path = orig_func.split('.')
for i in range(len(func_path) - 1, -1, -1):
try:
resolved_obj = importlib.import_module('.'.join... | Python |
sd_hijack.py | AUTOMATIC1111_stable-diffusion-webui/modules/sd_hijack.py | def list_optimizers():
new_optimizers = script_callbacks.list_optimizers_callback()
new_optimizers = [x for x in new_optimizers if x.is_available()]
new_optimizers = sorted(new_optimizers, key=lambda x: x.priority, reverse=True)
optimizers.clear()
optimizers.extend(new_optimizers)
def apply_optimiza... | Python |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 6