Commit
·
9023327
1
Parent(s):
455f086
fix: resolve merge conflicts and update UI
Browse files
app.py
CHANGED
|
@@ -30,15 +30,18 @@ def process_document(file):
|
|
| 30 |
if file is None:
|
| 31 |
return "Please upload an insurance claim document", None, None
|
| 32 |
|
|
|
|
|
|
|
|
|
|
| 33 |
# Handle PDF files
|
| 34 |
-
if
|
| 35 |
# Convert first page of PDF to image
|
| 36 |
images = pdf2image.convert_from_bytes(file.read(), first_page=1, last_page=1)
|
| 37 |
if not images:
|
| 38 |
return "Failed to process insurance claim PDF", None, None
|
| 39 |
image = images[0]
|
| 40 |
# Handle image files
|
| 41 |
-
elif
|
| 42 |
image = Image.open(file)
|
| 43 |
else:
|
| 44 |
return "Unsupported file format. Please upload PDF or image files.", None, None
|
|
@@ -151,7 +154,7 @@ with gr.Blocks(css=custom_css) as iface:
|
|
| 151 |
with gr.Column():
|
| 152 |
file_input = gr.File(
|
| 153 |
label="Upload Insurance Claim Document",
|
| 154 |
-
file_types=["pdf", "png", "jpg", "jpeg"],
|
| 155 |
elem_classes="file-upload"
|
| 156 |
)
|
| 157 |
|
|
|
|
| 30 |
if file is None:
|
| 31 |
return "Please upload an insurance claim document", None, None
|
| 32 |
|
| 33 |
+
# Get file extension
|
| 34 |
+
file_extension = os.path.splitext(file.name)[1].lower()
|
| 35 |
+
|
| 36 |
# Handle PDF files
|
| 37 |
+
if file_extension == '.pdf':
|
| 38 |
# Convert first page of PDF to image
|
| 39 |
images = pdf2image.convert_from_bytes(file.read(), first_page=1, last_page=1)
|
| 40 |
if not images:
|
| 41 |
return "Failed to process insurance claim PDF", None, None
|
| 42 |
image = images[0]
|
| 43 |
# Handle image files
|
| 44 |
+
elif file_extension in ('.png', '.jpg', '.jpeg'):
|
| 45 |
image = Image.open(file)
|
| 46 |
else:
|
| 47 |
return "Unsupported file format. Please upload PDF or image files.", None, None
|
|
|
|
| 154 |
with gr.Column():
|
| 155 |
file_input = gr.File(
|
| 156 |
label="Upload Insurance Claim Document",
|
| 157 |
+
file_types=[".pdf", ".png", ".jpg", ".jpeg"], # Changed from ["pdf", "png", "jpg", "jpeg"]
|
| 158 |
elem_classes="file-upload"
|
| 159 |
)
|
| 160 |
|