Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
32 |
-
|
|
|
33 |
|
34 |
-
# Return Parquet file
|
35 |
-
|
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(
|
|
|
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()
|