Spaces:
Running
on
Zero
Running
on
Zero
Fall back to loading the first image in the gallery if none are selected
Browse files
app.py
CHANGED
|
@@ -51,8 +51,11 @@ window.settings = {
|
|
| 51 |
crop_pos_x: 0,
|
| 52 |
crop_pos_y: 0,
|
| 53 |
};
|
| 54 |
-
window.castHologram = async function() {
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
| 56 |
if (!uri)
|
| 57 |
return;
|
| 58 |
const Bridge = BridgeClient.getInstance();
|
|
@@ -279,13 +282,13 @@ with gr.Blocks(css=css, head=head) as demo:
|
|
| 279 |
reset = gr.Button(value="Reset All Parameters")
|
| 280 |
|
| 281 |
gallery.select(fn=None, js="castHologram")
|
| 282 |
-
gallery.change(fn=zip_gallery, inputs=gallery, outputs=download_btn).then(fn=None, js="castHologram")
|
| 283 |
|
| 284 |
submit.click(
|
| 285 |
on_submit,
|
| 286 |
inputs=[input_image, batch_images, book, model_size, upscale_model, upscale_method, denoise_level, discard_alpha],
|
| 287 |
outputs=[gallery]
|
| 288 |
-
).success(fn=zip_gallery, inputs=gallery, outputs=download_btn).then(fn=None, js="castHologram")
|
| 289 |
|
| 290 |
depthiness.change(fn=None, inputs=depthiness, js="(value) => updateHologram (value, 'depthiness')")
|
| 291 |
focus.change(fn=None, inputs=focus, js="(value) => updateHologram (value, 'focus')")
|
|
@@ -303,7 +306,7 @@ with gr.Blocks(css=css, head=head) as demo:
|
|
| 303 |
return on_submit(image, None, None, 'vitl', None, None, -1, True)
|
| 304 |
example_files = glob.glob('assets/examples/*')
|
| 305 |
examples = gr.Examples(examples=example_files, inputs=[input_image], outputs=[gallery], fn=on_submit_example)
|
| 306 |
-
examples.load_input_event.success(fn=None, js="castHologram")
|
| 307 |
|
| 308 |
if __name__ == '__main__':
|
| 309 |
demo.queue().launch()
|
|
|
|
| 51 |
crop_pos_x: 0,
|
| 52 |
crop_pos_y: 0,
|
| 53 |
};
|
| 54 |
+
window.castHologram = async function(gallery) {
|
| 55 |
+
if (gallery.length == 0)
|
| 56 |
+
return;
|
| 57 |
+
const selected = document.querySelector('#img-display-output .thumbnail-item.selected img');
|
| 58 |
+
const uri = selected ? selected.src : gallery[0].image;
|
| 59 |
if (!uri)
|
| 60 |
return;
|
| 61 |
const Bridge = BridgeClient.getInstance();
|
|
|
|
| 282 |
reset = gr.Button(value="Reset All Parameters")
|
| 283 |
|
| 284 |
gallery.select(fn=None, js="castHologram")
|
| 285 |
+
gallery.change(fn=zip_gallery, inputs=gallery, outputs=download_btn).then(fn=None, js="castHologram", inputs=gallery)
|
| 286 |
|
| 287 |
submit.click(
|
| 288 |
on_submit,
|
| 289 |
inputs=[input_image, batch_images, book, model_size, upscale_model, upscale_method, denoise_level, discard_alpha],
|
| 290 |
outputs=[gallery]
|
| 291 |
+
).success(fn=zip_gallery, inputs=gallery, outputs=download_btn).then(fn=None, js="castHologram", inputs=gallery)
|
| 292 |
|
| 293 |
depthiness.change(fn=None, inputs=depthiness, js="(value) => updateHologram (value, 'depthiness')")
|
| 294 |
focus.change(fn=None, inputs=focus, js="(value) => updateHologram (value, 'focus')")
|
|
|
|
| 306 |
return on_submit(image, None, None, 'vitl', None, None, -1, True)
|
| 307 |
example_files = glob.glob('assets/examples/*')
|
| 308 |
examples = gr.Examples(examples=example_files, inputs=[input_image], outputs=[gallery], fn=on_submit_example)
|
| 309 |
+
examples.load_input_event.success(fn=None, js="castHologram", inputs=gallery)
|
| 310 |
|
| 311 |
if __name__ == '__main__':
|
| 312 |
demo.queue().launch()
|