Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -77,6 +77,22 @@ def save_image_and_show(image, folder_name="output_images"):
|
|
| 77 |
# Show the image to the user (not the path)
|
| 78 |
st.image(image, caption="Saved Image", channels="RGB")
|
| 79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
|
| 82 |
|
|
|
|
| 77 |
# Show the image to the user (not the path)
|
| 78 |
st.image(image, caption="Saved Image", channels="RGB")
|
| 79 |
|
| 80 |
+
zip_filename = f"{folder_name}.zip"
|
| 81 |
+
with zipfile.ZipFile(zip_filename, 'w') as zipf:
|
| 82 |
+
for root, dirs, files in os.walk(folder_name):
|
| 83 |
+
for file in files:
|
| 84 |
+
filepath = os.path.join(root, file)
|
| 85 |
+
arcname = os.path.relpath(filepath, folder_name)
|
| 86 |
+
zipf.write(filepath, arcname)
|
| 87 |
+
|
| 88 |
+
# Read zip for download
|
| 89 |
+
with open(zip_filename, "rb") as f:
|
| 90 |
+
st.download_button(
|
| 91 |
+
label="Download All Images as ZIP",
|
| 92 |
+
data=f,
|
| 93 |
+
file_name=zip_filename,
|
| 94 |
+
mime="application/zip"
|
| 95 |
+
)
|
| 96 |
|
| 97 |
|
| 98 |
|