Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -46,7 +46,7 @@ def save_text(text):
|
|
46 |
temp_file = "metadata.jsonl"
|
47 |
with open(temp_file, "w") as f:
|
48 |
f.write(text)
|
49 |
-
return temp_file
|
50 |
|
51 |
|
52 |
# Create Gradio interface
|
@@ -61,13 +61,16 @@ with gr.Blocks(title="VL-HF Annotations Converter") as iface:
|
|
61 |
|
62 |
with gr.Row():
|
63 |
output_text = gr.Textbox(label="Converted JSONL output", lines=10)
|
64 |
-
download_btn = gr.DownloadButton(
|
|
|
|
|
65 |
|
66 |
# Connect the components
|
67 |
-
input_file.change(
|
68 |
-
|
69 |
-
#
|
70 |
-
|
|
|
71 |
|
72 |
if __name__ == "__main__":
|
73 |
iface.launch()
|
|
|
46 |
temp_file = "metadata.jsonl"
|
47 |
with open(temp_file, "w") as f:
|
48 |
f.write(text)
|
49 |
+
return temp_file
|
50 |
|
51 |
|
52 |
# Create Gradio interface
|
|
|
61 |
|
62 |
with gr.Row():
|
63 |
output_text = gr.Textbox(label="Converted JSONL output", lines=10)
|
64 |
+
download_btn = gr.DownloadButton(
|
65 |
+
label="Download JSONL", value="metadata.jsonl", interactive=True
|
66 |
+
)
|
67 |
|
68 |
# Connect the components
|
69 |
+
output = input_file.change(
|
70 |
+
fn=process_metadata, inputs=[input_file], outputs=[output_text]
|
71 |
+
).then( # Chain the save operation immediately after processing
|
72 |
+
fn=save_text, inputs=[output_text], outputs=[download_btn]
|
73 |
+
)
|
74 |
|
75 |
if __name__ == "__main__":
|
76 |
iface.launch()
|