Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -109,7 +109,7 @@ def ocr_from_s3(api_key: str = Depends(verify_api_key),file_key: str = Query(...
|
|
| 109 |
image = Image.open(io.BytesIO(file_data)).convert("RGB") # Use BytesIO stream directly
|
| 110 |
image_np = np.array(image) # Convert to NumPy array
|
| 111 |
result = ocr.ocr(image_np, cls=True)
|
| 112 |
-
base64DataResp = f"data:image/{content_type.lower()};base64,{
|
| 113 |
# Extract text from OCR results
|
| 114 |
for line in result:
|
| 115 |
for word_info in line:
|
|
@@ -139,7 +139,7 @@ def ocr_from_s3(api_key: str = Depends(verify_api_key),file_key: str = Query(...
|
|
| 139 |
extracted_text.append(word_info[1][0])
|
| 140 |
|
| 141 |
pdf_document.close()
|
| 142 |
-
base64DataResp = f"data:application/pdf;base64,{
|
| 143 |
else:
|
| 144 |
return {"error": f"Unsupported file type: {content_type}"}
|
| 145 |
|
|
|
|
| 109 |
image = Image.open(io.BytesIO(file_data)).convert("RGB") # Use BytesIO stream directly
|
| 110 |
image_np = np.array(image) # Convert to NumPy array
|
| 111 |
result = ocr.ocr(image_np, cls=True)
|
| 112 |
+
base64DataResp = f"data:image/{content_type.lower()};base64,{base64Data}"
|
| 113 |
# Extract text from OCR results
|
| 114 |
for line in result:
|
| 115 |
for word_info in line:
|
|
|
|
| 139 |
extracted_text.append(word_info[1][0])
|
| 140 |
|
| 141 |
pdf_document.close()
|
| 142 |
+
base64DataResp = f"data:application/pdf;base64,{base64Data}"
|
| 143 |
else:
|
| 144 |
return {"error": f"Unsupported file type: {content_type}"}
|
| 145 |
|