hysts HF staff commited on
Commit
6383bc4
1 Parent(s): f4d16f5
Files changed (3) hide show
  1. app.py +9 -2
  2. model.py +3 -3
  3. style.css +4 -0
app.py CHANGED
@@ -16,8 +16,15 @@ FOOTER = '<img id="visitor-badge" src="https://visitor-badge.glitch.me/badge?pag
16
  def create_simple_demo(model: Model) -> gr.Blocks:
17
  with gr.Blocks() as demo:
18
  run_button = gr.Button('Generate')
19
- result = gr.Image(show_label=False, elem_id='result-grid')
20
- run_button.click(fn=model.run_simple, inputs=None, outputs=result)
 
 
 
 
 
 
 
21
  return demo
22
 
23
 
 
16
  def create_simple_demo(model: Model) -> gr.Blocks:
17
  with gr.Blocks() as demo:
18
  run_button = gr.Button('Generate')
19
+ with gr.Tabs():
20
+ with gr.TabItem('Result (Superresolved)'):
21
+ result = gr.Image(show_label=False, elem_id='result-grid')
22
+ with gr.TabItem('Result (Raw)'):
23
+ result_raw = gr.Image(show_label=False,
24
+ elem_id='result-grid-raw')
25
+ run_button.click(fn=model.run_simple,
26
+ inputs=None,
27
+ outputs=[result, result_raw])
28
  return demo
29
 
30
 
model.py CHANGED
@@ -180,9 +180,9 @@ class Model:
180
  0, 2, 1, 3, 4).reshape(nrows * h, ncols * w, 3)
181
  return PIL.Image.fromarray(grid)
182
 
183
- def run_simple(self) -> PIL.Image.Image:
184
  self.set_pipeline(self.MODEL_NAMES[0], 'DDIM')
185
  seed = self.rng.randint(0, 1000000)
186
  images = self.generate(seed, num_steps=10, num_images=4)
187
- images = [self.superresolve(image) for image in images]
188
- return self.to_grid(images, 2)
 
180
  0, 2, 1, 3, 4).reshape(nrows * h, ncols * w, 3)
181
  return PIL.Image.fromarray(grid)
182
 
183
+ def run_simple(self) -> tuple[PIL.Image.Image, PIL.Image.Image]:
184
  self.set_pipeline(self.MODEL_NAMES[0], 'DDIM')
185
  seed = self.rng.randint(0, 1000000)
186
  images = self.generate(seed, num_steps=10, num_images=4)
187
+ superresolved = [self.superresolve(image) for image in images]
188
+ return self.to_grid(superresolved, 2), self.to_grid(images, 2)
style.css CHANGED
@@ -5,6 +5,10 @@ div#result-grid {
5
  max-width: 600px;
6
  max-height: 600px;
7
  }
 
 
 
 
8
  div#result {
9
  max-width: 400px;
10
  max-height: 400px;
 
5
  max-width: 600px;
6
  max-height: 600px;
7
  }
8
+ div#result-grid-raw {
9
+ max-width: 600px;
10
+ max-height: 600px;
11
+ }
12
  div#result {
13
  max-width: 400px;
14
  max-height: 400px;