Spaces:
Running
on
Zero
Running
on
Zero
viklofg
commited on
Commit
·
5610897
1
Parent(s):
abf9774
Revert "Fix some image upload bugs"
Browse filesThis reverts commit abf9774fabf54081947ecbe03faaea434b6a275c.
- app/tabs/submit.py +6 -7
app/tabs/submit.py
CHANGED
@@ -111,7 +111,7 @@ def run_htrflow(custom_template_yaml, batch_image_gallery, progress=gr.Progress(
|
|
111 |
time.sleep(2)
|
112 |
gr.Info("Completed succesfully ✨")
|
113 |
|
114 |
-
yield collection
|
115 |
|
116 |
|
117 |
def get_pipeline_description(pipeline: str) -> str:
|
@@ -227,7 +227,7 @@ def handle_url_input(input_value: str) -> list[str]:
|
|
227 |
|
228 |
# Does the URL return JSON? => Treat it like a IIIF manifest.
|
229 |
try:
|
230 |
-
manifest = requests.get(input_value
|
231 |
return get_images_from_iiif_manifest(manifest)
|
232 |
except (requests.HTTPError, requests.JSONDecodeError):
|
233 |
pass
|
@@ -289,7 +289,7 @@ def move_uploaded_to_selected_if_possible(uploaded_images):
|
|
289 |
"""
|
290 |
Select all uploaded images if len(uploaded_images) <= MAX_IMAGES
|
291 |
"""
|
292 |
-
if uploaded_images is None
|
293 |
return uploaded_images
|
294 |
return []
|
295 |
|
@@ -428,7 +428,6 @@ with gr.Blocks() as submit:
|
|
428 |
batch_image_gallery.upload(lambda images: images, batch_image_gallery, uploaded_images_gallery)
|
429 |
image_iiif_url.submit(handle_url_input, image_iiif_url, uploaded_images_gallery).then(fn=lambda: "Swedish - Spreads", outputs=pipeline_dropdown)
|
430 |
image_iiif_url.submit(open_image_selector_modal, uploaded_images_gallery, image_selector_modal)
|
431 |
-
image_iiif_url.submit(move_uploaded_to_selected_if_possible, uploaded_images_gallery, selected_images_gallery)
|
432 |
|
433 |
# Move uploaded images to `selected_images`, opening the modal if needed
|
434 |
uploaded_images_gallery.change(open_image_selector_modal, uploaded_images_gallery, image_selector_modal)
|
@@ -438,18 +437,18 @@ with gr.Blocks() as submit:
|
|
438 |
uploaded_images_gallery.select(select_uploaded_image, selected_images_gallery, selected_images_gallery)
|
439 |
selected_images_gallery.select(deselect_selected_image, selected_images_gallery, selected_images_gallery)
|
440 |
selected_images_gallery.change(lambda images: gr.update(visible=bool(images)), selected_images_gallery, selected_images_gallery)
|
441 |
-
selected_images_gallery.change(lambda images: images, selected_images_gallery, batch_image_gallery)
|
442 |
selected_images_gallery.change(lambda images: gr.update(interactive=bool(images)), selected_images_gallery, ok_button)
|
443 |
|
444 |
# Image selector modal buttons
|
445 |
cancel_button.click(lambda: Modal(visible=False), None, image_selector_modal)
|
446 |
cancel_button.click(lambda: [], None, selected_images_gallery)
|
447 |
cancel_button.click(lambda: gr.update(value=None), None, batch_image_gallery)
|
448 |
-
cancel_button.click(lambda: gr.update(value=None), None, uploaded_images_gallery)
|
449 |
ok_button.click(lambda: Modal(visible=False), None, image_selector_modal)
|
|
|
450 |
|
451 |
# Run HTRflow on selected images
|
452 |
-
run_button.click(fn=run_htrflow, inputs=[custom_template_yaml, selected_images_gallery], outputs=
|
|
|
453 |
|
454 |
examples.select(get_selected_example_image, None, batch_image_gallery)
|
455 |
examples.select(get_selected_example_image, None, uploaded_images_gallery)
|
|
|
111 |
time.sleep(2)
|
112 |
gr.Info("Completed succesfully ✨")
|
113 |
|
114 |
+
yield collection
|
115 |
|
116 |
|
117 |
def get_pipeline_description(pipeline: str) -> str:
|
|
|
227 |
|
228 |
# Does the URL return JSON? => Treat it like a IIIF manifest.
|
229 |
try:
|
230 |
+
manifest = requests.get(input_value).json()
|
231 |
return get_images_from_iiif_manifest(manifest)
|
232 |
except (requests.HTTPError, requests.JSONDecodeError):
|
233 |
pass
|
|
|
289 |
"""
|
290 |
Select all uploaded images if len(uploaded_images) <= MAX_IMAGES
|
291 |
"""
|
292 |
+
if uploaded_images is not None and len(uploaded_images) <= MAX_IMAGES:
|
293 |
return uploaded_images
|
294 |
return []
|
295 |
|
|
|
428 |
batch_image_gallery.upload(lambda images: images, batch_image_gallery, uploaded_images_gallery)
|
429 |
image_iiif_url.submit(handle_url_input, image_iiif_url, uploaded_images_gallery).then(fn=lambda: "Swedish - Spreads", outputs=pipeline_dropdown)
|
430 |
image_iiif_url.submit(open_image_selector_modal, uploaded_images_gallery, image_selector_modal)
|
|
|
431 |
|
432 |
# Move uploaded images to `selected_images`, opening the modal if needed
|
433 |
uploaded_images_gallery.change(open_image_selector_modal, uploaded_images_gallery, image_selector_modal)
|
|
|
437 |
uploaded_images_gallery.select(select_uploaded_image, selected_images_gallery, selected_images_gallery)
|
438 |
selected_images_gallery.select(deselect_selected_image, selected_images_gallery, selected_images_gallery)
|
439 |
selected_images_gallery.change(lambda images: gr.update(visible=bool(images)), selected_images_gallery, selected_images_gallery)
|
|
|
440 |
selected_images_gallery.change(lambda images: gr.update(interactive=bool(images)), selected_images_gallery, ok_button)
|
441 |
|
442 |
# Image selector modal buttons
|
443 |
cancel_button.click(lambda: Modal(visible=False), None, image_selector_modal)
|
444 |
cancel_button.click(lambda: [], None, selected_images_gallery)
|
445 |
cancel_button.click(lambda: gr.update(value=None), None, batch_image_gallery)
|
|
|
446 |
ok_button.click(lambda: Modal(visible=False), None, image_selector_modal)
|
447 |
+
ok_button.click(lambda x: x, selected_images_gallery, batch_image_gallery)
|
448 |
|
449 |
# Run HTRflow on selected images
|
450 |
+
run_button.click(fn=run_htrflow, inputs=[custom_template_yaml, selected_images_gallery], outputs=collection_submit_state)
|
451 |
+
run_button.click(lambda: [], None, )
|
452 |
|
453 |
examples.select(get_selected_example_image, None, batch_image_gallery)
|
454 |
examples.select(get_selected_example_image, None, uploaded_images_gallery)
|