Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -69,8 +69,14 @@ async def infer(model_str, prompt, nprompt="", height=0, width=0, steps=0, cfg=0
|
|
| 69 |
if width > 0: kwargs["width"] = width
|
| 70 |
if steps > 0: kwargs["num_inference_steps"] = steps
|
| 71 |
if cfg > 0: cfg = kwargs["guidance_scale"] = cfg
|
| 72 |
-
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
task = asyncio.create_task(asyncio.to_thread(models_load[model_str].fn, prompt=prompt, negative_prompt=nprompt, **kwargs, token=HF_TOKEN))
|
| 75 |
await asyncio.sleep(0)
|
| 76 |
try:
|
|
@@ -91,7 +97,7 @@ async def infer(model_str, prompt, nprompt="", height=0, width=0, steps=0, cfg=0
|
|
| 91 |
# png_path = "img.png"
|
| 92 |
# png_path = get_current_time() + "_" + model_str.replace("/", "_") + ".png"
|
| 93 |
# png_path = model_str.replace("/", "_") + " - " + prompt + " - " + get_current_time() + ".png"
|
| 94 |
-
png_path = model_str.replace("/", "_") + " - " + get_current_time() + ".png"
|
| 95 |
image = save_image(result, png_path, model_str, prompt, nprompt, height, width, steps, cfg, seed)
|
| 96 |
return image
|
| 97 |
return None
|
|
@@ -129,7 +135,6 @@ CSS="""
|
|
| 129 |
js_func = """
|
| 130 |
function refresh() {
|
| 131 |
const url = new URL(window.location);
|
| 132 |
-
|
| 133 |
if (url.searchParams.get('__theme') !== 'dark') {
|
| 134 |
url.searchParams.set('__theme', 'dark');
|
| 135 |
window.location.href = url.href;
|
|
@@ -138,7 +143,6 @@ function refresh() {
|
|
| 138 |
"""
|
| 139 |
|
| 140 |
js_AutoSave="""
|
| 141 |
-
|
| 142 |
console.log("Yo");
|
| 143 |
|
| 144 |
var img1 = document.querySelector("div#component-355 .svelte-1kpcxni button.svelte-1kpcxni .svelte-1kpcxni img"),
|
|
@@ -258,4 +262,4 @@ with gr.Blocks(theme='NoCrypt/miku@>=1.2.2', fill_width=True, css=CSS) as demo:
|
|
| 258 |
|
| 259 |
# demo.queue(default_concurrency_limit=200, max_size=200)
|
| 260 |
demo.launch(show_api=False, max_threads=400)
|
| 261 |
-
# demo.launch(show_api=False, max_threads=400, js=js_AutoSave)
|
|
|
|
| 69 |
if width > 0: kwargs["width"] = width
|
| 70 |
if steps > 0: kwargs["num_inference_steps"] = steps
|
| 71 |
if cfg > 0: cfg = kwargs["guidance_scale"] = cfg
|
| 72 |
+
|
| 73 |
+
if seed == -1:
|
| 74 |
+
theSeed = randomize_seed()
|
| 75 |
+
kwargs["seed"] = theSeed
|
| 76 |
+
else:
|
| 77 |
+
kwargs["seed"] = seed
|
| 78 |
+
theSeed = seed
|
| 79 |
+
|
| 80 |
task = asyncio.create_task(asyncio.to_thread(models_load[model_str].fn, prompt=prompt, negative_prompt=nprompt, **kwargs, token=HF_TOKEN))
|
| 81 |
await asyncio.sleep(0)
|
| 82 |
try:
|
|
|
|
| 97 |
# png_path = "img.png"
|
| 98 |
# png_path = get_current_time() + "_" + model_str.replace("/", "_") + ".png"
|
| 99 |
# png_path = model_str.replace("/", "_") + " - " + prompt + " - " + get_current_time() + ".png"
|
| 100 |
+
png_path = model_str.replace("/", "_") + " - " + get_current_time() + "_" + str(theSeed) + ".png"
|
| 101 |
image = save_image(result, png_path, model_str, prompt, nprompt, height, width, steps, cfg, seed)
|
| 102 |
return image
|
| 103 |
return None
|
|
|
|
| 135 |
js_func = """
|
| 136 |
function refresh() {
|
| 137 |
const url = new URL(window.location);
|
|
|
|
| 138 |
if (url.searchParams.get('__theme') !== 'dark') {
|
| 139 |
url.searchParams.set('__theme', 'dark');
|
| 140 |
window.location.href = url.href;
|
|
|
|
| 143 |
"""
|
| 144 |
|
| 145 |
js_AutoSave="""
|
|
|
|
| 146 |
console.log("Yo");
|
| 147 |
|
| 148 |
var img1 = document.querySelector("div#component-355 .svelte-1kpcxni button.svelte-1kpcxni .svelte-1kpcxni img"),
|
|
|
|
| 262 |
|
| 263 |
# demo.queue(default_concurrency_limit=200, max_size=200)
|
| 264 |
demo.launch(show_api=False, max_threads=400)
|
| 265 |
+
# demo.launch(show_api=False, max_threads=400, js=js_AutoSave)
|