Update app.py
Browse files
app.py
CHANGED
@@ -159,7 +159,7 @@ with gr.Blocks() as demo:
|
|
159 |
|
160 |
with gr.Tab("Add Entry"):
|
161 |
with gr.Row():
|
162 |
-
image_input = gr.Image(label="Upload Image")
|
163 |
prompt_input = gr.Textbox(label="Prompt")
|
164 |
add_button = gr.Button("Add Entry")
|
165 |
|
@@ -189,7 +189,6 @@ with gr.Blocks() as demo:
|
|
189 |
|
190 |
with gr.Tab("Edit / Delete Entry"):
|
191 |
with gr.Column():
|
192 |
-
# Entry selector is referenced here, defined at the top level
|
193 |
selected_image = gr.Image(label="Selected Image", interactive=False)
|
194 |
selected_prompt = gr.Textbox(label="Current Prompt", interactive=False)
|
195 |
new_prompt_input = gr.Textbox(label="New Prompt (for Edit)")
|
@@ -256,15 +255,20 @@ with gr.Blocks() as demo:
|
|
256 |
|
257 |
with gr.Tab("Download Dataset"):
|
258 |
download_button = gr.Button("Download Dataset")
|
259 |
-
download_output = gr.File(label="Download Zip")
|
260 |
def download_dataset(current_dataset_name, datasets):
|
261 |
if not current_dataset_name:
|
262 |
return None, "No dataset selected."
|
263 |
if not datasets[current_dataset_name]:
|
264 |
return None, "Dataset is empty."
|
265 |
zip_buffer = save_dataset_to_zip(current_dataset_name, datasets[current_dataset_name])
|
266 |
-
#
|
267 |
-
|
|
|
|
|
|
|
|
|
|
|
268 |
download_button.click(
|
269 |
download_dataset,
|
270 |
inputs=[current_dataset_name, datasets],
|
|
|
159 |
|
160 |
with gr.Tab("Add Entry"):
|
161 |
with gr.Row():
|
162 |
+
image_input = gr.Image(label="Upload Image", type="numpy")
|
163 |
prompt_input = gr.Textbox(label="Prompt")
|
164 |
add_button = gr.Button("Add Entry")
|
165 |
|
|
|
189 |
|
190 |
with gr.Tab("Edit / Delete Entry"):
|
191 |
with gr.Column():
|
|
|
192 |
selected_image = gr.Image(label="Selected Image", interactive=False)
|
193 |
selected_prompt = gr.Textbox(label="Current Prompt", interactive=False)
|
194 |
new_prompt_input = gr.Textbox(label="New Prompt (for Edit)")
|
|
|
255 |
|
256 |
with gr.Tab("Download Dataset"):
|
257 |
download_button = gr.Button("Download Dataset")
|
258 |
+
download_output = gr.File(label="Download Zip", interactive=False)
|
259 |
def download_dataset(current_dataset_name, datasets):
|
260 |
if not current_dataset_name:
|
261 |
return None, "No dataset selected."
|
262 |
if not datasets[current_dataset_name]:
|
263 |
return None, "Dataset is empty."
|
264 |
zip_buffer = save_dataset_to_zip(current_dataset_name, datasets[current_dataset_name])
|
265 |
+
# Write zip_buffer to a temporary file
|
266 |
+
temp_dir = tempfile.mkdtemp()
|
267 |
+
zip_path = os.path.join(temp_dir, f"{current_dataset_name}.zip")
|
268 |
+
with open(zip_path, 'wb') as f:
|
269 |
+
f.write(zip_buffer.getvalue())
|
270 |
+
return zip_path, f"Dataset '{current_dataset_name}' is ready for download."
|
271 |
+
|
272 |
download_button.click(
|
273 |
download_dataset,
|
274 |
inputs=[current_dataset_name, datasets],
|