multimodalart HF staff commited on
Commit
b879202
1 Parent(s): 166b6db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -6
app.py CHANGED
@@ -37,11 +37,11 @@ pipe_normal.scheduler = EDMEulerScheduler(sigma_min=0.002, sigma_max=120.0, sigm
37
  pipe_normal.to("cuda")
38
 
39
  @spaces.GPU
40
- def run_normal(prompt):
41
  return pipe_normal(prompt, num_inference_steps=20).images[0]
42
 
43
  @spaces.GPU
44
- def run_edit(image, prompt):
45
  resolution = 1024
46
  image.resize((resolution, resolution))
47
  return pipe_edit(prompt=prompt,image=image,height=resolution,width=resolution,num_inference_steps=20).images[0]
@@ -51,7 +51,7 @@ max-width: 768px !important;
51
  margin: 0 auto;
52
  }
53
  '''
54
- with gr.Blocks() as demo:
55
  gr.Markdown('''# CosXL demo
56
  Unofficial demo for CosXL, a SDXL model tuned to produce full color range images. CosXL Edit allows you to perform edits on images. Both have a [non-commercial community license](https://huggingface.co/stabilityai/cosxl/blob/main/LICENSE)
57
  ''')
@@ -72,12 +72,24 @@ with gr.Blocks() as demo:
72
  output_edit = gr.Image(label="Your result image", interactive=False)
73
  with gr.Accordion("Advanced Settings", open=False):
74
  pass
75
- button_normal.click(
 
 
 
 
 
 
 
 
76
  fn=run_normal,
77
  inputs=[prompt_normal],
78
- outputs=[output_normal]
79
  )
80
- button_edit.click(
 
 
 
 
81
  fn=run_edit,
82
  inputs=[image_edit, prompt_edit],
83
  outputs=[output_edit]
 
37
  pipe_normal.to("cuda")
38
 
39
  @spaces.GPU
40
+ def run_normal(prompt, progress=gr.Progress(track_tqdm=True)):
41
  return pipe_normal(prompt, num_inference_steps=20).images[0]
42
 
43
  @spaces.GPU
44
+ def run_edit(image, prompt, progress=gr.Progress(track_tqdm=True)):
45
  resolution = 1024
46
  image.resize((resolution, resolution))
47
  return pipe_edit(prompt=prompt,image=image,height=resolution,width=resolution,num_inference_steps=20).images[0]
 
51
  margin: 0 auto;
52
  }
53
  '''
54
+ with gr.Blocks(css=css) as demo:
55
  gr.Markdown('''# CosXL demo
56
  Unofficial demo for CosXL, a SDXL model tuned to produce full color range images. CosXL Edit allows you to perform edits on images. Both have a [non-commercial community license](https://huggingface.co/stabilityai/cosxl/blob/main/LICENSE)
57
  ''')
 
72
  output_edit = gr.Image(label="Your result image", interactive=False)
73
  with gr.Accordion("Advanced Settings", open=False):
74
  pass
75
+
76
+ button_edit.click(
77
+
78
+ )
79
+ gr.on(
80
+ triggers=[
81
+ button_normal.click,
82
+ prompt_normal.submit
83
+ ],
84
  fn=run_normal,
85
  inputs=[prompt_normal],
86
+ outputs=[output_normal],
87
  )
88
+ gr.on(
89
+ triggers=[
90
+ button_edit.click,
91
+ prompt_edit.submit
92
+ ],
93
  fn=run_edit,
94
  inputs=[image_edit, prompt_edit],
95
  outputs=[output_edit]