Uthar commited on
Commit
bf9600c
·
verified ·
1 Parent(s): d50927a

Update app.py

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