Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -120,7 +120,7 @@ async def run_ocr(file: UploadFile) -> str:
|
|
| 120 |
image_b64 = base64.b64encode(content).decode()
|
| 121 |
|
| 122 |
# FIX 2: Matches reference limit — base64 must be < 180,000 characters
|
| 123 |
-
if len(image_b64) >=
|
| 124 |
raise HTTPException(
|
| 125 |
status_code=413,
|
| 126 |
detail="Image too large (base64 must be < 1,000,000 chars). Resize the image and try again.",
|
|
@@ -270,7 +270,7 @@ async def extract_front(file: UploadFile = File(...)):
|
|
| 270 |
img_byte_arr.seek(0)
|
| 271 |
image_b64 = base64.b64encode(img_byte_arr.getvalue()).decode()
|
| 272 |
|
| 273 |
-
if len(image_b64) >=
|
| 274 |
page_result["error"] = "Image too large. Resize and try again."
|
| 275 |
results.append(page_result)
|
| 276 |
continue
|
|
@@ -341,7 +341,7 @@ async def extract_back(file: UploadFile = File(...)):
|
|
| 341 |
img_byte_arr.seek(0)
|
| 342 |
image_b64 = base64.b64encode(img_byte_arr.getvalue()).decode()
|
| 343 |
|
| 344 |
-
if len(image_b64) >=
|
| 345 |
page_result["error"] = "Image too large. Resize and try again."
|
| 346 |
results.append(page_result)
|
| 347 |
continue
|
|
@@ -419,7 +419,7 @@ async def extract_pdf(file: UploadFile = File(...)):
|
|
| 419 |
img_byte_arr.seek(0)
|
| 420 |
image_b64 = base64.b64encode(img_byte_arr.getvalue()).decode()
|
| 421 |
|
| 422 |
-
if len(image_b64) >=
|
| 423 |
page_result["error"] = "Image too large. Resize and try again."
|
| 424 |
results.append(page_result)
|
| 425 |
continue
|
|
|
|
| 120 |
image_b64 = base64.b64encode(content).decode()
|
| 121 |
|
| 122 |
# FIX 2: Matches reference limit — base64 must be < 180,000 characters
|
| 123 |
+
if len(image_b64) >= 3000_000:
|
| 124 |
raise HTTPException(
|
| 125 |
status_code=413,
|
| 126 |
detail="Image too large (base64 must be < 1,000,000 chars). Resize the image and try again.",
|
|
|
|
| 270 |
img_byte_arr.seek(0)
|
| 271 |
image_b64 = base64.b64encode(img_byte_arr.getvalue()).decode()
|
| 272 |
|
| 273 |
+
if len(image_b64) >= 3_600_000:
|
| 274 |
page_result["error"] = "Image too large. Resize and try again."
|
| 275 |
results.append(page_result)
|
| 276 |
continue
|
|
|
|
| 341 |
img_byte_arr.seek(0)
|
| 342 |
image_b64 = base64.b64encode(img_byte_arr.getvalue()).decode()
|
| 343 |
|
| 344 |
+
if len(image_b64) >= 3_600_000:
|
| 345 |
page_result["error"] = "Image too large. Resize and try again."
|
| 346 |
results.append(page_result)
|
| 347 |
continue
|
|
|
|
| 419 |
img_byte_arr.seek(0)
|
| 420 |
image_b64 = base64.b64encode(img_byte_arr.getvalue()).decode()
|
| 421 |
|
| 422 |
+
if len(image_b64) >= 3_600_000:
|
| 423 |
page_result["error"] = "Image too large. Resize and try again."
|
| 424 |
results.append(page_result)
|
| 425 |
continue
|