maxbetjes commited on
Commit
f5ae7ba
·
verified ·
1 Parent(s): 04f82a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -138,15 +138,15 @@ def update_image(filepath, z):
138
  print(filepath)
139
  return (filepath_show, [((5, 5, 10, 10), 'nothing')]), filepath, (fp0, [((5, 5, 10, 10), 'nothing')])
140
 
141
- #def update_with_example(filepath):
142
- # print('update_btn')
143
- # print(filepath)
144
- # filepath_show = filepath
145
- #fpath, fext = os.path.splitext(filepath)
146
 
147
- #filepath = filepath_show + '.tif'
148
 
149
- #return (filepath_show, [((5, 5, 10, 10), 'nothing')]), [filepath], (fp0, [((5, 5, 10, 10), 'nothing')])
150
 
151
  def example(filepath):
152
  print(filepath)
@@ -325,7 +325,7 @@ with gr.Blocks(title = "Hello",
325
  # sample_list.append("samples/img%0.2d.png"%j)
326
 
327
  #gr.Examples(sample_list, fn = update_with_example, inputs=input_image, outputs = [input_image, up_btn, output_image], examples_per_page=50, label = "Click on an example to try it")
328
- example_image = gr.Image()
329
  gr.Examples(sample_list, fn= example, inputs=example_image, outputs=[example_image], examples_per_page=5, label = "Click on an example to try it")
330
  #input_image.upload(update_button, [input_image, depth], [input_image, up_btn, output_image])
331
  up_btn.upload(update_image, [up_btn, depth], [input_image, up_btn, output_image])
 
138
  print(filepath)
139
  return (filepath_show, [((5, 5, 10, 10), 'nothing')]), filepath, (fp0, [((5, 5, 10, 10), 'nothing')])
140
 
141
+ def update_with_example(filepath):
142
+ print('update_btn')
143
+ print(filepath)
144
+ filepath_show = filepath
145
+ fpath, fext = os.path.splitext(filepath)
146
 
147
+ filepath = fpath+ '.tif'
148
 
149
+ return (filepath_show, [((5, 5, 10, 10), 'nothing')]), [filepath], (fp0, [((5, 5, 10, 10), 'nothing')])
150
 
151
  def example(filepath):
152
  print(filepath)
 
325
  # sample_list.append("samples/img%0.2d.png"%j)
326
 
327
  #gr.Examples(sample_list, fn = update_with_example, inputs=input_image, outputs = [input_image, up_btn, output_image], examples_per_page=50, label = "Click on an example to try it")
328
+ example_image = gr.Image(visible=False, type='filepath')
329
  gr.Examples(sample_list, fn= example, inputs=example_image, outputs=[example_image], examples_per_page=5, label = "Click on an example to try it")
330
  #input_image.upload(update_button, [input_image, depth], [input_image, up_btn, output_image])
331
  up_btn.upload(update_image, [up_btn, depth], [input_image, up_btn, output_image])