Skip to content

Commit 9a37c9b

Browse files
author
Daniel Lorch
committed
chore: show inference results in notebook
1 parent ba689fa commit 9a37c9b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

notebooks/misc/e2e-example-with-multimodal-page-classification-few-shot-prompting.ipynb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
"import boto3\n",
109109
"import logging\n",
110110
"import datetime\n",
111+
"import pprint\n",
111112
"\n",
112113
"# Import base libraries\n",
113114
"from idp_common.models import Document, Status, Section, Page\n",
@@ -393,7 +394,16 @@
393394
"\n",
394395
"document_dict = document.to_dict()\n",
395396
"sections_json = json.dumps(document_dict[\"sections\"][:n], indent=2)\n",
396-
"print(f\"{sections_json}...\")"
397+
"print(f\"{sections_json}...\")\n",
398+
"\n",
399+
"for section in document.sections[:n]:\n",
400+
" print(f\"\\nSection {section.section_id} extraction result:\")\n",
401+
" extraction_result_uri = section.extraction_result_uri\n",
402+
" bucket, key = parse_s3_uri(extraction_result_uri)\n",
403+
" response = s3_client.get_object(Bucket=bucket, Key=key)\n",
404+
" content = response['Body'].read().decode('utf-8')\n",
405+
" result = json.loads(content)\n",
406+
" pprint.pp(result[\"inference_result\"])"
397407
]
398408
},
399409
{

0 commit comments

Comments
 (0)