Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -121,7 +121,8 @@ def update_image_metadata(*args):
|
|
121 |
success_count = 0
|
122 |
error_count = 0
|
123 |
image_paths = []
|
124 |
-
|
|
|
125 |
# First, extract all image paths
|
126 |
for i in range(100):
|
127 |
idx = i * 6
|
@@ -141,10 +142,12 @@ def update_image_metadata(*args):
|
|
141 |
keywords = args[idx + 5]
|
142 |
if write_metadata_to_image(copied_path, title, description, keywords):
|
143 |
success_count += 1
|
|
|
144 |
else:
|
145 |
error_count += 1
|
146 |
|
147 |
-
return f"Images copied and metadata updated. Successful updates: {success_count}, Failed updates: {error_count}.
|
|
|
148 |
|
149 |
def copy_images_to_project_dir(image_paths):
|
150 |
copied_paths = []
|
@@ -272,10 +275,11 @@ with gr.Blocks(css="""
|
|
272 |
|
273 |
# Save Buttons and Output
|
274 |
with gr.Row():
|
|
|
275 |
save_csv_button = gr.Button("Save CSV")
|
276 |
save_output = gr.Textbox(label="Save Status", interactive=False)
|
277 |
csv_output = gr.File(label="Download CSV") # File download component
|
278 |
-
|
279 |
|
280 |
|
281 |
|
@@ -305,4 +309,11 @@ with gr.Blocks(css="""
|
|
305 |
outputs=[csv_output, save_output] # Return both the file and status
|
306 |
)
|
307 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
308 |
demo.launch()
|
|
|
121 |
success_count = 0
|
122 |
error_count = 0
|
123 |
image_paths = []
|
124 |
+
edited_image_paths = [] # List to store paths of edited images
|
125 |
+
|
126 |
# First, extract all image paths
|
127 |
for i in range(100):
|
128 |
idx = i * 6
|
|
|
142 |
keywords = args[idx + 5]
|
143 |
if write_metadata_to_image(copied_path, title, description, keywords):
|
144 |
success_count += 1
|
145 |
+
edited_image_paths.append(copied_path) # Add edited image path to the list
|
146 |
else:
|
147 |
error_count += 1
|
148 |
|
149 |
+
return (f"Images copied and metadata updated. Successful updates: {success_count}, Failed updates: {error_count}.", edited_image_paths)
|
150 |
+
|
151 |
|
152 |
def copy_images_to_project_dir(image_paths):
|
153 |
copied_paths = []
|
|
|
275 |
|
276 |
# Save Buttons and Output
|
277 |
with gr.Row():
|
278 |
+
save_metadata_button = gr.Button("Save Metadata to Images")
|
279 |
save_csv_button = gr.Button("Save CSV")
|
280 |
save_output = gr.Textbox(label="Save Status", interactive=False)
|
281 |
csv_output = gr.File(label="Download CSV") # File download component
|
282 |
+
edited_images_output = gr.File(label="Download Edited Images", file_count="multiple") # Add this line
|
283 |
|
284 |
|
285 |
|
|
|
309 |
outputs=[csv_output, save_output] # Return both the file and status
|
310 |
)
|
311 |
|
312 |
+
save_metadata_button.click(
|
313 |
+
fn=update_image_metadata,
|
314 |
+
inputs=all_outputs,
|
315 |
+
outputs=[save_output, gr.File(label="Download Edited Images", file_count="multiple")] # Add file output for edited images
|
316 |
+
)
|
317 |
+
|
318 |
+
|
319 |
demo.launch()
|