{ "cells": [ { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "import os\n", "import pandas as pd\n", "import numpy as np\n", "import json\n", "\n", "\n", "ocr_types_dict = {\n", "# \"Qwen2.5-VL-72B\": \"qwen25vl_200dpi\",\n", "# \"Gemini2.5-Pro\": \"200dpi981md-geminiPro\",\n", "# \"Mathpix\": \"mathpix_200dpi\",\n", "# \"Doc2x_old\": \"Doc2x_200dpi\",\n", "# # \"Textin_old\": \"textin_200dpi\",\n", " \"Doc2x_new\": \"doc2x_0506\",\n", "# \"Textin_new\": \"textin_0506\",\n", "# # \"MinerU1-0.9.3\": \"mineru093\",\n", "# \"MinerU2-0311\": \"mineru2_0311_200dpi\",\n", "# # \"MinerU2-0415\": \"mineru2_0415\",\n", "# \"0415_hf\": \"0415_hf\",\n", "# # \"mineru2_0415_sglang\": \"mineru2_0415_sglang\",\n", "# # \"mineru2_0515_epoch1-4\": \"mineru2_0515_epoch1-4\", \n", "# # \"mineru2_sglang_0515_epoch1-4\": \"mineru2_sglang_0515_epoch1-4\",\n", "# # \"mineru2_0515_epoch2\": \"mineru2_0515_epoch2\",\n", "# # \"mineru2_sglang_0515_epoch2\": \"mineru2_sglang_0515_epoch2\",\n", "# # \"MinerU2.0-0515_mineru2-qwenvl+mineru2-qwenvl-bbox_1epoch\": \"MinerU2.0-0515_mineru2-qwenvl+mineru2-qwenvl-bbox_1epoch\",\n", "# # \"mineru2_0515_epoch2_0512\": \"mineru2_0515_epoch2_0512\",\n", "# # \"mineru2_0515_mineru2-qwenvl-bbox_epoch1\": \"mineru2_0515_mineru2-qwenvl-bbox_epoch1\",\n", "# # \"mineru2_sglang_0515_epoch1-4_0512\": \"mineru2_sglang_0515_epoch1-4_0512\",\n", "# # \"MinerU2.0-0515_mineru2-qwenvl+mineru2-qwenvl-bbox_1epoch_7-3 A\": \"results_without_box_start\",\n", "# \"MinerU1.0-1.3.10\": \"MinerU1-1_3_10\",\n", "# \"results_qwen_2-7\": \"results_qwen_2-7\",\n", "# \"mineru2_0515_epoch1-4_0512\": \"mineru2_0515_epoch1-4_0512\"\n", "}\n", "# ocr_types_dict = {\n", "# \"mineru093_omnidoc_qwenvl-s1-final_res\": \"mineru093_omnidoc_qwenvl-s1-final_res\",\n", "# \"mineru135_orilayout_unimernetv2_post_s5-replace_mftab\": \"mineru135_orilayout_unimernetv2_post_s5-replace_mftab\"\n", "# }\n", "\n", "result_folder = \"../result\"\n", "\n", "# match_name = 'no_split'\n", "match_name = 'quick_match'" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
text_block_Edit_dist_ENtext_block_Edit_dist_CHdisplay_formula_Edit_dist_ENdisplay_formula_Edit_dist_CHdisplay_formula_CDM_ENdisplay_formula_CDM_CHtable_TEDS_ENtable_TEDS_CHtable_TEDS_structure_only_ENtable_TEDS_structure_only_CHtable_Edit_dist_ENtable_Edit_dist_CHreading_order_Edit_dist_ENreading_order_Edit_dist_CHoverall_ENoverall_CH
mineru093_omnidoc_qwenvl-s1-final_res0.0660.2000.2280.55685.35750.50482.17080.69688.69382.5900.1390.1770.0670.2360.1250.292
mineru135_orilayout_unimernetv2_post_s5-replace_mftab0.0600.1910.1980.50989.68053.20484.93784.76891.05187.1780.1190.1380.0580.2200.1090.265
\n", "
" ], "text/plain": [ " text_block_Edit_dist_EN \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 0.066 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 0.060 \n", "\n", " text_block_Edit_dist_CH \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 0.200 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 0.191 \n", "\n", " display_formula_Edit_dist_EN \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 0.228 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 0.198 \n", "\n", " display_formula_Edit_dist_CH \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 0.556 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 0.509 \n", "\n", " display_formula_CDM_EN \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 85.357 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 89.680 \n", "\n", " display_formula_CDM_CH \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 50.504 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 53.204 \n", "\n", " table_TEDS_EN \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 82.170 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 84.937 \n", "\n", " table_TEDS_CH \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 80.696 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 84.768 \n", "\n", " table_TEDS_structure_only_EN \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 88.693 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 91.051 \n", "\n", " table_TEDS_structure_only_CH \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 82.590 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 87.178 \n", "\n", " table_Edit_dist_EN \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 0.139 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 0.119 \n", "\n", " table_Edit_dist_CH \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 0.177 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 0.138 \n", "\n", " reading_order_Edit_dist_EN \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 0.067 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 0.058 \n", "\n", " reading_order_Edit_dist_CH \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 0.236 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 0.220 \n", "\n", " overall_EN overall_CH \n", "mineru093_omnidoc_qwenvl-s1-final_res 0.125 0.292 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 0.109 0.265 " ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# overall result\n", "\n", "dict_list = []\n", "\n", "for ocr_type in ocr_types_dict.values():\n", " result_path = os.path.join(result_folder, f'{ocr_type}_{match_name}_metric_result.json')\n", " # if not os.path.exists(result_path):\n", " # continue\n", "\n", " with open(result_path, 'r') as f:\n", " result = json.load(f)\n", " \n", " save_dict = {}\n", " en_overall = []\n", " ch_overall = []\n", " for category_type, metric in [(\"text_block\", \"Edit_dist\"), (\"display_formula\", \"Edit_dist\"), (\"display_formula\", \"CDM\"), (\"table\", \"TEDS\"), (\"table\", \"TEDS_structure_only\"), (\"table\", \"Edit_dist\"), (\"reading_order\", \"Edit_dist\")]:\n", " if metric == 'CDM' or metric == \"TEDS\" or metric == \"TEDS_structure_only\":\n", " if result[category_type][\"page\"].get(metric):\n", " save_dict[category_type+'_'+metric+'_EN'] = result[category_type][\"page\"][metric][\"language: english\"] * 100\n", " save_dict[category_type+'_'+metric+'_CH'] = result[category_type][\"page\"][metric][\"language: simplified_chinese\"] * 100\n", " else:\n", " save_dict[category_type+'_'+metric+'_EN'] = '-'\n", " save_dict[category_type+'_'+metric+'_CH'] = '-'\n", " else:\n", " save_dict[category_type+'_'+metric+'_EN'] = result[category_type][\"page\"][metric].get(\"language: english\", np.nan)\n", " save_dict[category_type+'_'+metric+'_CH'] = result[category_type][\"page\"][metric].get(\"language: simplified_chinese\",np.nan)\n", " if metric == \"Edit_dist\":\n", " en_overall.append(result[category_type][\"page\"][metric].get(\"language: english\", np.nan))\n", " ch_overall.append(result[category_type][\"page\"][metric].get(\"language: simplified_chinese\",np.nan))\n", " \n", " save_dict['overall_EN'] = sum(en_overall) / len(en_overall)\n", " save_dict['overall_CH'] = sum(ch_overall) / len(ch_overall)\n", " dict_list.append(save_dict)\n", " \n", "df = pd.DataFrame(dict_list, index=ocr_types_dict.keys()).round(3)\n", "# df.to_csv('./overall.csv')\n", "\n", "df" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
text_block_Edit_distdisplay_formula_CDMtable_TEDStable_TEDS_structure_onlyreading_order_Edit_distoverall
mineru093_omnidoc_qwenvl-s1-final_res0.19864.44581.13184.3900.21975.258667
mineru135_orilayout_unimernetv2_post_s5-replace_mftab0.19167.79484.55688.0480.21077.750000
\n", "
" ], "text/plain": [ " text_block_Edit_dist \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 0.198 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 0.191 \n", "\n", " display_formula_CDM \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 64.445 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 67.794 \n", "\n", " table_TEDS \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 81.131 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 84.556 \n", "\n", " table_TEDS_structure_only \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 84.390 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 88.048 \n", "\n", " reading_order_Edit_dist \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 0.219 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 0.210 \n", "\n", " overall \n", "mineru093_omnidoc_qwenvl-s1-final_res 75.258667 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 77.750000 " ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# overall result:不区分中英文, page级别的avg\n", "\n", "dict_list = []\n", "\n", "for ocr_type in ocr_types_dict.values():\n", " result_path = os.path.join(result_folder, f'{ocr_type}_{match_name}_metric_result.json')\n", " # if not os.path.exists(result_path):\n", " # continue\n", "\n", " with open(result_path, 'r') as f:\n", " result = json.load(f)\n", " \n", " save_dict = {}\n", " # en_overall = []\n", " # for category_type, metric in [(\"text_block\", \"Edit_dist\"), (\"display_formula\", \"CDM\"), (\"display_formula\", \"Edit_dist\"), (\"table\", \"TEDS\"), (\"table\", \"Edit_dist\"), (\"reading_order\", \"Edit_dist\")]:\n", " for category_type, metric in [(\"text_block\", \"Edit_dist\"), (\"display_formula\", \"CDM\"), (\"table\", \"TEDS\"), (\"table\", \"TEDS_structure_only\"), (\"reading_order\", \"Edit_dist\")]:\n", " if metric == 'CDM' or metric == \"TEDS\" or metric == \"TEDS_structure_only\":\n", " if result[category_type][\"page\"].get(metric):\n", " save_dict[category_type+'_'+metric] = result[category_type][\"page\"][metric][\"ALL\"] * 100 # page级别的avg\n", " else:\n", " save_dict[category_type+'_'+metric] = '-'\n", " else:\n", " save_dict[category_type+'_'+metric] = result[category_type][\"all\"][metric].get(\"ALL_page_avg\", np.nan)\n", " # if metric == \"Edit_dist\":\n", " # en_overall.append(result[category_type][\"all\"][metric].get(\"ALL_page_avg\", np.nan))\n", " \n", " # save_dict['overall'] = sum(en_overall) / len(en_overall)\n", " dict_list.append(save_dict)\n", " \n", "df = pd.DataFrame(dict_list, index=ocr_types_dict.keys()).round(3)\n", "df['overall'] = ((1-df['text_block_Edit_dist'])*100 + df['display_formula_CDM'] + df['table_TEDS'])/3\n", "# df.to_csv('./overall.csv')\n", "\n", "df" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
data_source: bookdata_source: PPT2PDFdata_source: research_reportdata_source: colorful_textbookdata_source: exam_paperdata_source: magazinedata_source: academic_literaturedata_source: notedata_source: newspaper
mineru093_omnidoc_qwenvl-s1-final_res0.060.0980.0280.0890.1190.0440.0400.9690.205
mineru135_orilayout_unimernetv2_post_s5-replace_mftab0.050.1170.0260.0920.1200.0810.0310.9700.108
\n", "
" ], "text/plain": [ " data_source: book \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 0.06 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 0.05 \n", "\n", " data_source: PPT2PDF \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 0.098 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 0.117 \n", "\n", " data_source: research_report \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 0.028 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 0.026 \n", "\n", " data_source: colorful_textbook \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 0.089 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 0.092 \n", "\n", " data_source: exam_paper \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 0.119 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 0.120 \n", "\n", " data_source: magazine \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 0.044 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 0.081 \n", "\n", " data_source: academic_literature \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 0.040 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 0.031 \n", "\n", " data_source: note \\\n", "mineru093_omnidoc_qwenvl-s1-final_res 0.969 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 0.970 \n", "\n", " data_source: newspaper \n", "mineru093_omnidoc_qwenvl-s1-final_res 0.205 \n", "mineru135_orilayout_unimernetv2_post_s5-replace... 0.108 " ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# PDF type\n", "dict_list = []\n", "\n", "for ocr_type in ocr_types_dict.values():\n", " result_path = os.path.join(result_folder, f'{ocr_type}_{match_name}_metric_result.json')\n", " \n", " with open(result_path, 'r') as f:\n", " result = json.load(f)\n", " \n", " # for category_type in result.keys():\n", " dict_list.append(result['text_block'][\"page\"][\"Edit_dist\"])\n", "df2 = pd.DataFrame(dict_list, index=ocr_types_dict.keys())\n", "\n", "reordered_df2 = df2.round(3)\n", "\n", "selected_columns = reordered_df2[[\"data_source: book\", \"data_source: PPT2PDF\", \"data_source: research_report\", \"data_source: colorful_textbook\", \"data_source: exam_paper\", \"data_source: magazine\", \"data_source: academic_literature\", \"data_source: note\", \"data_source: newspaper\"]]\n", "# selected_columns = reordered_df2[[\"data_source: book\", \"data_source: research_report\", \"data_source: colorful_textbook\", \"data_source: exam_paper\", \"data_source: magazine\", \"data_source: academic_literature\"]]\n", "# calculate mean\n", "# selected_columns['mean'] = selected_columns.mean(axis=1).round(3)\n", "# selected_columns['variance'] = selected_columns.var(axis=1)\n", "# selected_columns.to_csv('./data_source.csv')\n", "\n", "selected_columns" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/mnt/petrelfs/ouyanglinke/.local/lib/python3.7/site-packages/ipykernel_launcher.py:19: SettingWithCopyWarning: \n", "A value is trying to be set on a copy of a slice from a DataFrame.\n", "Try using .loc[row_indexer,col_indexer] = value instead\n", "\n", "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", "/mnt/petrelfs/ouyanglinke/.local/lib/python3.7/site-packages/ipykernel_launcher.py:20: SettingWithCopyWarning: \n", "A value is trying to be set on a copy of a slice from a DataFrame.\n", "Try using .loc[row_indexer,col_indexer] = value instead\n", "\n", "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
fuzzy_scanwatermarkcolorful_backgroudmeanvariance
MinerU-0.9.30.1500.1510.1070.1360.0004
Marker-0.2.170.2860.4360.2900.3370.0049
Marker-1.2.30.3330.4840.3190.3790.0056
Mathpix0.2940.2900.1820.2550.0027
docling0.9380.8070.8270.8570.0033
GOT-OCR0.1750.1900.1860.1840.0000
Nougat0.9340.9150.8730.9070.0006
GPT4o0.2630.1950.1840.2140.0012
Qwen2-VL-72B0.1010.1570.1140.1240.0006
InternVL2-Llama3-76B0.1200.1970.1550.1570.0010
\n", "
" ], "text/plain": [ " fuzzy_scan watermark colorful_backgroud mean \\\n", "MinerU-0.9.3 0.150 0.151 0.107 0.136 \n", "Marker-0.2.17 0.286 0.436 0.290 0.337 \n", "Marker-1.2.3 0.333 0.484 0.319 0.379 \n", "Mathpix 0.294 0.290 0.182 0.255 \n", "docling 0.938 0.807 0.827 0.857 \n", "GOT-OCR 0.175 0.190 0.186 0.184 \n", "Nougat 0.934 0.915 0.873 0.907 \n", "GPT4o 0.263 0.195 0.184 0.214 \n", "Qwen2-VL-72B 0.101 0.157 0.114 0.124 \n", "InternVL2-Llama3-76B 0.120 0.197 0.155 0.157 \n", "\n", " variance \n", "MinerU-0.9.3 0.0004 \n", "Marker-0.2.17 0.0049 \n", "Marker-1.2.3 0.0056 \n", "Mathpix 0.0027 \n", "docling 0.0033 \n", "GOT-OCR 0.0000 \n", "Nougat 0.0006 \n", "GPT4o 0.0012 \n", "Qwen2-VL-72B 0.0006 \n", "InternVL2-Llama3-76B 0.0010 " ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# page special issue\n", "dict_list = []\n", "\n", "for ocr_type in ocr_types:\n", " result_path = os.path.join(result_folder, f'{ocr_type}_{match_name}_metric_result.json')\n", " \n", " with open(result_path, 'r') as f:\n", " result = json.load(f)\n", " \n", " # for category_type in result.keys():\n", " dict_list.append(result['text_block'][\"page\"][\"Edit_dist\"])\n", "df2 = pd.DataFrame(dict_list, index=offical_names)\n", "\n", "reordered_df2 = df2.round(3)\n", "reordered_df2\n", "\n", "selected_columns = reordered_df2[['fuzzy_scan', 'watermark', 'colorful_backgroud']]\n", "# calculate mean and variance\n", "selected_columns['mean'] = selected_columns.mean(axis=1).round(3)\n", "selected_columns['variance'] = selected_columns.var(axis=1).round(4)\n", "\n", "# selected_columns.to_csv('./page_issue.csv')\n", "selected_columns" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/mnt/petrelfs/ouyanglinke/.local/lib/python3.7/site-packages/ipykernel_launcher.py:20: SettingWithCopyWarning: \n", "A value is trying to be set on a copy of a slice from a DataFrame.\n", "Try using .loc[row_indexer,col_indexer] = value instead\n", "\n", "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", "/mnt/petrelfs/ouyanglinke/.local/lib/python3.7/site-packages/ipykernel_launcher.py:21: SettingWithCopyWarning: \n", "A value is trying to be set on a copy of a slice from a DataFrame.\n", "Try using .loc[row_indexer,col_indexer] = value instead\n", "\n", "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
layout: single_columnlayout: double_columnlayout: three_columnlayout: other_layoutmeanvariance
MinerU-0.9.30.3110.1010.1170.3760.2260.0143
Marker-0.2.170.2310.2510.3090.3780.2920.0033
Marker-1.2.30.2990.2990.1490.3630.2770.0062
Mathpix0.1890.1750.2250.4130.2500.0091
docling0.7580.5350.8290.7010.7060.0118
GOT-OCR0.1630.1450.2720.4680.2620.0165
Nougat0.8520.6010.6760.8730.7500.0133
GPT4o0.1090.2040.2540.4260.2480.0132
Qwen2-VL-72B0.0980.2480.5140.4290.3220.0260
InternVL2-Llama3-76B0.0820.3120.6820.4440.3800.0472
\n", "
" ], "text/plain": [ " layout: single_column layout: double_column \\\n", "MinerU-0.9.3 0.311 0.101 \n", "Marker-0.2.17 0.231 0.251 \n", "Marker-1.2.3 0.299 0.299 \n", "Mathpix 0.189 0.175 \n", "docling 0.758 0.535 \n", "GOT-OCR 0.163 0.145 \n", "Nougat 0.852 0.601 \n", "GPT4o 0.109 0.204 \n", "Qwen2-VL-72B 0.098 0.248 \n", "InternVL2-Llama3-76B 0.082 0.312 \n", "\n", " layout: three_column layout: other_layout mean \\\n", "MinerU-0.9.3 0.117 0.376 0.226 \n", "Marker-0.2.17 0.309 0.378 0.292 \n", "Marker-1.2.3 0.149 0.363 0.277 \n", "Mathpix 0.225 0.413 0.250 \n", "docling 0.829 0.701 0.706 \n", "GOT-OCR 0.272 0.468 0.262 \n", "Nougat 0.676 0.873 0.750 \n", "GPT4o 0.254 0.426 0.248 \n", "Qwen2-VL-72B 0.514 0.429 0.322 \n", "InternVL2-Llama3-76B 0.682 0.444 0.380 \n", "\n", " variance \n", "MinerU-0.9.3 0.0143 \n", "Marker-0.2.17 0.0033 \n", "Marker-1.2.3 0.0062 \n", "Mathpix 0.0091 \n", "docling 0.0118 \n", "GOT-OCR 0.0165 \n", "Nougat 0.0133 \n", "GPT4o 0.0132 \n", "Qwen2-VL-72B 0.0260 \n", "InternVL2-Llama3-76B 0.0472 " ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# reading order under different layout\n", "dict_list = []\n", "\n", "for ocr_type in ocr_types:\n", " result_path = os.path.join(result_folder, f'{ocr_type}_{match_name}_metric_result.json')\n", " \n", " with open(result_path, 'r') as f:\n", " result = json.load(f)\n", " \n", " # for category_type in result.keys():\n", " dict_list.append(result['reading_order'][\"page\"][\"Edit_dist\"])\n", "\n", "df3 = pd.DataFrame(dict_list, index=offical_names)\n", "\n", "reordered_df3 = df3.round(3)\n", "\n", "\n", "selected_columns3 = reordered_df3[[\"layout: single_column\", \"layout: double_column\", \"layout: three_column\", \"layout: other_layout\"]]\n", "# calculate mean and variance\n", "selected_columns3['mean'] = selected_columns3.mean(axis=1).round(3)\n", "selected_columns3['variance'] = selected_columns3.var(axis=1).round(4)\n", "\n", "# selected_columns3.to_csv('./layout.csv')\n", "selected_columns3" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
text_language: text_englishtext_language: text_simplified_chinesetext_language: text_en_ch_mixedtext_background: whitetext_background: single_coloredtext_background: multi_colored
MinerU-0.9.30.1240.2060.7420.1630.1470.513
Marker-0.2.170.2670.3900.4990.3400.3890.497
Marker-1.2.30.1630.3790.7470.3030.3960.594
Mathpix0.1730.7740.5380.6750.5540.570
docling0.5380.9800.9310.8590.7980.927
GOT-OCR0.2520.7630.2660.6690.5950.440
Nougat0.5880.9910.9830.8750.9350.972
GPT4o0.1710.6470.3220.5360.4230.406
Qwen2-VL-72B0.3370.5750.3100.5370.4000.233
InternVL2-Llama3-76B0.4180.6060.2510.5890.3660.221
\n", "
" ], "text/plain": [ " text_language: text_english \\\n", "MinerU-0.9.3 0.124 \n", "Marker-0.2.17 0.267 \n", "Marker-1.2.3 0.163 \n", "Mathpix 0.173 \n", "docling 0.538 \n", "GOT-OCR 0.252 \n", "Nougat 0.588 \n", "GPT4o 0.171 \n", "Qwen2-VL-72B 0.337 \n", "InternVL2-Llama3-76B 0.418 \n", "\n", " text_language: text_simplified_chinese \\\n", "MinerU-0.9.3 0.206 \n", "Marker-0.2.17 0.390 \n", "Marker-1.2.3 0.379 \n", "Mathpix 0.774 \n", "docling 0.980 \n", "GOT-OCR 0.763 \n", "Nougat 0.991 \n", "GPT4o 0.647 \n", "Qwen2-VL-72B 0.575 \n", "InternVL2-Llama3-76B 0.606 \n", "\n", " text_language: text_en_ch_mixed text_background: white \\\n", "MinerU-0.9.3 0.742 0.163 \n", "Marker-0.2.17 0.499 0.340 \n", "Marker-1.2.3 0.747 0.303 \n", "Mathpix 0.538 0.675 \n", "docling 0.931 0.859 \n", "GOT-OCR 0.266 0.669 \n", "Nougat 0.983 0.875 \n", "GPT4o 0.322 0.536 \n", "Qwen2-VL-72B 0.310 0.537 \n", "InternVL2-Llama3-76B 0.251 0.589 \n", "\n", " text_background: single_colored \\\n", "MinerU-0.9.3 0.147 \n", "Marker-0.2.17 0.389 \n", "Marker-1.2.3 0.396 \n", "Mathpix 0.554 \n", "docling 0.798 \n", "GOT-OCR 0.595 \n", "Nougat 0.935 \n", "GPT4o 0.423 \n", "Qwen2-VL-72B 0.400 \n", "InternVL2-Llama3-76B 0.366 \n", "\n", " text_background: multi_colored \n", "MinerU-0.9.3 0.513 \n", "Marker-0.2.17 0.497 \n", "Marker-1.2.3 0.594 \n", "Mathpix 0.570 \n", "docling 0.927 \n", "GOT-OCR 0.440 \n", "Nougat 0.972 \n", "GPT4o 0.406 \n", "Qwen2-VL-72B 0.233 \n", "InternVL2-Llama3-76B 0.221 " ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# text attribute\n", "dict_list = []\n", "\n", "for ocr_type in ocr_types:\n", " result_path = os.path.join(result_folder, f'{ocr_type}_{match_name}_metric_result.json')\n", " \n", " with open(result_path, 'r') as f:\n", " result = json.load(f)\n", " \n", " # for category_type in result.keys():\n", " dict_list.append(result['text_block'][\"group\"][\"Edit_dist\"])\n", "\n", "df4 = pd.DataFrame(dict_list, index=offical_names)\n", "df4 = df4.round(3)\n", "\n", "selected_columns = df4[[\"text_language: text_english\", \"text_language: text_simplified_chinese\", \"text_language: text_en_ch_mixed\", \"text_background: white\", \"text_background: single_colored\", \"text_background: multi_colored\"]]\n", "\n", "# selected_columns.to_csv('.text_attribute.csv')\n", "selected_columns" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
language: table_enlanguage: table_simplified_chineselanguage: table_en_ch_mixedline: full_lineline: less_lineline: fewer_lineline: wireless_linewith_span: Truewith_span: Falseinclude_equation: Trueinclude_equation: Falseinclude_background: Trueinclude_background: Falsetable_layout: verticaltable_layout: horizontal
MinerU-0.9.375.159.379.159.471.669.760.063.665.366.064.459.267.53.065.8
Marker-0.2.1752.042.044.141.053.846.551.443.346.142.045.843.645.86.345.7
Marker-1.2.364.947.349.844.561.859.063.652.652.753.252.548.054.935.552.9
Mathpix75.463.271.367.477.366.325.570.365.468.766.759.770.819.267.9
docling58.224.130.125.933.548.022.734.034.743.832.328.837.34.935.0
GOT-OCR51.746.249.045.548.351.346.246.048.945.748.439.851.90.048.7
Nougat36.20.30.06.13.522.10.015.08.921.08.72.615.20.011.2
GPT4o71.158.057.362.568.761.331.256.864.760.862.261.462.214.262.7
Qwen2-VL-72B57.062.572.170.263.548.157.249.367.647.964.363.160.241.461.5
InternVL2-Llama3-76B60.958.565.458.865.358.355.649.065.153.360.958.859.86.960.3
\n", "
" ], "text/plain": [ " language: table_en language: table_simplified_chinese \\\n", "MinerU-0.9.3 75.1 59.3 \n", "Marker-0.2.17 52.0 42.0 \n", "Marker-1.2.3 64.9 47.3 \n", "Mathpix 75.4 63.2 \n", "docling 58.2 24.1 \n", "GOT-OCR 51.7 46.2 \n", "Nougat 36.2 0.3 \n", "GPT4o 71.1 58.0 \n", "Qwen2-VL-72B 57.0 62.5 \n", "InternVL2-Llama3-76B 60.9 58.5 \n", "\n", " language: table_en_ch_mixed line: full_line \\\n", "MinerU-0.9.3 79.1 59.4 \n", "Marker-0.2.17 44.1 41.0 \n", "Marker-1.2.3 49.8 44.5 \n", "Mathpix 71.3 67.4 \n", "docling 30.1 25.9 \n", "GOT-OCR 49.0 45.5 \n", "Nougat 0.0 6.1 \n", "GPT4o 57.3 62.5 \n", "Qwen2-VL-72B 72.1 70.2 \n", "InternVL2-Llama3-76B 65.4 58.8 \n", "\n", " line: less_line line: fewer_line line: wireless_line \\\n", "MinerU-0.9.3 71.6 69.7 60.0 \n", "Marker-0.2.17 53.8 46.5 51.4 \n", "Marker-1.2.3 61.8 59.0 63.6 \n", "Mathpix 77.3 66.3 25.5 \n", "docling 33.5 48.0 22.7 \n", "GOT-OCR 48.3 51.3 46.2 \n", "Nougat 3.5 22.1 0.0 \n", "GPT4o 68.7 61.3 31.2 \n", "Qwen2-VL-72B 63.5 48.1 57.2 \n", "InternVL2-Llama3-76B 65.3 58.3 55.6 \n", "\n", " with_span: True with_span: False \\\n", "MinerU-0.9.3 63.6 65.3 \n", "Marker-0.2.17 43.3 46.1 \n", "Marker-1.2.3 52.6 52.7 \n", "Mathpix 70.3 65.4 \n", "docling 34.0 34.7 \n", "GOT-OCR 46.0 48.9 \n", "Nougat 15.0 8.9 \n", "GPT4o 56.8 64.7 \n", "Qwen2-VL-72B 49.3 67.6 \n", "InternVL2-Llama3-76B 49.0 65.1 \n", "\n", " include_equation: True include_equation: False \\\n", "MinerU-0.9.3 66.0 64.4 \n", "Marker-0.2.17 42.0 45.8 \n", "Marker-1.2.3 53.2 52.5 \n", "Mathpix 68.7 66.7 \n", "docling 43.8 32.3 \n", "GOT-OCR 45.7 48.4 \n", "Nougat 21.0 8.7 \n", "GPT4o 60.8 62.2 \n", "Qwen2-VL-72B 47.9 64.3 \n", "InternVL2-Llama3-76B 53.3 60.9 \n", "\n", " include_background: True include_background: False \\\n", "MinerU-0.9.3 59.2 67.5 \n", "Marker-0.2.17 43.6 45.8 \n", "Marker-1.2.3 48.0 54.9 \n", "Mathpix 59.7 70.8 \n", "docling 28.8 37.3 \n", "GOT-OCR 39.8 51.9 \n", "Nougat 2.6 15.2 \n", "GPT4o 61.4 62.2 \n", "Qwen2-VL-72B 63.1 60.2 \n", "InternVL2-Llama3-76B 58.8 59.8 \n", "\n", " table_layout: vertical table_layout: horizontal \n", "MinerU-0.9.3 3.0 65.8 \n", "Marker-0.2.17 6.3 45.7 \n", "Marker-1.2.3 35.5 52.9 \n", "Mathpix 19.2 67.9 \n", "docling 4.9 35.0 \n", "GOT-OCR 0.0 48.7 \n", "Nougat 0.0 11.2 \n", "GPT4o 14.2 62.7 \n", "Qwen2-VL-72B 41.4 61.5 \n", "InternVL2-Llama3-76B 6.9 60.3 " ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# table attribute\n", "dict_list = []\n", "\n", "for ocr_type in ocr_types:\n", " result_path = os.path.join(result_folder, f'{ocr_type}_{match_name}_metric_result.json')\n", " \n", " with open(result_path, 'r') as f:\n", " result = json.load(f)\n", " \n", " # for category_type in result.keys():\n", " dict_list.append(result['table'][\"group\"][\"TEDS\"])\n", "\n", "df4 = pd.DataFrame(dict_list, index=offical_names)\n", "df4 = df4 * 100\n", "df4 = df4.round(1)\n", "\n", "selected_columns = df4[[\"language: table_en\", \"language: table_simplified_chinese\", \"language: table_en_ch_mixed\", \"line: full_line\", \"line: less_line\", \"line: fewer_line\", \"line: wireless_line\", \n", " \"with_span: True\", \"with_span: False\", \"include_equation: True\", \"include_equation: False\", \"include_background: True\", \"include_background: False\", \"table_layout: vertical\", \"table_layout: horizontal\"]]\n", "\n", "# selected_columns.to_csv('./table_attribute.csv')\n", "selected_columns" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
text_language: text_englishtext_language: text_simplified_chinesetext_language: text_en_ch_mixedtext_background: whitetext_background: single_coloredtext_background: multi_coloredtext_rotate: normaltext_rotate: rotate90text_rotate: rotate270text_rotate: horizontal
OmniDocBench_easyocr_text_ocr0.260.3980.4450.3660.2870.3880.3600.9700.9970.926
OmniDocBench_openocr_text_ocr0.070.0680.1060.0690.0580.0810.0690.0380.8910.025
\n", "
" ], "text/plain": [ " text_language: text_english \\\n", "OmniDocBench_easyocr_text_ocr 0.26 \n", "OmniDocBench_openocr_text_ocr 0.07 \n", "\n", " text_language: text_simplified_chinese \\\n", "OmniDocBench_easyocr_text_ocr 0.398 \n", "OmniDocBench_openocr_text_ocr 0.068 \n", "\n", " text_language: text_en_ch_mixed \\\n", "OmniDocBench_easyocr_text_ocr 0.445 \n", "OmniDocBench_openocr_text_ocr 0.106 \n", "\n", " text_background: white \\\n", "OmniDocBench_easyocr_text_ocr 0.366 \n", "OmniDocBench_openocr_text_ocr 0.069 \n", "\n", " text_background: single_colored \\\n", "OmniDocBench_easyocr_text_ocr 0.287 \n", "OmniDocBench_openocr_text_ocr 0.058 \n", "\n", " text_background: multi_colored \\\n", "OmniDocBench_easyocr_text_ocr 0.388 \n", "OmniDocBench_openocr_text_ocr 0.081 \n", "\n", " text_rotate: normal text_rotate: rotate90 \\\n", "OmniDocBench_easyocr_text_ocr 0.360 0.970 \n", "OmniDocBench_openocr_text_ocr 0.069 0.038 \n", "\n", " text_rotate: rotate270 text_rotate: horizontal \n", "OmniDocBench_easyocr_text_ocr 0.997 0.926 \n", "OmniDocBench_openocr_text_ocr 0.891 0.025 " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# text OCR\n", "\n", "ocr_types = ['OmniDocBench_easyocr_text_ocr', 'OmniDocBench_openocr_text_ocr']\n", "offical_names = ocr_types\n", "\n", "result_folder = '/mnt/petrelfs/ouyanglinke/OmniDocBench/result'\n", "\n", "dict_list = []\n", "\n", "for ocr_type in ocr_types:\n", " result_path = os.path.join(result_folder, f'{ocr_type}_metric_result.json')\n", " \n", " with open(result_path, 'r') as f:\n", " result = json.load(f)\n", " \n", " # for category_type in result.keys():\n", " dict_list.append(result[\"group\"][\"Edit_dist\"])\n", "\n", "df4 = pd.DataFrame(dict_list, index=offical_names)\n", "df4 = df4.round(3)\n", "\n", "selected_columns = df4[[\"text_language: text_english\", \"text_language: text_simplified_chinese\", \"text_language: text_en_ch_mixed\", \"text_background: white\", \"text_background: single_colored\", \"text_background: multi_colored\", \"text_rotate: normal\", \"text_rotate: rotate90\", \"text_rotate: rotate270\", \"text_rotate: horizontal\"]]\n", "\n", "# selected_columns.to_csv('.text_attribute.csv')\n", "selected_columns" ] } ], "metadata": { "kernelspec": { "display_name": "layoutlmv3", "language": "python", "name": "layoutlmv3" }, "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.7.16" } }, "nbformat": 4, "nbformat_minor": 2 }