Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -43,7 +43,7 @@ def get_content_type(url):
|
|
43 |
|
44 |
def perform_ocr_file(file, ocr_method="Mistral OCR"):
|
45 |
if ocr_method == "Mistral OCR":
|
46 |
-
if
|
47 |
uploaded_pdf = client.files.upload(
|
48 |
file={
|
49 |
"file_name": file.name,
|
@@ -62,7 +62,7 @@ def perform_ocr_file(file, ocr_method="Mistral OCR"):
|
|
62 |
)
|
63 |
client.files.delete(file_id=uploaded_pdf.id)
|
64 |
|
65 |
-
elif
|
66 |
base64_image = encode_image(file.name)
|
67 |
ocr_response = client.ocr.process(
|
68 |
model="mistral-ocr-latest",
|
|
|
43 |
|
44 |
def perform_ocr_file(file, ocr_method="Mistral OCR"):
|
45 |
if ocr_method == "Mistral OCR":
|
46 |
+
if file.name.lower().endswith('.pdf'):
|
47 |
uploaded_pdf = client.files.upload(
|
48 |
file={
|
49 |
"file_name": file.name,
|
|
|
62 |
)
|
63 |
client.files.delete(file_id=uploaded_pdf.id)
|
64 |
|
65 |
+
elif file.name.lower().endswith(('.png', '.jpg', '.jpeg')):
|
66 |
base64_image = encode_image(file.name)
|
67 |
ocr_response = client.ocr.process(
|
68 |
model="mistral-ocr-latest",
|