Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -228,8 +228,12 @@ def extract_fields_from_image(image_path, progress=None):
|
|
| 228 |
progress(0.25, desc="Preparing prompt...")
|
| 229 |
|
| 230 |
# Prompt engineering: Carefully crafted prompt for multilingual form extraction
|
| 231 |
-
prompt = "<image_soft_token> Extract all the
|
| 232 |
-
print(f"[Prompt] Using engineered prompt: {prompt[:80]}...")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
|
| 234 |
if progress:
|
| 235 |
progress(0.35, desc="Tokenizing inputs...")
|
|
|
|
| 228 |
progress(0.25, desc="Preparing prompt...")
|
| 229 |
|
| 230 |
# Prompt engineering: Carefully crafted prompt for multilingual form extraction
|
| 231 |
+
# prompt = "<image_soft_token> Extract all the form field labels from this image. Return ONLY a JSON object where keys are field names and values are 'text'. For Hindi/Devanagari forms, preserve the original script. Do NOT include any introductory or concluding text."
|
| 232 |
+
# print(f"[Prompt] Using engineered prompt: {prompt[:80]}...")
|
| 233 |
+
|
| 234 |
+
prompt = "Extract all form field labels from this image. Return ONLY a JSON object where keys are field names and values are 'text'. For Hindi/Devanagari forms, preserve the original script. Do NOT include any introductory or concluding text."
|
| 235 |
+
messages = [{"role": "user", "content": [{"type": "image", "image": image}, {"type": "text", "text": prompt}]}]
|
| 236 |
+
|
| 237 |
|
| 238 |
if progress:
|
| 239 |
progress(0.35, desc="Tokenizing inputs...")
|