Skip to content

Commit 365d4b1

Browse files
authored
Merge branch 'AUTOMATIC1111:master' into master
2 parents 3770b8d + f510a22 commit 365d4b1

5 files changed

Lines changed: 49 additions & 23 deletions

File tree

‎modules/prompt_parser.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def reconstruct_multicond_batch(c: MulticondLearnedConditioning, current_step):
275275

276276
def parse_prompt_attention(text):
277277
"""
278-
Parses a string with attention tokens and returns a list of pairs: text and its assoicated weight.
278+
Parses a string with attention tokens and returns a list of pairs: text and its associated weight.
279279
Accepted tokens are:
280280
(abc) - increases attention to abc by a multiplier of 1.1
281281
(abc:3.12) - increases attention to abc by a multiplier of 3.12

‎modules/sd_hijack_optimizations.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def einsum_op_cuda(q, k, v):
181181
mem_free_torch = mem_reserved - mem_active
182182
mem_free_total = mem_free_cuda + mem_free_torch
183183
# Divide factor of safety as there's copying and fragmentation
184-
return self.einsum_op_tensor_mem(q, k, v, mem_free_total / 3.3 / (1 << 20))
184+
return einsum_op_tensor_mem(q, k, v, mem_free_total / 3.3 / (1 << 20))
185185

186186
def einsum_op(q, k, v):
187187
if q.device.type == 'cuda':

‎modules/sd_models.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ def get_state_dict_from_checkpoint(pl_sd):
148148
if new_key is not None:
149149
sd[new_key] = v
150150

151-
return sd
151+
pl_sd.clear()
152+
pl_sd.update(sd)
153+
154+
return pl_sd
152155

153156

154157
def load_model_weights(model, checkpoint_info):

‎modules/ui.py‎

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import traceback
1313
import platform
1414
import subprocess as sp
15-
from functools import reduce
15+
from functools import partial, reduce
1616

1717
import numpy as np
1818
import torch
@@ -261,6 +261,19 @@ def f(*args, extra_outputs_array=extra_outputs, **kwargs):
261261
return f
262262

263263

264+
def calc_time_left(progress, threshold, label, force_display):
265+
if progress == 0:
266+
return ""
267+
else:
268+
time_since_start = time.time() - shared.state.time_start
269+
eta = (time_since_start/progress)
270+
eta_relative = eta-time_since_start
271+
if (eta_relative > threshold and progress > 0.02) or force_display:
272+
return label + time.strftime('%H:%M:%S', time.gmtime(eta_relative))
273+
else:
274+
return ""
275+
276+
264277
def check_progress_call(id_part):
265278
if shared.state.job_count == 0:
266279
return "", gr_show(False), gr_show(False), gr_show(False)
@@ -272,11 +285,15 @@ def check_progress_call(id_part):
272285
if shared.state.sampling_steps > 0:
273286
progress += 1 / shared.state.job_count * shared.state.sampling_step / shared.state.sampling_steps
274287

288+
time_left = calc_time_left( progress, 60, " ETA:", shared.state.time_left_force_display )
289+
if time_left != "":
290+
shared.state.time_left_force_display = True
291+
275292
progress = min(progress, 1)
276293

277294
progressbar = ""
278295
if opts.show_progressbar:
279-
progressbar = f"""
{progress * 100}%">{str(int(progress*100))+"%" if progress > 0.01 else ""}
"""
296+
progressbar = f"""
overflow:hidden;width:{progress * 100}%">{str(int(progress*100))+"%"+time_left if progress > 0.01 else ""}
"""
280297

281298
image = gr_show(False)
282299
preview_visibility = gr_show(False)
@@ -308,6 +325,8 @@ def check_progress_call_initial(id_part):
308325
shared.state.current_latent = None
309326
shared.state.current_image = None
310327
shared.state.textinfo = None
328+
shared.state.time_start = time.time()
329+
shared.state.time_left_force_display = False
311330

312331
return check_progress_call(id_part)
313332

@@ -1543,6 +1562,7 @@ def run_settings_single(value, key):
15431562

15441563
def reload_scripts():
15451564
modules.scripts.reload_script_body_only()
1565+
reload_javascript() # need to refresh the html page
15461566

15471567
reload_script_bodies.click(
15481568
fn=reload_scripts,
@@ -1801,26 +1821,30 @@ def apply_field(obj, field, condition=None, init_field=None):
18011821
return demo
18021822

18031823

1804-
with open(os.path.join(script_path, "script.js"), "r", encoding="utf8") as jsfile:
1805-
javascript = f''
1824+
def load_javascript(raw_response):
1825+
with open(os.path.join(script_path, "script.js"), "r", encoding="utf8") as jsfile:
1826+
javascript = f''
18061827

1807-
jsdir = os.path.join(script_path, "javascript")
1808-
for filename in sorted(os.listdir(jsdir)):
1809-
with open(os.path.join(jsdir, filename), "r", encoding="utf8") as jsfile:
1810-
javascript += f"\n"
1828+
jsdir = os.path.join(script_path, "javascript")
1829+
for filename in sorted(os.listdir(jsdir)):
1830+
with open(os.path.join(jsdir, filename), "r", encoding="utf8") as jsfile:
1831+
javascript += f"\n"
18111832

1812-
if cmd_opts.theme is not None:
1813-
javascript += f"\n\n"
1833+
if cmd_opts.theme is not None:
1834+
javascript += f"\n\n"
18141835

1815-
javascript += f"\n"
1836+
javascript += f"\n"
18161837

1817-
if 'gradio_routes_templates_response' not in globals():
18181838
def template_response(*args, **kwargs):
1819-
res = gradio_routes_templates_response(*args, **kwargs)
1820-
res.body = res.body.replace(b'', f'{javascript}'.encode("utf8"))
1839+
res = raw_response(*args, **kwargs)
1840+
res.body = res.body.replace(
1841+
b'', f'{javascript}'.encode("utf8"))
18211842
res.init_headers()
18221843
return res
18231844

1824-
gradio_routes_templates_response = gradio.routes.templates.TemplateResponse
18251845
gradio.routes.templates.TemplateResponse = template_response
18261846

1847+
1848+
reload_javascript = partial(load_javascript,
1849+
gradio.routes.templates.TemplateResponse)
1850+
reload_javascript()

‎style.css‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,17 @@
3434
.performance {
3535
font-size: 0.85em;
3636
color: #444;
37-
display: flex;
38-
justify-content: space-between;
39-
white-space: nowrap;
37+
}
38+
39+
.performance p{
40+
display: inline-block;
4041
}
4142

4243
.performance .time {
4344
margin-right: 0;
4445
}
4546

4647
.performance .vram {
47-
margin-left: 0;
48-
text-align: right;
4948
}
5049

5150
#txt2img_generate, #img2img_generate {

0 commit comments

Comments
 (0)