Update app.py
Browse files
app.py
CHANGED
|
@@ -54,10 +54,6 @@ def simple_parse_lines(text: str):
|
|
| 54 |
"Price": price_value,
|
| 55 |
"Category": current_category if current_category else ""
|
| 56 |
})
|
| 57 |
-
else:
|
| 58 |
-
# If no price, optionally keep as a note; comment out if you prefer dropping
|
| 59 |
-
pass
|
| 60 |
-
|
| 61 |
return rows
|
| 62 |
|
| 63 |
def process_images_to_zip(files):
|
|
@@ -65,9 +61,9 @@ def process_images_to_zip(files):
|
|
| 65 |
work_dir = tempfile.mkdtemp(prefix="menu_excel_")
|
| 66 |
output_files = []
|
| 67 |
|
| 68 |
-
for idx,
|
| 69 |
# Load image
|
| 70 |
-
image = Image.open(
|
| 71 |
image = preprocess_image(image)
|
| 72 |
|
| 73 |
# OCR
|
|
@@ -99,7 +95,12 @@ def process_images_to_zip(files):
|
|
| 99 |
with gr.Blocks(title="Menu to Excel (one file per image)") as demo:
|
| 100 |
gr.Markdown("## Menu to Excel converter\nUpload menu images to get a ZIP containing separate Excel files (one per image).")
|
| 101 |
with gr.Row():
|
| 102 |
-
input_files = gr.File(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
run_btn = gr.Button("Process")
|
| 104 |
output_zip = gr.File(label="Download ZIP")
|
| 105 |
|
|
|
|
| 54 |
"Price": price_value,
|
| 55 |
"Category": current_category if current_category else ""
|
| 56 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
return rows
|
| 58 |
|
| 59 |
def process_images_to_zip(files):
|
|
|
|
| 61 |
work_dir = tempfile.mkdtemp(prefix="menu_excel_")
|
| 62 |
output_files = []
|
| 63 |
|
| 64 |
+
for idx, file_path in enumerate(files, start=1):
|
| 65 |
# Load image
|
| 66 |
+
image = Image.open(file_path).convert("RGB")
|
| 67 |
image = preprocess_image(image)
|
| 68 |
|
| 69 |
# OCR
|
|
|
|
| 95 |
with gr.Blocks(title="Menu to Excel (one file per image)") as demo:
|
| 96 |
gr.Markdown("## Menu to Excel converter\nUpload menu images to get a ZIP containing separate Excel files (one per image).")
|
| 97 |
with gr.Row():
|
| 98 |
+
input_files = gr.File(
|
| 99 |
+
label="Upload menu images",
|
| 100 |
+
file_count="multiple",
|
| 101 |
+
type="filepath", # ✅ fixed here
|
| 102 |
+
file_types=[".png", ".jpg", ".jpeg"]
|
| 103 |
+
)
|
| 104 |
run_btn = gr.Button("Process")
|
| 105 |
output_zip = gr.File(label="Download ZIP")
|
| 106 |
|