зеркало из
https://github.com/ssciwr/AMMICO.git
synced 2025-11-01 06:26:10 +02:00
1948 строки
47 KiB
Plaintext
1948 строки
47 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Image summary and visual question answering"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"This notebooks shows how to generate image captions and use the visual question answering with [LAVIS](https://github.com/salesforce/LAVIS). \n",
|
|
"\n",
|
|
"The first cell is only run on google colab and installs the [ammico](https://github.com/ssciwr/AMMICO) package.\n",
|
|
"\n",
|
|
"After that, we can import `ammico` and read in the files given a folder path."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2023-07-07T12:10:06.882435Z",
|
|
"iopub.status.busy": "2023-07-07T12:10:06.882081Z",
|
|
"iopub.status.idle": "2023-07-07T12:10:06.890623Z",
|
|
"shell.execute_reply": "2023-07-07T12:10:06.889655Z"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# if running on google colab\n",
|
|
"# flake8-noqa-cell\n",
|
|
"import os\n",
|
|
"\n",
|
|
"if \"google.colab\" in str(get_ipython()):\n",
|
|
" # update python version\n",
|
|
" # install setuptools\n",
|
|
" # %pip install setuptools==61 -qqq\n",
|
|
" # install ammico\n",
|
|
" %pip install git+https://github.com/ssciwr/ammico.git -qqq\n",
|
|
" # mount google drive for data and API key\n",
|
|
" from google.colab import drive\n",
|
|
"\n",
|
|
" drive.mount(\"/content/drive\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2023-07-07T12:10:06.893099Z",
|
|
"iopub.status.busy": "2023-07-07T12:10:06.892892Z",
|
|
"iopub.status.idle": "2023-07-07T12:10:17.263588Z",
|
|
"shell.execute_reply": "2023-07-07T12:10:17.262955Z"
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import ammico\n",
|
|
"from ammico import utils as mutils\n",
|
|
"from ammico import display as mdisplay\n",
|
|
"import ammico.summary as sm"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2023-07-07T12:10:17.266982Z",
|
|
"iopub.status.busy": "2023-07-07T12:10:17.266167Z",
|
|
"iopub.status.idle": "2023-07-07T12:10:17.270923Z",
|
|
"shell.execute_reply": "2023-07-07T12:10:17.270334Z"
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Here you need to provide the path to your google drive folder\n",
|
|
"# or local folder containing the images\n",
|
|
"images = mutils.find_files(\n",
|
|
" path=\"data/\",\n",
|
|
" limit=10,\n",
|
|
")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2023-07-07T12:10:17.273523Z",
|
|
"iopub.status.busy": "2023-07-07T12:10:17.273308Z",
|
|
"iopub.status.idle": "2023-07-07T12:10:17.276472Z",
|
|
"shell.execute_reply": "2023-07-07T12:10:17.275843Z"
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"mydict = mutils.initialize_dict(images)"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Create captions for images and directly write to csv"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Here you can choose between two models: \"base\" or \"large\". This will generate the caption for each image and directly put the results in a dataframe. This dataframe can be exported as a csv file.\n",
|
|
"\n",
|
|
"The results are written into the columns `const_image_summary` - this will always be the same result (as always the same seed will be used). The column `3_non-deterministic summary` displays three different answers generated with different seeds, these are most likely different when you run the analysis again."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2023-07-07T12:10:17.280136Z",
|
|
"iopub.status.busy": "2023-07-07T12:10:17.279922Z",
|
|
"iopub.status.idle": "2023-07-07T12:11:20.042486Z",
|
|
"shell.execute_reply": "2023-07-07T12:11:20.023445Z"
|
|
},
|
|
"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%| | 6.98M/2.50G [00:00<00:36, 73.2MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 1%| | 24.0M/2.50G [00:00<00:22, 116MB/s] "
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 1%|▏ | 34.8M/2.50G [00:00<00:26, 101MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 2%|▏ | 50.8M/2.50G [00:00<00:21, 124MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 2%|▏ | 64.0M/2.50G [00:00<00:25, 104MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 3%|▎ | 80.0M/2.50G [00:00<00:24, 106MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 4%|▍ | 103M/2.50G [00:00<00:18, 140MB/s] "
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 5%|▍ | 125M/2.50G [00:00<00:15, 163MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 6%|▌ | 144M/2.50G [00:01<00:14, 174MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 6%|▋ | 166M/2.50G [00:01<00:13, 191MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 8%|▊ | 197M/2.50G [00:01<00:10, 229MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 9%|▉ | 228M/2.50G [00:01<00:09, 258MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 10%|▉ | 256M/2.50G [00:01<00:09, 257MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 11%|█ | 286M/2.50G [00:01<00:08, 272MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 12%|█▏ | 316M/2.50G [00:01<00:08, 287MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 13%|█▎ | 344M/2.50G [00:01<00:08, 272MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 15%|█▍ | 375M/2.50G [00:01<00:08, 286MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 16%|█▌ | 406M/2.50G [00:02<00:07, 297MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 17%|█▋ | 436M/2.50G [00:02<00:07, 303MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 18%|█▊ | 466M/2.50G [00:02<00:07, 305MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 19%|█▉ | 495M/2.50G [00:02<00:07, 280MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 20%|██ | 522M/2.50G [00:02<00:07, 273MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 22%|██▏ | 552M/2.50G [00:02<00:07, 283MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 23%|██▎ | 582M/2.50G [00:02<00:07, 292MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 24%|██▍ | 612M/2.50G [00:02<00:06, 299MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 25%|██▌ | 643M/2.50G [00:02<00:06, 307MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 26%|██▋ | 674M/2.50G [00:02<00:06, 312MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 27%|██▋ | 704M/2.50G [00:03<00:06, 314MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 29%|██▊ | 735M/2.50G [00:03<00:06, 315MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 30%|██▉ | 765M/2.50G [00:03<00:06, 305MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 31%|███ | 794M/2.50G [00:03<00:06, 299MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 32%|███▏ | 824M/2.50G [00:03<00:06, 303MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 33%|███▎ | 854M/2.50G [00:03<00:05, 305MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 34%|███▍ | 884M/2.50G [00:03<00:05, 310MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 36%|███▌ | 915M/2.50G [00:03<00:05, 314MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 37%|███▋ | 946M/2.50G [00:03<00:05, 317MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 38%|███▊ | 977M/2.50G [00:03<00:05, 320MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 39%|███▉ | 0.98G/2.50G [00:04<00:05, 318MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 41%|████ | 1.01G/2.50G [00:04<00:04, 320MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 42%|████▏ | 1.04G/2.50G [00:04<00:04, 321MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 43%|████▎ | 1.07G/2.50G [00:04<00:04, 317MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 44%|████▍ | 1.10G/2.50G [00:04<00:05, 297MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 45%|████▌ | 1.13G/2.50G [00:05<00:13, 111MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 46%|████▋ | 1.16G/2.50G [00:05<00:10, 135MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 47%|████▋ | 1.19G/2.50G [00:05<00:08, 158MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 49%|████▊ | 1.22G/2.50G [00:05<00:07, 185MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 50%|████▉ | 1.25G/2.50G [00:05<00:06, 212MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 51%|█████ | 1.28G/2.50G [00:05<00:05, 236MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 52%|█████▏ | 1.30G/2.50G [00:05<00:05, 257MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 53%|█████▎ | 1.33G/2.50G [00:05<00:04, 262MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 54%|█████▍ | 1.36G/2.50G [00:06<00:04, 278MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 56%|█████▌ | 1.39G/2.50G [00:06<00:04, 277MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 57%|█████▋ | 1.42G/2.50G [00:06<00:04, 287MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 58%|█████▊ | 1.45G/2.50G [00:06<00:03, 296MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 59%|█████▉ | 1.48G/2.50G [00:06<00:03, 303MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 60%|██████ | 1.51G/2.50G [00:06<00:03, 274MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 61%|██████▏ | 1.54G/2.50G [00:06<00:03, 285MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 63%|██████▎ | 1.56G/2.50G [00:06<00:03, 275MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 64%|██████▎ | 1.59G/2.50G [00:06<00:03, 287MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 65%|██████▍ | 1.62G/2.50G [00:06<00:03, 284MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 66%|██████▌ | 1.65G/2.50G [00:07<00:03, 281MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 67%|██████▋ | 1.67G/2.50G [00:07<00:03, 254MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 68%|██████▊ | 1.70G/2.50G [00:07<00:03, 252MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 69%|██████▉ | 1.72G/2.50G [00:07<00:03, 236MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 70%|██████▉ | 1.75G/2.50G [00:07<00:03, 236MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 71%|███████ | 1.77G/2.50G [00:07<00:03, 227MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 71%|███████▏ | 1.79G/2.50G [00:07<00:03, 223MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 72%|███████▏ | 1.81G/2.50G [00:07<00:03, 221MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 73%|███████▎ | 1.84G/2.50G [00:08<00:03, 232MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 74%|███████▍ | 1.86G/2.50G [00:08<00:02, 241MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 75%|███████▌ | 1.89G/2.50G [00:08<00:02, 249MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 76%|███████▋ | 1.91G/2.50G [00:08<00:02, 251MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 77%|███████▋ | 1.94G/2.50G [00:08<00:02, 260MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 78%|███████▊ | 1.96G/2.50G [00:08<00:05, 111MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 79%|███████▉ | 1.99G/2.50G [00:09<00:03, 141MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 81%|████████ | 2.02G/2.50G [00:09<00:03, 171MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 82%|████████▏ | 2.05G/2.50G [00:09<00:02, 195MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 83%|████████▎ | 2.07G/2.50G [00:09<00:02, 212MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 84%|████████▍ | 2.10G/2.50G [00:09<00:01, 231MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 85%|████████▍ | 2.12G/2.50G [00:09<00:01, 240MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 86%|████████▌ | 2.15G/2.50G [00:09<00:01, 250MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 87%|████████▋ | 2.18G/2.50G [00:09<00:01, 254MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 88%|████████▊ | 2.20G/2.50G [00:09<00:01, 256MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 89%|████████▉ | 2.23G/2.50G [00:09<00:01, 264MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 90%|████████▉ | 2.25G/2.50G [00:10<00:01, 263MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 91%|█████████ | 2.28G/2.50G [00:10<00:00, 266MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 92%|█████████▏| 2.30G/2.50G [00:10<00:00, 270MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 93%|█████████▎| 2.33G/2.50G [00:10<00:00, 269MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 94%|█████████▍| 2.36G/2.50G [00:10<00:00, 269MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 95%|█████████▌| 2.38G/2.50G [00:13<00:04, 32.2MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 96%|█████████▌| 2.40G/2.50G [00:13<00:03, 37.4MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 96%|█████████▋| 2.41G/2.50G [00:13<00:02, 43.0MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 97%|█████████▋| 2.43G/2.50G [00:13<00:01, 50.2MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 97%|█████████▋| 2.44G/2.50G [00:13<00:01, 53.6MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 98%|█████████▊| 2.45G/2.50G [00:13<00:00, 64.3MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 99%|█████████▊| 2.47G/2.50G [00:14<00:00, 76.2MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 99%|█████████▉| 2.48G/2.50G [00:14<00:00, 91.8MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
"100%|█████████▉| 2.50G/2.50G [00:14<00:00, 108MB/s] "
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
"100%|██████████| 2.50G/2.50G [00:14<00:00, 189MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 0%| | 0.00/1.35G [00:00<?, ?B/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 0%| | 4.01M/1.35G [00:00<00:43, 32.8MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 1%| | 9.62M/1.35G [00:00<00:30, 46.6MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 1%| | 16.0M/1.35G [00:00<00:26, 53.8MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 2%|▏ | 25.2M/1.35G [00:00<00:20, 69.6MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 3%|▎ | 48.0M/1.35G [00:00<00:11, 127MB/s] "
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 5%|▍ | 64.0M/1.35G [00:00<00:11, 119MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 5%|▌ | 75.6M/1.35G [00:00<00:12, 111MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 6%|▋ | 86.3M/1.35G [00:00<00:13, 100MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 7%|▋ | 96.1M/1.35G [00:01<00:17, 75.8MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 8%|▊ | 112M/1.35G [00:01<00:14, 94.8MB/s] "
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 9%|▉ | 128M/1.35G [00:01<00:16, 79.7MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 10%|▉ | 137M/1.35G [00:01<00:18, 69.4MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 10%|█ | 145M/1.35G [00:01<00:21, 59.9MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 12%|█▏ | 160M/1.35G [00:02<00:17, 74.1MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 13%|█▎ | 176M/1.35G [00:02<00:15, 83.8MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 14%|█▍ | 198M/1.35G [00:02<00:10, 115MB/s] "
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 16%|█▌ | 221M/1.35G [00:02<00:08, 143MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 17%|█▋ | 237M/1.35G [00:02<00:08, 148MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 19%|█▊ | 256M/1.35G [00:02<00:07, 151MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 20%|██ | 282M/1.35G [00:02<00:06, 182MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 22%|██▏ | 301M/1.35G [00:02<00:06, 185MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 23%|██▎ | 319M/1.35G [00:02<00:06, 184MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 25%|██▍ | 343M/1.35G [00:03<00:05, 204MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 26%|██▋ | 363M/1.35G [00:03<00:05, 187MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 29%|██▊ | 395M/1.35G [00:03<00:04, 227MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 31%|███ | 421M/1.35G [00:03<00:04, 239MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 32%|███▏ | 448M/1.35G [00:03<00:04, 237MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 35%|███▍ | 480M/1.35G [00:03<00:04, 219MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 37%|███▋ | 512M/1.35G [00:03<00:04, 226MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 39%|███▉ | 536M/1.35G [00:03<00:04, 213MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 41%|████ | 568M/1.35G [00:04<00:03, 219MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 44%|████▎ | 600M/1.35G [00:04<00:03, 237MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 46%|████▌ | 630M/1.35G [00:04<00:03, 256MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 48%|████▊ | 660M/1.35G [00:04<00:02, 270MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 50%|████▉ | 686M/1.35G [00:04<00:02, 263MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 52%|█████▏ | 712M/1.35G [00:04<00:02, 258MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 53%|█████▎ | 737M/1.35G [00:05<00:05, 131MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 55%|█████▌ | 760M/1.35G [00:05<00:04, 148MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 57%|█████▋ | 792M/1.35G [00:05<00:03, 183MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 59%|█████▉ | 815M/1.35G [00:05<00:03, 191MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 61%|██████ | 838M/1.35G [00:05<00:02, 195MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 62%|██████▏ | 860M/1.35G [00:05<00:02, 200MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 64%|██████▍ | 881M/1.35G [00:05<00:02, 191MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 66%|██████▌ | 912M/1.35G [00:05<00:02, 222MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 68%|██████▊ | 935M/1.35G [00:06<00:02, 216MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 69%|██████▉ | 956M/1.35G [00:06<00:02, 210MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 71%|███████ | 981M/1.35G [00:06<00:01, 223MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 73%|███████▎ | 0.98G/1.35G [00:06<00:01, 223MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 74%|███████▍ | 1.00G/1.35G [00:06<00:01, 215MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 76%|███████▌ | 1.02G/1.35G [00:06<00:01, 207MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 78%|███████▊ | 1.05G/1.35G [00:06<00:01, 237MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 80%|████████ | 1.08G/1.35G [00:06<00:01, 244MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 82%|████████▏ | 1.10G/1.35G [00:06<00:01, 237MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 83%|████████▎ | 1.12G/1.35G [00:07<00:01, 239MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 86%|████████▌ | 1.15G/1.35G [00:07<00:00, 258MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 87%|████████▋ | 1.18G/1.35G [00:07<00:01, 159MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 89%|████████▉ | 1.20G/1.35G [00:07<00:00, 184MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 91%|█████████ | 1.22G/1.35G [00:07<00:00, 181MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 93%|█████████▎| 1.25G/1.35G [00:07<00:00, 193MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 95%|█████████▍| 1.28G/1.35G [00:07<00:00, 219MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 97%|█████████▋| 1.30G/1.35G [00:07<00:00, 234MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
" 99%|█████████▊| 1.33G/1.35G [00:08<00:00, 238MB/s]"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"\r",
|
|
"100%|██████████| 1.35G/1.35G [00:08<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(model_type=\"base\")\n",
|
|
"# summary_model, summary_vis_processors = mutils.load_model(\"large\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 6,
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2023-07-07T12:11:20.281054Z",
|
|
"iopub.status.busy": "2023-07-07T12:11:20.278583Z",
|
|
"iopub.status.idle": "2023-07-07T12:12:04.580839Z",
|
|
"shell.execute_reply": "2023-07-07T12:12:04.579750Z"
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [
|
|
{
|
|
"ename": "TypeError",
|
|
"evalue": "analyse_image() got an unexpected keyword argument 'summary_model'",
|
|
"output_type": "error",
|
|
"traceback": [
|
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
|
|
"Cell \u001b[0;32mIn[6], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m key \u001b[38;5;129;01min\u001b[39;00m mydict:\n\u001b[0;32m----> 2\u001b[0m mydict[key] \u001b[38;5;241m=\u001b[39m \u001b[43msm\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mSummaryDetector\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmydict\u001b[49m\u001b[43m[\u001b[49m\u001b[43mkey\u001b[49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43manalyse_image\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 3\u001b[0m \u001b[43m \u001b[49m\u001b[43msummary_model\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43msummary_model\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msummary_vis_processors\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43msummary_vis_processors\u001b[49m\n\u001b[1;32m 4\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n",
|
|
"\u001b[0;31mTypeError\u001b[0m: analyse_image() got an unexpected keyword argument 'summary_model'"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"for key in mydict:\n",
|
|
" mydict[key] = sm.SummaryDetector(mydict[key]).analyse_image(\n",
|
|
" summary_model=summary_model, summary_vis_processors=summary_vis_processors\n",
|
|
" )"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"source": [
|
|
"Convert the dictionary of dictionarys into a dictionary with lists:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 7,
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2023-07-07T12:12:04.684412Z",
|
|
"iopub.status.busy": "2023-07-07T12:12:04.683842Z",
|
|
"iopub.status.idle": "2023-07-07T12:12:04.781540Z",
|
|
"shell.execute_reply": "2023-07-07T12:12:04.780882Z"
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"outdict = mutils.append_data_to_dict(mydict)\n",
|
|
"df = mutils.dump_df(outdict)"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Check the dataframe:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 8,
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2023-07-07T12:12:04.789181Z",
|
|
"iopub.status.busy": "2023-07-07T12:12:04.788928Z",
|
|
"iopub.status.idle": "2023-07-07T12:12:04.969102Z",
|
|
"shell.execute_reply": "2023-07-07T12:12:04.968025Z"
|
|
},
|
|
"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",
|
|
" </tr>\n",
|
|
" </thead>\n",
|
|
" <tbody>\n",
|
|
" <tr>\n",
|
|
" <th>0</th>\n",
|
|
" <td>data/102730_eng.png</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>1</th>\n",
|
|
" <td>data/106349S_por.png</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>2</th>\n",
|
|
" <td>data/102141_2_eng.png</td>\n",
|
|
" </tr>\n",
|
|
" </tbody>\n",
|
|
"</table>\n",
|
|
"</div>"
|
|
],
|
|
"text/plain": [
|
|
" filename\n",
|
|
"0 data/102730_eng.png\n",
|
|
"1 data/106349S_por.png\n",
|
|
"2 data/102141_2_eng.png"
|
|
]
|
|
},
|
|
"execution_count": 8,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"df.head(10)"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Write the csv file:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 9,
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2023-07-07T12:12:04.988475Z",
|
|
"iopub.status.busy": "2023-07-07T12:12:04.987968Z",
|
|
"iopub.status.idle": "2023-07-07T12:12:05.044673Z",
|
|
"shell.execute_reply": "2023-07-07T12:12:05.044071Z"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"df.to_csv(\"data_out.csv\")"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"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": 10,
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2023-07-07T12:12:05.051627Z",
|
|
"iopub.status.busy": "2023-07-07T12:12:05.051057Z",
|
|
"iopub.status.idle": "2023-07-07T12:12:05.086302Z",
|
|
"shell.execute_reply": "2023-07-07T12:12:05.085533Z"
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [
|
|
{
|
|
"ename": "TypeError",
|
|
"evalue": "__init__() got an unexpected keyword argument 'identify'",
|
|
"output_type": "error",
|
|
"traceback": [
|
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
|
|
"Cell \u001b[0;32mIn[10], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m analysis_explorer \u001b[38;5;241m=\u001b[39m \u001b[43mmdisplay\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mAnalysisExplorer\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmydict\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43midentify\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43msummary\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 2\u001b[0m analysis_explorer\u001b[38;5;241m.\u001b[39mrun_server(port\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m8055\u001b[39m)\n",
|
|
"\u001b[0;31mTypeError\u001b[0m: __init__() got an unexpected keyword argument 'identify'"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"analysis_explorer = mdisplay.AnalysisExplorer(mydict, identify=\"summary\")\n",
|
|
"analysis_explorer.run_server(port=8055)"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Generate answers to free-form questions about images written in natural language. "
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Set the list of questions as a list of strings:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 11,
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2023-07-07T12:12:05.092380Z",
|
|
"iopub.status.busy": "2023-07-07T12:12:05.092010Z",
|
|
"iopub.status.idle": "2023-07-07T12:12:05.095465Z",
|
|
"shell.execute_reply": "2023-07-07T12:12:05.094813Z"
|
|
}
|
|
},
|
|
"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",
|
|
"]"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Explore the analysis using the interface:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 12,
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2023-07-07T12:12:05.103260Z",
|
|
"iopub.status.busy": "2023-07-07T12:12:05.102902Z",
|
|
"iopub.status.idle": "2023-07-07T12:12:05.134127Z",
|
|
"shell.execute_reply": "2023-07-07T12:12:05.133465Z"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"ename": "TypeError",
|
|
"evalue": "__init__() got an unexpected keyword argument 'identify'",
|
|
"output_type": "error",
|
|
"traceback": [
|
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
|
|
"Cell \u001b[0;32mIn[12], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m analysis_explorer \u001b[38;5;241m=\u001b[39m \u001b[43mmdisplay\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mAnalysisExplorer\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmydict\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43midentify\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43msummary\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 2\u001b[0m analysis_explorer\u001b[38;5;241m.\u001b[39mrun_server(port\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m8055\u001b[39m)\n",
|
|
"\u001b[0;31mTypeError\u001b[0m: __init__() got an unexpected keyword argument 'identify'"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"analysis_explorer = mdisplay.AnalysisExplorer(mydict, identify=\"summary\")\n",
|
|
"analysis_explorer.run_server(port=8055)"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Or directly analyze for further processing\n",
|
|
"Instead of inspecting each of the images, you can also directly carry out the analysis and export the result into a csv. This may take a while depending on how many images you have loaded."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 13,
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2023-07-07T12:12:05.139683Z",
|
|
"iopub.status.busy": "2023-07-07T12:12:05.139130Z",
|
|
"iopub.status.idle": "2023-07-07T12:13:45.261519Z",
|
|
"shell.execute_reply": "2023-07-07T12:13:45.243181Z"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"for key in mydict:\n",
|
|
" mydict[key] = sm.SummaryDetector(mydict[key]).analyse_questions(list_of_questions)"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Convert to dataframe and write csv\n",
|
|
"These steps are required to convert the dictionary of dictionarys into a dictionary with lists, that can be converted into a pandas dataframe and exported to a csv file."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 14,
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2023-07-07T12:13:45.305412Z",
|
|
"iopub.status.busy": "2023-07-07T12:13:45.304806Z",
|
|
"iopub.status.idle": "2023-07-07T12:13:45.342296Z",
|
|
"shell.execute_reply": "2023-07-07T12:13:45.341683Z"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"outdict2 = mutils.append_data_to_dict(mydict)\n",
|
|
"df2 = mutils.dump_df(outdict2)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 15,
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2023-07-07T12:13:45.347822Z",
|
|
"iopub.status.busy": "2023-07-07T12:13:45.347451Z",
|
|
"iopub.status.idle": "2023-07-07T12:13:45.367341Z",
|
|
"shell.execute_reply": "2023-07-07T12:13:45.366608Z"
|
|
}
|
|
},
|
|
"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>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>2</td>\n",
|
|
" <td>no</td>\n",
|
|
" <td>yes</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>1</th>\n",
|
|
" <td>data/106349S_por.png</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>yes</td>\n",
|
|
" <td>yes</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>2</th>\n",
|
|
" <td>data/102141_2_eng.png</td>\n",
|
|
" <td>1</td>\n",
|
|
" <td>no</td>\n",
|
|
" <td>yes</td>\n",
|
|
" </tr>\n",
|
|
" </tbody>\n",
|
|
"</table>\n",
|
|
"</div>"
|
|
],
|
|
"text/plain": [
|
|
" filename How many persons on the picture? \\\n",
|
|
"0 data/102730_eng.png 2 \n",
|
|
"1 data/106349S_por.png 1 \n",
|
|
"2 data/102141_2_eng.png 1 \n",
|
|
"\n",
|
|
" Are there any politicians in the picture? \\\n",
|
|
"0 no \n",
|
|
"1 yes \n",
|
|
"2 no \n",
|
|
"\n",
|
|
" Does the picture show something from medicine? \n",
|
|
"0 yes \n",
|
|
"1 yes \n",
|
|
"2 yes "
|
|
]
|
|
},
|
|
"execution_count": 15,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"df2.head(10)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 16,
|
|
"metadata": {
|
|
"execution": {
|
|
"iopub.execute_input": "2023-07-07T12:13:45.375357Z",
|
|
"iopub.status.busy": "2023-07-07T12:13:45.375126Z",
|
|
"iopub.status.idle": "2023-07-07T12:13:45.382066Z",
|
|
"shell.execute_reply": "2023-07-07T12:13:45.381488Z"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"df2.to_csv(\"data_out2.csv\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3 (ipykernel)",
|
|
"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.17"
|
|
},
|
|
"vscode": {
|
|
"interpreter": {
|
|
"hash": "f1142466f556ab37fe2d38e2897a16796906208adb09fea90ba58bdf8a56f0ba"
|
|
}
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 4
|
|
}
|