dnth commited on
Commit
7c6e75e
·
verified ·
1 Parent(s): 488ebed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
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 # Return only the file path
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(label="Download JSONL", interactive=True)
 
 
65
 
66
  # Connect the components
67
- input_file.change(fn=process_metadata, inputs=[input_file], outputs=[output_text])
68
-
69
- # Connect download button directly to output text
70
- download_btn.click(fn=save_text, inputs=[output_text], outputs=[download_btn])
 
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()