Uthar commited on
Commit
1b39c8f
·
verified ·
1 Parent(s): ffbfa9a

Update app.py

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