apolinario commited on
Commit
9c92ac2
1 Parent(s): b759ddd

return the image actually

Browse files
Files changed (1) hide show
  1. app.py +7 -10
app.py CHANGED
@@ -75,7 +75,7 @@ perceptor = (
75
  .requires_grad_(False)
76
  .to(device)
77
  )
78
- def run(user_input,num_steps, template, width,height):
79
  import random
80
  #if uploaded_file is not None:
81
  #uploaded_folder = f"{DefaultPaths.root_path}/uploaded"
@@ -1522,10 +1522,6 @@ def run(user_input,num_steps, template, width,height):
1522
 
1523
  except KeyboardInterrupt:
1524
  pass
1525
- except st.script_runner.StopException as e:
1526
- torch.cuda.empty_cache()
1527
- pass
1528
- return j
1529
 
1530
  def add_noise(img):
1531
 
@@ -2297,10 +2293,11 @@ def run(user_input,num_steps, template, width,height):
2297
  mh = ModelHost(args)
2298
  x = 0
2299
 
2300
- for x in range(batch_size):
2301
- mh.setup_model(x)
2302
- last_iter = mh.run(x)
2303
- x = x + 1
 
2304
 
2305
  if zoom:
2306
  files = os.listdir(steps_path)
@@ -2326,7 +2323,7 @@ def run(user_input,num_steps, template, width,height):
2326
  ##################### START GRADIO HERE ############################
2327
  image = gr.outputs.Image(type="pil", label="Your result")
2328
  iface = gr.Interface(
2329
- fn=run,
2330
  inputs=[
2331
  gr.inputs.Textbox(label="Prompt - try adding increments to your prompt such as 'oil on canvas', 'a painting', 'a book cover'",default="chalk pastel drawing of a dog wearing a funny hat"),
2332
  gr.inputs.Slider(label="Steps - more steps can increase quality but will take longer to generate",default=45,maximum=50,minimum=1,step=1),
 
75
  .requires_grad_(False)
76
  .to(device)
77
  )
78
+ def run_all(user_input,num_steps, template, width,height):
79
  import random
80
  #if uploaded_file is not None:
81
  #uploaded_folder = f"{DefaultPaths.root_path}/uploaded"
 
1522
 
1523
  except KeyboardInterrupt:
1524
  pass
 
 
 
 
1525
 
1526
  def add_noise(img):
1527
 
 
2293
  mh = ModelHost(args)
2294
  x = 0
2295
 
2296
+ #for x in range(batch_size):
2297
+ mh.setup_model(x)
2298
+ last_iter = mh.run(x)
2299
+ return(last_iter)
2300
+ #x = x + 1
2301
 
2302
  if zoom:
2303
  files = os.listdir(steps_path)
 
2323
  ##################### START GRADIO HERE ############################
2324
  image = gr.outputs.Image(type="pil", label="Your result")
2325
  iface = gr.Interface(
2326
+ fn=run_all,
2327
  inputs=[
2328
  gr.inputs.Textbox(label="Prompt - try adding increments to your prompt such as 'oil on canvas', 'a painting', 'a book cover'",default="chalk pastel drawing of a dog wearing a funny hat"),
2329
  gr.inputs.Slider(label="Steps - more steps can increase quality but will take longer to generate",default=45,maximum=50,minimum=1,step=1),