prithivMLmods commited on
Commit
735e3fc
·
verified ·
1 Parent(s): cd4e155

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -9
app.py CHANGED
@@ -5,6 +5,7 @@ import pyarrow.parquet as pq
5
  from PIL import Image
6
  import io
7
  import base64
 
8
 
9
  def image_to_parquet(files):
10
  # List to store image data
@@ -28,15 +29,12 @@ def image_to_parquet(files):
28
  table = pa.Table.from_pandas(df)
29
 
30
  # Save table as Parquet file
31
- parquet_buffer = io.BytesIO()
32
- pq.write_table(table, parquet_buffer)
 
33
 
34
- # Return Parquet file
35
- parquet_buffer.seek(0)
36
- return parquet_buffer
37
-
38
- def download_parquet(file):
39
- return file
40
 
41
  # Gradio interface
42
  with gr.Blocks() as demo:
@@ -48,4 +46,4 @@ with gr.Blocks() as demo:
48
 
49
  convert_button.click(fn=image_to_parquet, inputs=[image_input], outputs=[download_button])
50
 
51
- demo.launch(share=True)
 
5
  from PIL import Image
6
  import io
7
  import base64
8
+ import tempfile
9
 
10
  def image_to_parquet(files):
11
  # List to store image data
 
29
  table = pa.Table.from_pandas(df)
30
 
31
  # Save table as Parquet file
32
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".parquet") as tmp_file:
33
+ pq.write_table(table, tmp_file)
34
+ parquet_file_path = tmp_file.name
35
 
36
+ # Return Parquet file path
37
+ return parquet_file_path
 
 
 
 
38
 
39
  # Gradio interface
40
  with gr.Blocks() as demo:
 
46
 
47
  convert_button.click(fn=image_to_parquet, inputs=[image_input], outputs=[download_button])
48
 
49
+ demo.launch()