Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,6 +16,7 @@ def extract_info(image: Image.Image) -> str:
|
|
| 16 |
image = image.convert("L")
|
| 17 |
# Extract text from the image
|
| 18 |
text = pytesseract.image_to_string(image)
|
|
|
|
| 19 |
if not text.strip():
|
| 20 |
return json.dumps({"error": "No text could be extracted from the image."}, indent=2)
|
| 21 |
|
|
@@ -29,6 +30,7 @@ def extract_info(image: Image.Image) -> str:
|
|
| 29 |
"Extract all structured information from the given OCR text "
|
| 30 |
"and return it as a clean JSON object. "
|
| 31 |
"Do not include any explanation or markdown formatting."
|
|
|
|
| 32 |
),
|
| 33 |
},
|
| 34 |
{"role": "user", "content": f"Extract structured JSON from this OCR text:\n\n{text}"},
|
|
|
|
| 16 |
image = image.convert("L")
|
| 17 |
# Extract text from the image
|
| 18 |
text = pytesseract.image_to_string(image)
|
| 19 |
+
|
| 20 |
if not text.strip():
|
| 21 |
return json.dumps({"error": "No text could be extracted from the image."}, indent=2)
|
| 22 |
|
|
|
|
| 30 |
"Extract all structured information from the given OCR text "
|
| 31 |
"and return it as a clean JSON object. "
|
| 32 |
"Do not include any explanation or markdown formatting."
|
| 33 |
+
"Format in a simple json and avoid nested json."
|
| 34 |
),
|
| 35 |
},
|
| 36 |
{"role": "user", "content": f"Extract structured JSON from this OCR text:\n\n{text}"},
|