Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -45,7 +45,7 @@ css = """
|
|
| 45 |
max-width: 520px;
|
| 46 |
}
|
| 47 |
"""
|
| 48 |
-
with gr.Blocks(css=css) as demo:
|
| 49 |
with gr.Column(elem_id="col-container"):
|
| 50 |
gr.Markdown("""
|
| 51 |
# AVIF to PNG Converter
|
|
@@ -56,22 +56,19 @@ with gr.Blocks(css=css) as demo:
|
|
| 56 |
label="Upload AVIF File",
|
| 57 |
file_types=[".avif"],
|
| 58 |
file_count="multiple"
|
| 59 |
-
)
|
| 60 |
run_button = gr.Button("Convert", scale=0)
|
| 61 |
result = gr.Gallery(label="Result")
|
| 62 |
download_button = gr.Button("Download All as ZIP")
|
| 63 |
-
|
| 64 |
converted_files = []
|
| 65 |
|
| 66 |
def handle_conversion(avif_files):
|
| 67 |
global converted_files
|
| 68 |
converted_files = convert_avif_to_png(avif_files)
|
| 69 |
return converted_files
|
| 70 |
-
|
| 71 |
def handle_download():
|
| 72 |
-
if not converted_files:
|
| 73 |
-
error_modal.show()
|
| 74 |
-
return None
|
| 75 |
return zip_files(converted_files)
|
| 76 |
|
| 77 |
run_button.click(
|
|
@@ -83,5 +80,13 @@ with gr.Blocks(css=css) as demo:
|
|
| 83 |
fn=handle_download,
|
| 84 |
inputs=[],
|
| 85 |
outputs=[gr.File()]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
)
|
| 87 |
demo.queue().launch()
|
|
|
|
| 45 |
max-width: 520px;
|
| 46 |
}
|
| 47 |
"""
|
| 48 |
+
with gr.Blocks(css=css) as demo:
|
| 49 |
with gr.Column(elem_id="col-container"):
|
| 50 |
gr.Markdown("""
|
| 51 |
# AVIF to PNG Converter
|
|
|
|
| 56 |
label="Upload AVIF File",
|
| 57 |
file_types=[".avif"],
|
| 58 |
file_count="multiple"
|
| 59 |
+
)
|
| 60 |
run_button = gr.Button("Convert", scale=0)
|
| 61 |
result = gr.Gallery(label="Result")
|
| 62 |
download_button = gr.Button("Download All as ZIP")
|
| 63 |
+
|
| 64 |
converted_files = []
|
| 65 |
|
| 66 |
def handle_conversion(avif_files):
|
| 67 |
global converted_files
|
| 68 |
converted_files = convert_avif_to_png(avif_files)
|
| 69 |
return converted_files
|
| 70 |
+
|
| 71 |
def handle_download():
|
|
|
|
|
|
|
|
|
|
| 72 |
return zip_files(converted_files)
|
| 73 |
|
| 74 |
run_button.click(
|
|
|
|
| 80 |
fn=handle_download,
|
| 81 |
inputs=[],
|
| 82 |
outputs=[gr.File()]
|
| 83 |
+
).success(
|
| 84 |
+
lambda: gr.Info("Download started."),
|
| 85 |
+
inputs=None,
|
| 86 |
+
outputs=None
|
| 87 |
+
).error(
|
| 88 |
+
lambda e: gr.Error(str(e)),
|
| 89 |
+
inputs=None,
|
| 90 |
+
outputs=None
|
| 91 |
)
|
| 92 |
demo.queue().launch()
|