Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -232,7 +232,7 @@ def read_root():
|
|
| 232 |
return {"message": "Welcome to the Invoice Summarization API!"}
|
| 233 |
|
| 234 |
@app.get("/ocr/extraction")
|
| 235 |
-
def
|
| 236 |
api_key: str = Depends(verify_api_key),
|
| 237 |
file_key: str = Query(..., description="S3 file key for the file"),
|
| 238 |
document_type: str = Query(..., description="Type of document"),
|
|
@@ -248,9 +248,9 @@ def ocr_from_s3(
|
|
| 248 |
summary = None
|
| 249 |
|
| 250 |
if content_type.startswith("image/"): # Image file
|
| 251 |
-
image = Image.open(io.BytesIO(file_data)).convert("RGB")
|
| 252 |
-
extracted_text.append(pytesseract.image_to_string(image))
|
| 253 |
-
|
| 254 |
# If single image, store Base64
|
| 255 |
base64Data = base64.b64encode(file_data).decode('utf-8')
|
| 256 |
base64DataResp = f"data:image/{content_type.lower()};base64,{base64Data}"
|
|
|
|
| 232 |
return {"message": "Welcome to the Invoice Summarization API!"}
|
| 233 |
|
| 234 |
@app.get("/ocr/extraction")
|
| 235 |
+
def extract_text_from_file(
|
| 236 |
api_key: str = Depends(verify_api_key),
|
| 237 |
file_key: str = Query(..., description="S3 file key for the file"),
|
| 238 |
document_type: str = Query(..., description="Type of document"),
|
|
|
|
| 248 |
summary = None
|
| 249 |
|
| 250 |
if content_type.startswith("image/"): # Image file
|
| 251 |
+
# image = Image.open(io.BytesIO(file_data)).convert("RGB")
|
| 252 |
+
# extracted_text.append(pytesseract.image_to_string(image))
|
| 253 |
+
|
| 254 |
# If single image, store Base64
|
| 255 |
base64Data = base64.b64encode(file_data).decode('utf-8')
|
| 256 |
base64DataResp = f"data:image/{content_type.lower()};base64,{base64Data}"
|