AMMICO/build/html/notebooks/Example summary.ipynb

2831 строка
64 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Image summary and visual question answering"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebooks shows some preliminary work on Image Captioning and Visual question answering with lavis. It is mainly meant to explore its capabilities and to decide on future research directions. We package our code into a `ammico` package that is imported here:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-16T08:52:39.041361Z",
"iopub.status.busy": "2023-05-16T08:52:39.041037Z",
"iopub.status.idle": "2023-05-16T08:52:51.693387Z",
"shell.execute_reply": "2023-05-16T08:52:51.692579Z"
},
"tags": []
},
"outputs": [],
"source": [
"from ammico import utils as mutils\n",
"from ammico import display as mdisplay\n",
"import ammico.summary as sm"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Set an image path as input file path."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-16T08:52:51.697459Z",
"iopub.status.busy": "2023-05-16T08:52:51.696630Z",
"iopub.status.idle": "2023-05-16T08:52:51.701311Z",
"shell.execute_reply": "2023-05-16T08:52:51.700575Z"
},
"tags": []
},
"outputs": [],
"source": [
"images = mutils.find_files(\n",
" path=\"data/\",\n",
" limit=10,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-16T08:52:51.704482Z",
"iopub.status.busy": "2023-05-16T08:52:51.704200Z",
"iopub.status.idle": "2023-05-16T08:52:51.707999Z",
"shell.execute_reply": "2023-05-16T08:52:51.707195Z"
},
"tags": []
},
"outputs": [],
"source": [
"mydict = mutils.initialize_dict(images)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Create captions for images and directly write to csv"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here you can choose between two models: \"base\" or \"large\""
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-16T08:52:51.711304Z",
"iopub.status.busy": "2023-05-16T08:52:51.710804Z",
"iopub.status.idle": "2023-05-16T08:53:19.327537Z",
"shell.execute_reply": "2023-05-16T08:53:19.326400Z"
},
"tags": []
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 0%| | 0.00/2.50G [00:00<?, ?B/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 0%| | 4.37M/2.50G [00:00<00:58, 45.8MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 1%| | 23.8M/2.50G [00:00<00:19, 139MB/s] "
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 2%|▏ | 43.0M/2.50G [00:00<00:15, 167MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 2%|▏ | 64.0M/2.50G [00:00<00:14, 183MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 3%|▎ | 82.8M/2.50G [00:00<00:13, 188MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 4%|▍ | 107M/2.50G [00:00<00:12, 208MB/s] "
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 5%|▌ | 129M/2.50G [00:00<00:11, 216MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 6%|▌ | 152M/2.50G [00:00<00:11, 224MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 7%|▋ | 177M/2.50G [00:00<00:10, 235MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 8%|▊ | 200M/2.50G [00:01<00:10, 238MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 9%|▊ | 223M/2.50G [00:01<00:10, 238MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 10%|▉ | 246M/2.50G [00:01<00:10, 239MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 11%|█ | 270M/2.50G [00:01<00:09, 243MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 11%|█▏ | 293M/2.50G [00:01<00:09, 240MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 12%|█▏ | 316M/2.50G [00:01<00:09, 238MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 13%|█▎ | 338M/2.50G [00:01<00:09, 239MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 14%|█▍ | 361M/2.50G [00:01<00:09, 239MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 15%|█▍ | 384M/2.50G [00:01<00:09, 239MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 16%|█▌ | 408M/2.50G [00:01<00:09, 241MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 17%|█▋ | 431M/2.50G [00:02<00:09, 242MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 18%|█▊ | 454M/2.50G [00:02<00:09, 242MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 19%|█▊ | 477M/2.50G [00:02<00:09, 239MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 19%|█▉ | 500M/2.50G [00:02<00:09, 238MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 20%|██ | 523M/2.50G [00:02<00:09, 218MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 21%|██ | 544M/2.50G [00:02<00:10, 203MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 22%|██▏ | 566M/2.50G [00:02<00:09, 212MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 23%|██▎ | 590M/2.50G [00:02<00:09, 222MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 24%|██▍ | 614M/2.50G [00:02<00:08, 230MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 25%|██▍ | 636M/2.50G [00:03<00:11, 182MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 26%|██▌ | 666M/2.50G [00:03<00:09, 213MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 27%|██▋ | 692M/2.50G [00:03<00:08, 230MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 28%|██▊ | 719M/2.50G [00:03<00:07, 243MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 29%|██▉ | 746M/2.50G [00:03<00:07, 255MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 30%|███ | 773M/2.50G [00:03<00:07, 264MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 31%|███ | 799M/2.50G [00:03<00:10, 172MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 32%|███▏ | 828M/2.50G [00:03<00:09, 200MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 33%|███▎ | 855M/2.50G [00:04<00:08, 218MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 34%|███▍ | 879M/2.50G [00:04<00:07, 228MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 35%|███▌ | 904M/2.50G [00:04<00:07, 228MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 36%|███▋ | 932M/2.50G [00:04<00:06, 247MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 37%|███▋ | 960M/2.50G [00:04<00:06, 242MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 38%|███▊ | 986M/2.50G [00:04<00:06, 252MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 39%|███▉ | 0.99G/2.50G [00:04<00:06, 253MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 40%|████ | 1.01G/2.50G [00:05<00:10, 157MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 41%|████▏ | 1.03G/2.50G [00:05<00:09, 172MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 42%|████▏ | 1.05G/2.50G [00:05<00:08, 177MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 43%|████▎ | 1.08G/2.50G [00:05<00:07, 195MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 44%|████▍ | 1.10G/2.50G [00:05<00:09, 165MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 45%|████▍ | 1.12G/2.50G [00:05<00:08, 180MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 46%|████▌ | 1.14G/2.50G [00:05<00:07, 194MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 46%|████▋ | 1.16G/2.50G [00:05<00:07, 182MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 47%|████▋ | 1.18G/2.50G [00:06<00:08, 170MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 48%|████▊ | 1.20G/2.50G [00:06<00:07, 176MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 49%|████▉ | 1.22G/2.50G [00:06<00:07, 191MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 50%|████▉ | 1.25G/2.50G [00:06<00:06, 205MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 51%|█████ | 1.27G/2.50G [00:06<00:06, 218MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 52%|█████▏ | 1.30G/2.50G [00:06<00:05, 230MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 53%|█████▎ | 1.32G/2.50G [00:06<00:05, 235MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 54%|█████▎ | 1.34G/2.50G [00:06<00:05, 241MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 55%|█████▍ | 1.37G/2.50G [00:06<00:04, 247MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 56%|█████▌ | 1.39G/2.50G [00:06<00:04, 249MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 56%|█████▋ | 1.41G/2.50G [00:07<00:04, 248MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 57%|█████▋ | 1.44G/2.50G [00:07<00:04, 248MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 58%|█████▊ | 1.46G/2.50G [00:07<00:04, 248MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 59%|█████▉ | 1.48G/2.50G [00:07<00:04, 244MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 60%|██████ | 1.51G/2.50G [00:07<00:04, 222MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 61%|██████ | 1.53G/2.50G [00:07<00:04, 225MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 62%|██████▏ | 1.55G/2.50G [00:09<00:21, 46.8MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 62%|██████▏ | 1.56G/2.50G [00:09<00:18, 55.3MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 63%|██████▎ | 1.58G/2.50G [00:09<00:14, 67.8MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 64%|██████▍ | 1.60G/2.50G [00:09<00:11, 84.5MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 65%|██████▍ | 1.62G/2.50G [00:09<00:09, 102MB/s] "
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 66%|██████▌ | 1.64G/2.50G [00:09<00:07, 124MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 66%|██████▌ | 1.66G/2.50G [00:09<00:06, 138MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 67%|██████▋ | 1.68G/2.50G [00:09<00:05, 163MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 68%|██████▊ | 1.71G/2.50G [00:09<00:04, 185MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 69%|██████▉ | 1.73G/2.50G [00:09<00:04, 201MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 70%|██████▉ | 1.75G/2.50G [00:10<00:03, 214MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 71%|███████ | 1.78G/2.50G [00:10<00:03, 225MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 72%|███████▏ | 1.80G/2.50G [00:10<00:03, 229MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 73%|███████▎ | 1.82G/2.50G [00:10<00:03, 219MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 74%|███████▎ | 1.84G/2.50G [00:10<00:03, 227MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 75%|███████▍ | 1.87G/2.50G [00:10<00:03, 228MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 75%|███████▌ | 1.89G/2.50G [00:10<00:02, 226MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 76%|███████▌ | 1.91G/2.50G [00:10<00:02, 216MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 77%|███████▋ | 1.93G/2.50G [00:10<00:02, 231MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 78%|███████▊ | 1.96G/2.50G [00:10<00:02, 230MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 79%|███████▉ | 1.98G/2.50G [00:11<00:02, 240MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 80%|████████ | 2.01G/2.50G [00:11<00:02, 250MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 81%|████████ | 2.03G/2.50G [00:11<00:01, 256MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 82%|████████▏ | 2.06G/2.50G [00:11<00:01, 261MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 83%|████████▎ | 2.08G/2.50G [00:11<00:01, 256MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 84%|████████▍ | 2.11G/2.50G [00:11<00:01, 261MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 85%|████████▌ | 2.13G/2.50G [00:11<00:01, 242MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 86%|████████▌ | 2.16G/2.50G [00:11<00:01, 249MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 87%|████████▋ | 2.18G/2.50G [00:11<00:01, 255MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 88%|████████▊ | 2.21G/2.50G [00:12<00:01, 262MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 89%|████████▉ | 2.23G/2.50G [00:12<00:01, 263MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 90%|█████████ | 2.26G/2.50G [00:13<00:04, 64.6MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 91%|█████████ | 2.27G/2.50G [00:13<00:04, 58.1MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 91%|█████████▏| 2.29G/2.50G [00:13<00:03, 69.9MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 92%|█████████▏| 2.31G/2.50G [00:13<00:02, 79.8MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 93%|█████████▎| 2.32G/2.50G [00:14<00:02, 90.6MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 93%|█████████▎| 2.34G/2.50G [00:14<00:01, 110MB/s] "
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 94%|█████████▍| 2.36G/2.50G [00:14<00:01, 116MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 95%|█████████▌| 2.38G/2.50G [00:14<00:00, 137MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 96%|█████████▌| 2.40G/2.50G [00:14<00:00, 154MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 97%|█████████▋| 2.42G/2.50G [00:14<00:00, 163MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 98%|█████████▊| 2.44G/2.50G [00:14<00:00, 187MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 98%|█████████▊| 2.46G/2.50G [00:15<00:00, 118MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 99%|█████████▉| 2.48G/2.50G [00:15<00:00, 144MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
"100%|██████████| 2.50G/2.50G [00:15<00:00, 177MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\n"
]
}
],
"source": [
"obj = sm.SummaryDetector(mydict)\n",
"summary_model, summary_vis_processors = obj.load_model(\"base\")\n",
"# summary_model, summary_vis_processors = obj.load_model(\"large\")"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-16T08:53:19.332464Z",
"iopub.status.busy": "2023-05-16T08:53:19.331847Z",
"iopub.status.idle": "2023-05-16T08:53:55.281645Z",
"shell.execute_reply": "2023-05-16T08:53:55.280790Z"
},
"tags": []
},
"outputs": [],
"source": [
"for key in mydict:\n",
" mydict[key] = sm.SummaryDetector(mydict[key]).analyse_image(\n",
" summary_model, summary_vis_processors\n",
" )"
]
},
{
"cell_type": "markdown",
"metadata": {
"tags": []
},
"source": [
"Convert the dictionary of dictionaries into a dictionary with lists:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-16T08:53:55.285992Z",
"iopub.status.busy": "2023-05-16T08:53:55.285470Z",
"iopub.status.idle": "2023-05-16T08:53:55.289680Z",
"shell.execute_reply": "2023-05-16T08:53:55.289099Z"
},
"tags": []
},
"outputs": [],
"source": [
"outdict = mutils.append_data_to_dict(mydict)\n",
"df = mutils.dump_df(outdict)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Check the dataframe:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-16T08:53:55.292832Z",
"iopub.status.busy": "2023-05-16T08:53:55.292351Z",
"iopub.status.idle": "2023-05-16T08:53:55.305632Z",
"shell.execute_reply": "2023-05-16T08:53:55.305048Z"
},
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>filename</th>\n",
" <th>const_image_summary</th>\n",
" <th>3_non-deterministic summary</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>data/102730_eng.png</td>\n",
" <td>two people in blue coats spray disinfection a van</td>\n",
" <td>[two people wearing blue uniforms spraying out...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>data/102141_2_eng.png</td>\n",
" <td>a collage of images including a corona sign, a...</td>\n",
" <td>[many pictures include people, signs, and a fe...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>data/106349S_por.png</td>\n",
" <td>a man wearing a face mask while looking at a c...</td>\n",
" <td>[a man in a face mask talking into the radio, ...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" filename const_image_summary \n",
"0 data/102730_eng.png two people in blue coats spray disinfection a van \\\n",
"1 data/102141_2_eng.png a collage of images including a corona sign, a... \n",
"2 data/106349S_por.png a man wearing a face mask while looking at a c... \n",
"\n",
" 3_non-deterministic summary \n",
"0 [two people wearing blue uniforms spraying out... \n",
"1 [many pictures include people, signs, and a fe... \n",
"2 [a man in a face mask talking into the radio, ... "
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.head(10)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Write the csv file:"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-16T08:53:55.308815Z",
"iopub.status.busy": "2023-05-16T08:53:55.308298Z",
"iopub.status.idle": "2023-05-16T08:53:55.313320Z",
"shell.execute_reply": "2023-05-16T08:53:55.312701Z"
},
"tags": []
},
"outputs": [],
"source": [
"df.to_csv(\"./data_out.csv\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Manually inspect the summaries\n",
"\n",
"To check the analysis, you can inspect the analyzed elements here. Loading the results takes a moment, so please be patient. If you are sure of what you are doing.\n",
"\n",
"`const_image_summary` - the permanent summarys, which does not change from run to run (analyse_image).\n",
"\n",
"`3_non-deterministic summary` - 3 different summarys examples that change from run to run (analyse_image). "
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-16T08:53:55.317337Z",
"iopub.status.busy": "2023-05-16T08:53:55.316858Z",
"iopub.status.idle": "2023-05-16T08:53:56.349975Z",
"shell.execute_reply": "2023-05-16T08:53:56.349193Z"
},
"tags": []
},
"outputs": [
{
"ename": "AttributeError",
"evalue": "module 'ammico.display' has no attribute 'explore_analysis'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[9], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mmdisplay\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mexplore_analysis\u001b[49m(mydict, identify\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msummary\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
"\u001b[0;31mAttributeError\u001b[0m: module 'ammico.display' has no attribute 'explore_analysis'"
]
}
],
"source": [
"mdisplay.explore_analysis(mydict, identify=\"summary\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Generate answers to free-form questions about images written in natural language. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Set the list of questions"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-16T08:53:56.353915Z",
"iopub.status.busy": "2023-05-16T08:53:56.353365Z",
"iopub.status.idle": "2023-05-16T08:53:56.357947Z",
"shell.execute_reply": "2023-05-16T08:53:56.357185Z"
}
},
"outputs": [],
"source": [
"list_of_questions = [\n",
" \"How many persons on the picture?\",\n",
" \"Are there any politicians in the picture?\",\n",
" \"Does the picture show something from medicine?\",\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-16T08:53:56.361531Z",
"iopub.status.busy": "2023-05-16T08:53:56.360977Z",
"iopub.status.idle": "2023-05-16T08:55:02.735011Z",
"shell.execute_reply": "2023-05-16T08:55:02.733473Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 0%| | 0.00/1.35G [00:00<?, ?B/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 0%| | 6.01M/1.35G [00:00<00:25, 55.4MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 1%| | 12.0M/1.35G [00:00<00:30, 46.6MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 1%|▏ | 17.5M/1.35G [00:00<00:31, 44.6MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 2%|▏ | 24.6M/1.35G [00:00<00:27, 51.2MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 2%|▏ | 30.1M/1.35G [00:00<00:30, 47.0MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 3%|▎ | 40.3M/1.35G [00:00<00:22, 63.6MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 3%|▎ | 48.0M/1.35G [00:00<00:20, 67.5MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 4%|▍ | 54.8M/1.35G [00:01<00:23, 58.6MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 5%|▍ | 64.6M/1.35G [00:01<00:20, 66.6MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 5%|▌ | 71.2M/1.35G [00:01<00:20, 66.9MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 6%|▌ | 79.3M/1.35G [00:01<00:19, 70.7MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 6%|▋ | 89.0M/1.35G [00:01<00:19, 68.4MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 7%|▋ | 95.7M/1.35G [00:01<00:23, 57.6MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 8%|▊ | 104M/1.35G [00:01<00:21, 62.8MB/s] "
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 8%|▊ | 111M/1.35G [00:01<00:21, 62.6MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 9%|▊ | 118M/1.35G [00:02<00:22, 59.9MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 9%|▉ | 124M/1.35G [00:02<00:21, 60.0MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 10%|▉ | 132M/1.35G [00:02<00:19, 65.5MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 10%|█ | 138M/1.35G [00:02<00:20, 63.8MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 11%|█ | 146M/1.35G [00:02<00:21, 60.9MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 11%|█ | 152M/1.35G [00:02<00:21, 59.4MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 12%|█▏ | 160M/1.35G [00:02<00:19, 64.6MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 12%|█▏ | 167M/1.35G [00:02<00:23, 54.0MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 12%|█▏ | 172M/1.35G [00:03<00:29, 42.6MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 13%|█▎ | 185M/1.35G [00:03<00:19, 62.6MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 14%|█▍ | 193M/1.35G [00:03<00:18, 67.3MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 15%|█▍ | 201M/1.35G [00:03<00:19, 62.5MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 15%|█▌ | 209M/1.35G [00:03<00:19, 63.0MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 16%|█▌ | 215M/1.35G [00:03<00:19, 62.7MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 16%|█▌ | 221M/1.35G [00:03<00:19, 61.1MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 17%|█▋ | 228M/1.35G [00:03<00:20, 59.1MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 17%|█▋ | 234M/1.35G [00:04<00:19, 60.1MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 18%|█▊ | 243M/1.35G [00:04<00:18, 62.9MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 18%|█▊ | 252M/1.35G [00:04<00:16, 71.2MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 19%|█▉ | 259M/1.35G [00:04<00:19, 61.0MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 20%|█▉ | 272M/1.35G [00:04<00:14, 78.9MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 20%|██ | 281M/1.35G [00:04<00:14, 77.4MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 21%|██ | 289M/1.35G [00:04<00:15, 72.3MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 22%|██▏ | 298M/1.35G [00:04<00:15, 73.5MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 22%|██▏ | 307M/1.35G [00:05<00:13, 80.3MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 23%|██▎ | 315M/1.35G [00:05<00:16, 68.8MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 23%|██▎ | 323M/1.35G [00:05<00:17, 64.4MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 24%|██▍ | 331M/1.35G [00:05<00:19, 56.8MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 25%|██▍ | 340M/1.35G [00:05<00:17, 63.1MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 25%|██▌ | 347M/1.35G [00:05<00:16, 65.2MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 26%|██▌ | 360M/1.35G [00:05<00:13, 80.0MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 27%|██▋ | 368M/1.35G [00:05<00:13, 80.6MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 27%|██▋ | 376M/1.35G [00:06<00:13, 78.7MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 28%|██▊ | 384M/1.35G [00:06<00:14, 73.9MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 29%|██▉ | 400M/1.35G [00:06<00:11, 88.5MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 30%|██▉ | 408M/1.35G [00:06<00:11, 87.8MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 30%|███ | 418M/1.35G [00:06<00:12, 82.3MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 31%|███▏ | 434M/1.35G [00:06<00:10, 98.3MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 32%|███▏ | 447M/1.35G [00:06<00:09, 108MB/s] "
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 33%|███▎ | 458M/1.35G [00:06<00:09, 104MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 34%|███▍ | 468M/1.35G [00:07<00:10, 94.4MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 35%|███▍ | 482M/1.35G [00:07<00:09, 98.6MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 36%|███▌ | 491M/1.35G [00:07<00:09, 95.3MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 37%|███▋ | 505M/1.35G [00:07<00:08, 108MB/s] "
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 37%|███▋ | 516M/1.35G [00:07<00:08, 103MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 38%|███▊ | 526M/1.35G [00:07<00:08, 102MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 39%|███▉ | 538M/1.35G [00:07<00:08, 99.0MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 40%|███▉ | 548M/1.35G [00:07<00:08, 102MB/s] "
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 40%|████ | 558M/1.35G [00:08<00:08, 97.0MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 41%|████ | 568M/1.35G [00:08<00:08, 96.3MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 42%|████▏ | 584M/1.35G [00:08<00:08, 93.8MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 43%|████▎ | 598M/1.35G [00:08<00:07, 108MB/s] "
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 44%|████▍ | 609M/1.35G [00:08<00:08, 93.6MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 45%|████▌ | 622M/1.35G [00:08<00:07, 104MB/s] "
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 46%|████▌ | 632M/1.35G [00:08<00:08, 96.7MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 47%|████▋ | 642M/1.35G [00:08<00:08, 87.2MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 47%|████▋ | 651M/1.35G [00:09<00:08, 89.5MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 48%|████▊ | 663M/1.35G [00:09<00:07, 96.6MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 49%|████▉ | 674M/1.35G [00:09<00:07, 103MB/s] "
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 50%|████▉ | 688M/1.35G [00:09<00:06, 108MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 51%|█████ | 704M/1.35G [00:09<00:06, 112MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 52%|█████▏ | 715M/1.35G [00:09<00:06, 108MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 53%|█████▎ | 725M/1.35G [00:09<00:06, 101MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 53%|█████▎ | 735M/1.35G [00:09<00:06, 98.1MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 54%|█████▍ | 744M/1.35G [00:10<00:07, 94.6MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 55%|█████▍ | 753M/1.35G [00:10<00:12, 53.2MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 56%|█████▌ | 768M/1.35G [00:10<00:09, 70.8MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 56%|█████▋ | 777M/1.35G [00:10<00:08, 74.3MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 57%|█████▋ | 787M/1.35G [00:10<00:09, 66.9MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 58%|█████▊ | 800M/1.35G [00:10<00:07, 79.4MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 59%|█████▊ | 809M/1.35G [00:11<00:07, 79.9MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 60%|█████▉ | 822M/1.35G [00:11<00:06, 93.7MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 60%|██████ | 832M/1.35G [00:11<00:08, 67.3MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 61%|██████ | 840M/1.35G [00:11<00:08, 70.5MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 62%|██████▏ | 856M/1.35G [00:11<00:06, 86.4MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 63%|██████▎ | 865M/1.35G [00:11<00:06, 81.5MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 64%|██████▍ | 880M/1.35G [00:11<00:06, 79.6MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 64%|██████▍ | 888M/1.35G [00:12<00:06, 77.1MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 65%|██████▍ | 896M/1.35G [00:12<00:06, 76.9MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 66%|██████▌ | 903M/1.35G [00:12<00:07, 71.0MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 66%|██████▌ | 910M/1.35G [00:12<00:07, 68.0MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 67%|██████▋ | 919M/1.35G [00:12<00:06, 73.3MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 67%|██████▋ | 926M/1.35G [00:12<00:07, 60.5MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 68%|██████▊ | 932M/1.35G [00:12<00:08, 57.7MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 68%|██████▊ | 939M/1.35G [00:12<00:07, 60.5MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 69%|██████▊ | 945M/1.35G [00:13<00:07, 57.3MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 69%|██████▉ | 951M/1.35G [00:13<00:08, 50.9MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 69%|██████▉ | 956M/1.35G [00:13<00:08, 49.8MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 70%|██████▉ | 963M/1.35G [00:13<00:07, 55.2MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 70%|███████ | 969M/1.35G [00:13<00:07, 56.8MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 71%|███████ | 977M/1.35G [00:13<00:07, 56.2MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 71%|███████ | 982M/1.35G [00:13<00:08, 48.7MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 72%|███████▏ | 989M/1.35G [00:14<00:07, 53.2MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 72%|███████▏ | 996M/1.35G [00:14<00:07, 57.3MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 73%|███████▎ | 0.98G/1.35G [00:14<00:06, 61.4MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 73%|███████▎ | 0.99G/1.35G [00:14<00:06, 58.1MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 74%|███████▎ | 0.99G/1.35G [00:14<00:06, 60.0MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 74%|███████▍ | 1.00G/1.35G [00:14<00:08, 44.3MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 75%|███████▍ | 1.01G/1.35G [00:14<00:07, 50.7MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 75%|███████▌ | 1.01G/1.35G [00:14<00:06, 51.8MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 76%|███████▌ | 1.02G/1.35G [00:15<00:06, 54.0MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 76%|███████▌ | 1.03G/1.35G [00:15<00:06, 54.5MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 77%|███████▋ | 1.03G/1.35G [00:15<00:05, 58.5MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 77%|███████▋ | 1.04G/1.35G [00:15<00:05, 59.7MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 78%|███████▊ | 1.05G/1.35G [00:15<00:05, 64.0MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 78%|███████▊ | 1.05G/1.35G [00:15<00:06, 50.1MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 79%|███████▉ | 1.06G/1.35G [00:15<00:04, 61.4MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 79%|███████▉ | 1.07G/1.35G [00:15<00:05, 58.0MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 80%|███████▉ | 1.07G/1.35G [00:16<00:05, 57.7MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 80%|████████ | 1.08G/1.35G [00:16<00:04, 61.1MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 81%|████████ | 1.09G/1.35G [00:16<00:05, 54.9MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 81%|████████ | 1.09G/1.35G [00:16<00:04, 57.2MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 82%|████████▏ | 1.10G/1.35G [00:16<00:04, 56.1MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 82%|████████▏ | 1.10G/1.35G [00:16<00:04, 55.5MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 82%|████████▏ | 1.11G/1.35G [00:16<00:04, 53.8MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 83%|████████▎ | 1.12G/1.35G [00:16<00:04, 54.0MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 84%|████████▎ | 1.13G/1.35G [00:17<00:03, 63.4MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 84%|████████▍ | 1.14G/1.35G [00:17<00:03, 71.9MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 85%|████████▍ | 1.14G/1.35G [00:17<00:03, 66.3MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 85%|████████▌ | 1.15G/1.35G [00:17<00:03, 64.3MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 86%|████████▌ | 1.16G/1.35G [00:17<00:03, 67.0MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 87%|████████▋ | 1.17G/1.35G [00:17<00:03, 57.3MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 87%|████████▋ | 1.18G/1.35G [00:17<00:02, 61.6MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 88%|████████▊ | 1.18G/1.35G [00:17<00:02, 64.7MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 88%|████████▊ | 1.19G/1.35G [00:18<00:02, 64.1MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 89%|████████▉ | 1.20G/1.35G [00:18<00:02, 63.4MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 89%|████████▉ | 1.20G/1.35G [00:18<00:02, 55.0MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 90%|████████▉ | 1.21G/1.35G [00:18<00:02, 52.8MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 90%|████████▉ | 1.21G/1.35G [00:18<00:02, 50.8MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 90%|█████████ | 1.22G/1.35G [00:18<00:02, 47.1MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 91%|█████████ | 1.22G/1.35G [00:18<00:02, 48.7MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 91%|█████████ | 1.23G/1.35G [00:18<00:02, 48.2MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 92%|█████████▏| 1.23G/1.35G [00:19<00:02, 54.0MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 92%|█████████▏| 1.24G/1.35G [00:19<00:03, 38.3MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 92%|█████████▏| 1.25G/1.35G [00:19<00:02, 43.9MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 93%|█████████▎| 1.25G/1.35G [00:19<00:02, 44.8MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 93%|█████████▎| 1.26G/1.35G [00:19<00:02, 45.7MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 94%|█████████▍| 1.27G/1.35G [00:19<00:01, 56.9MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 94%|█████████▍| 1.27G/1.35G [00:19<00:01, 47.5MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 95%|█████████▍| 1.28G/1.35G [00:20<00:01, 53.5MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 95%|█████████▌| 1.29G/1.35G [00:20<00:01, 53.2MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 96%|█████████▌| 1.29G/1.35G [00:20<00:01, 55.4MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 96%|█████████▋| 1.30G/1.35G [00:20<00:00, 56.6MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 97%|█████████▋| 1.30G/1.35G [00:20<00:00, 58.6MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 97%|█████████▋| 1.31G/1.35G [00:20<00:00, 43.7MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 98%|█████████▊| 1.32G/1.35G [00:20<00:00, 45.3MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 98%|█████████▊| 1.32G/1.35G [00:20<00:00, 47.3MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 99%|█████████▊| 1.33G/1.35G [00:21<00:00, 55.0MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
" 99%|█████████▉| 1.34G/1.35G [00:21<00:00, 57.6MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
"100%|█████████▉| 1.34G/1.35G [00:21<00:00, 48.2MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\r",
"100%|██████████| 1.35G/1.35G [00:21<00:00, 67.4MB/s]"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\n"
]
}
],
"source": [
"for key in mydict:\n",
" mydict[key] = sm.SummaryDetector(mydict[key]).analyse_questions(list_of_questions)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-16T08:55:02.741425Z",
"iopub.status.busy": "2023-05-16T08:55:02.740920Z",
"iopub.status.idle": "2023-05-16T08:55:02.880034Z",
"shell.execute_reply": "2023-05-16T08:55:02.878954Z"
}
},
"outputs": [
{
"ename": "AttributeError",
"evalue": "module 'ammico.display' has no attribute 'explore_analysis'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[12], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mmdisplay\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mexplore_analysis\u001b[49m(mydict, identify\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msummary\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
"\u001b[0;31mAttributeError\u001b[0m: module 'ammico.display' has no attribute 'explore_analysis'"
]
}
],
"source": [
"mdisplay.explore_analysis(mydict, identify=\"summary\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Convert the dictionary of dictionarys into a dictionary with lists:"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-16T08:55:02.883864Z",
"iopub.status.busy": "2023-05-16T08:55:02.883408Z",
"iopub.status.idle": "2023-05-16T08:55:02.892056Z",
"shell.execute_reply": "2023-05-16T08:55:02.891370Z"
}
},
"outputs": [],
"source": [
"outdict2 = mutils.append_data_to_dict(mydict)\n",
"df2 = mutils.dump_df(outdict2)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-16T08:55:02.895511Z",
"iopub.status.busy": "2023-05-16T08:55:02.895086Z",
"iopub.status.idle": "2023-05-16T08:55:02.911026Z",
"shell.execute_reply": "2023-05-16T08:55:02.910254Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>filename</th>\n",
" <th>const_image_summary</th>\n",
" <th>3_non-deterministic summary</th>\n",
" <th>How many persons on the picture?</th>\n",
" <th>Are there any politicians in the picture?</th>\n",
" <th>Does the picture show something from medicine?</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>data/102730_eng.png</td>\n",
" <td>two people in blue coats spray disinfection a van</td>\n",
" <td>[two people wearing blue uniforms spraying out...</td>\n",
" <td>2</td>\n",
" <td>no</td>\n",
" <td>yes</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>data/102141_2_eng.png</td>\n",
" <td>a collage of images including a corona sign, a...</td>\n",
" <td>[many pictures include people, signs, and a fe...</td>\n",
" <td>1</td>\n",
" <td>no</td>\n",
" <td>yes</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>data/106349S_por.png</td>\n",
" <td>a man wearing a face mask while looking at a c...</td>\n",
" <td>[a man in a face mask talking into the radio, ...</td>\n",
" <td>1</td>\n",
" <td>yes</td>\n",
" <td>yes</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" filename const_image_summary \n",
"0 data/102730_eng.png two people in blue coats spray disinfection a van \\\n",
"1 data/102141_2_eng.png a collage of images including a corona sign, a... \n",
"2 data/106349S_por.png a man wearing a face mask while looking at a c... \n",
"\n",
" 3_non-deterministic summary \n",
"0 [two people wearing blue uniforms spraying out... \\\n",
"1 [many pictures include people, signs, and a fe... \n",
"2 [a man in a face mask talking into the radio, ... \n",
"\n",
" How many persons on the picture? Are there any politicians in the picture? \n",
"0 2 no \\\n",
"1 1 no \n",
"2 1 yes \n",
"\n",
" Does the picture show something from medicine? \n",
"0 yes \n",
"1 yes \n",
"2 yes "
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df2.head(10)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"execution": {
"iopub.execute_input": "2023-05-16T08:55:02.915269Z",
"iopub.status.busy": "2023-05-16T08:55:02.914835Z",
"iopub.status.idle": "2023-05-16T08:55:02.920240Z",
"shell.execute_reply": "2023-05-16T08:55:02.919575Z"
}
},
"outputs": [],
"source": [
"df2.to_csv(\"./data_out2.csv\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
},
"vscode": {
"interpreter": {
"hash": "f1142466f556ab37fe2d38e2897a16796906208adb09fea90ba58bdf8a56f0ba"
}
}
},
"nbformat": 4,
"nbformat_minor": 4
}