2021-05-18 11:13:07 +08:00
{
"nbformat": 4,
2022-03-21 19:38:35 +08:00
"nbformat_minor": 0,
2021-05-18 11:13:07 +08:00
"metadata": {
"colab": {
"name": "mmocr.ipynb",
"provenance": [],
"collapsed_sections": [],
2021-08-25 11:45:47 +08:00
"toc_visible": true
2021-05-18 11:13:07 +08:00
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3",
"language": "python"
},
"language_info": {
"name": "python",
"version": "3.8.5"
},
2021-08-25 11:45:47 +08:00
"accelerator": "GPU",
"widgets": {
"application/vnd.jupyter.widget-state+json": {
2022-03-21 19:38:35 +08:00
"9922c33a131f41cfac84af47b5e5981c": {
2021-08-25 11:45:47 +08:00
"model_module": "@jupyter-widgets/controls",
"model_name": "HBoxModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
2022-03-21 19:38:35 +08:00
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
2021-08-25 11:45:47 +08:00
"_model_name": "HBoxModel",
2022-03-21 19:38:35 +08:00
"_view_count": null,
2021-08-25 11:45:47 +08:00
"_view_module": "@jupyter-widgets/controls",
2022-03-21 19:38:35 +08:00
"_view_module_version": "1.5.0",
"_view_name": "HBoxView",
"box_style": "",
"children": [
"IPY_MODEL_9be2b6bd525c4b31be2d386b37d573b6",
"IPY_MODEL_edb36ab14ab44bc98983d447c1cb150a",
"IPY_MODEL_46dafdb514c049a7bb18ada61c7dee49"
],
"layout": "IPY_MODEL_c267e0b248154c028a93390ea187ef7f"
}
},
"9be2b6bd525c4b31be2d386b37d573b6": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
2021-08-25 11:45:47 +08:00
"_model_module_version": "1.5.0",
2022-03-21 19:38:35 +08:00
"_model_name": "HTMLModel",
2021-08-25 11:45:47 +08:00
"_view_count": null,
2022-03-21 19:38:35 +08:00
"_view_module": "@jupyter-widgets/controls",
2021-08-25 11:45:47 +08:00
"_view_module_version": "1.5.0",
2022-03-21 19:38:35 +08:00
"_view_name": "HTMLView",
"description": "",
"description_tooltip": null,
"layout": "IPY_MODEL_e2bc0c96bdee4d9c981f71c1001ec637",
"placeholder": " ",
"style": "IPY_MODEL_b735ff5dcd114345bc89b462bc276759",
"value": "100%"
}
},
"edb36ab14ab44bc98983d447c1cb150a": {
"model_module": "@jupyter-widgets/controls",
"model_name": "FloatProgressModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "FloatProgressModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "ProgressView",
"bar_style": "success",
"description": "",
"description_tooltip": null,
"layout": "IPY_MODEL_5ef02d42f1d34f6a81dbbe8b4fbd7ffc",
"max": 229956710,
"min": 0,
"orientation": "horizontal",
"style": "IPY_MODEL_1712f2cbff4a4cbdaaa238d89905ec21",
"value": 229956710
}
},
"46dafdb514c049a7bb18ada61c7dee49": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "HTMLModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "HTMLView",
"description": "",
"description_tooltip": null,
"layout": "IPY_MODEL_1e43262b71ef45f1a5535d78594a0235",
"placeholder": " ",
"style": "IPY_MODEL_5e7c98e0dbc4463c81b15c56c48ba1cf",
"value": " 219M/219M [00:30<00:00, 7.18MB/s]"
}
},
"c267e0b248154c028a93390ea187ef7f": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_model_module": "@jupyter-widgets/base",
"_model_module_version": "1.2.0",
"_model_name": "LayoutModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "LayoutView",
"align_content": null,
"align_items": null,
"align_self": null,
"border": null,
"bottom": null,
"display": null,
"flex": null,
"flex_flow": null,
"grid_area": null,
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
"grid_template_columns": null,
"grid_template_rows": null,
"height": null,
"justify_content": null,
"justify_items": null,
"left": null,
"margin": null,
"max_height": null,
"max_width": null,
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
"overflow": null,
"overflow_x": null,
"overflow_y": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": null
}
},
"e2bc0c96bdee4d9c981f71c1001ec637": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_model_module": "@jupyter-widgets/base",
"_model_module_version": "1.2.0",
"_model_name": "LayoutModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "LayoutView",
"align_content": null,
"align_items": null,
"align_self": null,
"border": null,
"bottom": null,
"display": null,
"flex": null,
"flex_flow": null,
"grid_area": null,
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
"grid_template_columns": null,
"grid_template_rows": null,
"height": null,
"justify_content": null,
"justify_items": null,
"left": null,
"margin": null,
"max_height": null,
"max_width": null,
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
"overflow": null,
"overflow_x": null,
"overflow_y": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": null
}
},
"b735ff5dcd114345bc89b462bc276759": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"model_module_version": "1.5.0",
"state": {
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "DescriptionStyleModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "StyleView",
"description_width": ""
}
},
"5ef02d42f1d34f6a81dbbe8b4fbd7ffc": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_model_module": "@jupyter-widgets/base",
"_model_module_version": "1.2.0",
"_model_name": "LayoutModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "LayoutView",
"align_content": null,
"align_items": null,
"align_self": null,
"border": null,
"bottom": null,
"display": null,
"flex": null,
"flex_flow": null,
"grid_area": null,
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
"grid_template_columns": null,
"grid_template_rows": null,
"height": null,
"justify_content": null,
"justify_items": null,
"left": null,
"margin": null,
"max_height": null,
"max_width": null,
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
"overflow": null,
"overflow_x": null,
"overflow_y": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": null
}
},
"1712f2cbff4a4cbdaaa238d89905ec21": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ProgressStyleModel",
"model_module_version": "1.5.0",
"state": {
2021-08-25 11:45:47 +08:00
"_model_module": "@jupyter-widgets/controls",
2022-03-21 19:38:35 +08:00
"_model_module_version": "1.5.0",
"_model_name": "ProgressStyleModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "StyleView",
"bar_color": null,
"description_width": ""
}
},
"1e43262b71ef45f1a5535d78594a0235": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_model_module": "@jupyter-widgets/base",
"_model_module_version": "1.2.0",
"_model_name": "LayoutModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "LayoutView",
"align_content": null,
"align_items": null,
"align_self": null,
"border": null,
"bottom": null,
"display": null,
"flex": null,
"flex_flow": null,
"grid_area": null,
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
"grid_template_columns": null,
"grid_template_rows": null,
"height": null,
"justify_content": null,
"justify_items": null,
"left": null,
"margin": null,
"max_height": null,
"max_width": null,
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
"overflow": null,
"overflow_x": null,
"overflow_y": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": null
}
},
"5e7c98e0dbc4463c81b15c56c48ba1cf": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"model_module_version": "1.5.0",
"state": {
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "DescriptionStyleModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "StyleView",
"description_width": ""
}
},
"0cfa2ece94314ed186b834646623852a": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HBoxModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "HBoxModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "HBoxView",
"box_style": "",
2021-08-25 11:45:47 +08:00
"children": [
2022-03-21 19:38:35 +08:00
"IPY_MODEL_5f5f9ed460404047bfda112283b4f159",
"IPY_MODEL_7c6bbe29702444b9a6adfef0d11f2a5c",
"IPY_MODEL_b48490fd9f0d4cc38acd6c0ccf57b68a"
],
"layout": "IPY_MODEL_6f6240bf87a3442dbce39764c97dbd8f"
}
},
"5f5f9ed460404047bfda112283b4f159": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "HTMLModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "HTMLView",
"description": "",
"description_tooltip": null,
"layout": "IPY_MODEL_b3adfe1225ac4497ae818e5a78132c34",
"placeholder": " ",
"style": "IPY_MODEL_c36a853d851249c49c63599219f73c38",
"value": "100%"
}
},
"7c6bbe29702444b9a6adfef0d11f2a5c": {
"model_module": "@jupyter-widgets/controls",
"model_name": "FloatProgressModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "FloatProgressModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "ProgressView",
"bar_style": "success",
"description": "",
"description_tooltip": null,
"layout": "IPY_MODEL_a4d14f12345b4956a7861d5c54a51fad",
"max": 145703066,
"min": 0,
"orientation": "horizontal",
"style": "IPY_MODEL_592582312a0c4ddfa40e55026fd51e3f",
"value": 145703066
}
},
"b48490fd9f0d4cc38acd6c0ccf57b68a": {
"model_module": "@jupyter-widgets/controls",
"model_name": "HTMLModel",
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "HTMLModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "HTMLView",
"description": "",
"description_tooltip": null,
"layout": "IPY_MODEL_3947416ef2c245d197e7b254d0d513b8",
"placeholder": " ",
"style": "IPY_MODEL_dc187713177749469e49eed82769df1c",
"value": " 139M/139M [00:22<00:00, 5.26MB/s]"
2021-08-25 11:45:47 +08:00
}
},
2022-03-21 19:38:35 +08:00
"6f6240bf87a3442dbce39764c97dbd8f": {
2021-08-25 11:45:47 +08:00
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
2022-03-21 19:38:35 +08:00
"_model_module": "@jupyter-widgets/base",
"_model_module_version": "1.2.0",
"_model_name": "LayoutModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
2021-08-25 11:45:47 +08:00
"_view_name": "LayoutView",
2022-03-21 19:38:35 +08:00
"align_content": null,
"align_items": null,
"align_self": null,
"border": null,
"bottom": null,
"display": null,
"flex": null,
"flex_flow": null,
"grid_area": null,
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
"grid_template_columns": null,
2021-08-25 11:45:47 +08:00
"grid_template_rows": null,
2022-03-21 19:38:35 +08:00
"height": null,
2021-08-25 11:45:47 +08:00
"justify_content": null,
2022-03-21 19:38:35 +08:00
"justify_items": null,
"left": null,
"margin": null,
"max_height": null,
"max_width": null,
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
2021-08-25 11:45:47 +08:00
"overflow": null,
2022-03-21 19:38:35 +08:00
"overflow_x": null,
"overflow_y": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": null
}
},
"b3adfe1225ac4497ae818e5a78132c34": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_model_module": "@jupyter-widgets/base",
2021-08-25 11:45:47 +08:00
"_model_module_version": "1.2.0",
2022-03-21 19:38:35 +08:00
"_model_name": "LayoutModel",
2021-08-25 11:45:47 +08:00
"_view_count": null,
2022-03-21 19:38:35 +08:00
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "LayoutView",
"align_content": null,
2021-08-25 11:45:47 +08:00
"align_items": null,
2022-03-21 19:38:35 +08:00
"align_self": null,
"border": null,
2021-08-25 11:45:47 +08:00
"bottom": null,
2022-03-21 19:38:35 +08:00
"display": null,
"flex": null,
"flex_flow": null,
2021-08-25 11:45:47 +08:00
"grid_area": null,
2022-03-21 19:38:35 +08:00
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
2021-08-25 11:45:47 +08:00
"grid_template_columns": null,
2022-03-21 19:38:35 +08:00
"grid_template_rows": null,
"height": null,
"justify_content": null,
2021-08-25 11:45:47 +08:00
"justify_items": null,
2022-03-21 19:38:35 +08:00
"left": null,
"margin": null,
2021-08-25 11:45:47 +08:00
"max_height": null,
2022-03-21 19:38:35 +08:00
"max_width": null,
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
"overflow": null,
"overflow_x": null,
"overflow_y": null,
"padding": null,
"right": null,
"top": null,
2021-08-25 11:45:47 +08:00
"visibility": null,
2022-03-21 19:38:35 +08:00
"width": null
}
},
"c36a853d851249c49c63599219f73c38": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"model_module_version": "1.5.0",
"state": {
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "DescriptionStyleModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "StyleView",
"description_width": ""
}
},
"a4d14f12345b4956a7861d5c54a51fad": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_model_module": "@jupyter-widgets/base",
"_model_module_version": "1.2.0",
"_model_name": "LayoutModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "LayoutView",
"align_content": null,
"align_items": null,
2021-08-25 11:45:47 +08:00
"align_self": null,
2022-03-21 19:38:35 +08:00
"border": null,
"bottom": null,
"display": null,
"flex": null,
"flex_flow": null,
"grid_area": null,
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
"grid_template_columns": null,
"grid_template_rows": null,
2021-08-25 11:45:47 +08:00
"height": null,
2022-03-21 19:38:35 +08:00
"justify_content": null,
"justify_items": null,
"left": null,
"margin": null,
"max_height": null,
"max_width": null,
2021-08-25 11:45:47 +08:00
"min_height": null,
2022-03-21 19:38:35 +08:00
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
"overflow": null,
"overflow_x": null,
"overflow_y": null,
2021-08-25 11:45:47 +08:00
"padding": null,
2022-03-21 19:38:35 +08:00
"right": null,
"top": null,
"visibility": null,
"width": null
}
},
"592582312a0c4ddfa40e55026fd51e3f": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ProgressStyleModel",
"model_module_version": "1.5.0",
"state": {
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "ProgressStyleModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "StyleView",
"bar_color": null,
"description_width": ""
}
},
"3947416ef2c245d197e7b254d0d513b8": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_model_module": "@jupyter-widgets/base",
"_model_module_version": "1.2.0",
"_model_name": "LayoutModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "LayoutView",
"align_content": null,
"align_items": null,
"align_self": null,
"border": null,
"bottom": null,
"display": null,
"flex": null,
"flex_flow": null,
"grid_area": null,
"grid_auto_columns": null,
"grid_auto_flow": null,
2021-08-25 11:45:47 +08:00
"grid_auto_rows": null,
2022-03-21 19:38:35 +08:00
"grid_column": null,
2021-08-25 11:45:47 +08:00
"grid_gap": null,
2022-03-21 19:38:35 +08:00
"grid_row": null,
"grid_template_areas": null,
"grid_template_columns": null,
"grid_template_rows": null,
"height": null,
"justify_content": null,
"justify_items": null,
"left": null,
"margin": null,
"max_height": null,
2021-08-25 11:45:47 +08:00
"max_width": null,
2022-03-21 19:38:35 +08:00
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
2021-08-25 11:45:47 +08:00
"order": null,
2022-03-21 19:38:35 +08:00
"overflow": null,
"overflow_x": null,
"overflow_y": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": null
}
},
"dc187713177749469e49eed82769df1c": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"model_module_version": "1.5.0",
"state": {
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "DescriptionStyleModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
2021-08-25 11:45:47 +08:00
"_view_module_version": "1.2.0",
2022-03-21 19:38:35 +08:00
"_view_name": "StyleView",
"description_width": ""
2021-08-25 11:45:47 +08:00
}
},
2022-03-21 19:38:35 +08:00
"cd5e91174a6441ad9d7b8c0a05f18f60": {
2021-08-25 11:45:47 +08:00
"model_module": "@jupyter-widgets/controls",
2022-03-21 19:38:35 +08:00
"model_name": "HBoxModel",
2021-08-25 11:45:47 +08:00
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
2022-03-21 19:38:35 +08:00
"_model_module": "@jupyter-widgets/controls",
2021-08-25 11:45:47 +08:00
"_model_module_version": "1.5.0",
2022-03-21 19:38:35 +08:00
"_model_name": "HBoxModel",
2021-08-25 11:45:47 +08:00
"_view_count": null,
2022-03-21 19:38:35 +08:00
"_view_module": "@jupyter-widgets/controls",
2021-08-25 11:45:47 +08:00
"_view_module_version": "1.5.0",
2022-03-21 19:38:35 +08:00
"_view_name": "HBoxView",
"box_style": "",
"children": [
"IPY_MODEL_7f0e77d508574ec485243125375cedfb",
"IPY_MODEL_45cc8c746da74a8fbc32d5bdfb1e350e",
"IPY_MODEL_4153b5f7dd474c079cb9b38f79d515d8"
],
"layout": "IPY_MODEL_31a4e677ff8849e8b9050ece3e516413"
2021-08-25 11:45:47 +08:00
}
},
2022-03-21 19:38:35 +08:00
"7f0e77d508574ec485243125375cedfb": {
2021-08-25 11:45:47 +08:00
"model_module": "@jupyter-widgets/controls",
2022-03-21 19:38:35 +08:00
"model_name": "HTMLModel",
2021-08-25 11:45:47 +08:00
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
2022-03-21 19:38:35 +08:00
"_model_module": "@jupyter-widgets/controls",
2021-08-25 11:45:47 +08:00
"_model_module_version": "1.5.0",
2022-03-21 19:38:35 +08:00
"_model_name": "HTMLModel",
2021-08-25 11:45:47 +08:00
"_view_count": null,
2022-03-21 19:38:35 +08:00
"_view_module": "@jupyter-widgets/controls",
2021-08-25 11:45:47 +08:00
"_view_module_version": "1.5.0",
2022-03-21 19:38:35 +08:00
"_view_name": "HTMLView",
"description": "",
2021-08-25 11:45:47 +08:00
"description_tooltip": null,
2022-03-21 19:38:35 +08:00
"layout": "IPY_MODEL_3761f71633874fd39205adb5fafe98fe",
"placeholder": " ",
"style": "IPY_MODEL_12377605aaa24988b2075e88c5fd77cc",
"value": "100%"
2021-08-25 11:45:47 +08:00
}
},
2022-03-21 19:38:35 +08:00
"45cc8c746da74a8fbc32d5bdfb1e350e": {
2021-08-25 11:45:47 +08:00
"model_module": "@jupyter-widgets/controls",
2022-03-21 19:38:35 +08:00
"model_name": "FloatProgressModel",
2021-08-25 11:45:47 +08:00
"model_module_version": "1.5.0",
"state": {
"_dom_classes": [],
2022-03-21 19:38:35 +08:00
"_model_module": "@jupyter-widgets/controls",
2021-08-25 11:45:47 +08:00
"_model_module_version": "1.5.0",
2022-03-21 19:38:35 +08:00
"_model_name": "FloatProgressModel",
2021-08-25 11:45:47 +08:00
"_view_count": null,
2022-03-21 19:38:35 +08:00
"_view_module": "@jupyter-widgets/controls",
2021-08-25 11:45:47 +08:00
"_view_module_version": "1.5.0",
2022-03-21 19:38:35 +08:00
"_view_name": "ProgressView",
"bar_style": "success",
"description": "",
2021-08-25 11:45:47 +08:00
"description_tooltip": null,
2022-03-21 19:38:35 +08:00
"layout": "IPY_MODEL_39bb6e08d13c4979a731ca6c8a8e5668",
"max": 19256299,
"min": 0,
"orientation": "horizontal",
"style": "IPY_MODEL_97992daf80b5487595712d675d17a9da",
"value": 19256299
2021-08-25 11:45:47 +08:00
}
},
2022-03-21 19:38:35 +08:00
"4153b5f7dd474c079cb9b38f79d515d8": {
2021-08-25 11:45:47 +08:00
"model_module": "@jupyter-widgets/controls",
2022-03-21 19:38:35 +08:00
"model_name": "HTMLModel",
2021-08-25 11:45:47 +08:00
"model_module_version": "1.5.0",
"state": {
2022-03-21 19:38:35 +08:00
"_dom_classes": [],
"_model_module": "@jupyter-widgets/controls",
2021-08-25 11:45:47 +08:00
"_model_module_version": "1.5.0",
2022-03-21 19:38:35 +08:00
"_model_name": "HTMLModel",
2021-08-25 11:45:47 +08:00
"_view_count": null,
2022-03-21 19:38:35 +08:00
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": "1.5.0",
"_view_name": "HTMLView",
"description": "",
"description_tooltip": null,
"layout": "IPY_MODEL_f1d3884457d8426db6a59bda51249444",
"placeholder": " ",
"style": "IPY_MODEL_a2220a97632e449e95ff559987245b0b",
"value": " 18.4M/18.4M [00:02<00:00, 8.57MB/s]"
2021-08-25 11:45:47 +08:00
}
},
2022-03-21 19:38:35 +08:00
"31a4e677ff8849e8b9050ece3e516413": {
2021-08-25 11:45:47 +08:00
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
2022-03-21 19:38:35 +08:00
"_model_module": "@jupyter-widgets/base",
2021-08-25 11:45:47 +08:00
"_model_module_version": "1.2.0",
2022-03-21 19:38:35 +08:00
"_model_name": "LayoutModel",
2021-08-25 11:45:47 +08:00
"_view_count": null,
2022-03-21 19:38:35 +08:00
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "LayoutView",
"align_content": null,
2021-08-25 11:45:47 +08:00
"align_items": null,
2022-03-21 19:38:35 +08:00
"align_self": null,
"border": null,
2021-08-25 11:45:47 +08:00
"bottom": null,
2022-03-21 19:38:35 +08:00
"display": null,
"flex": null,
"flex_flow": null,
2021-08-25 11:45:47 +08:00
"grid_area": null,
2022-03-21 19:38:35 +08:00
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
2021-08-25 11:45:47 +08:00
"grid_template_columns": null,
2022-03-21 19:38:35 +08:00
"grid_template_rows": null,
"height": null,
"justify_content": null,
2021-08-25 11:45:47 +08:00
"justify_items": null,
2022-03-21 19:38:35 +08:00
"left": null,
"margin": null,
2021-08-25 11:45:47 +08:00
"max_height": null,
2022-03-21 19:38:35 +08:00
"max_width": null,
2021-08-25 11:45:47 +08:00
"min_height": null,
2022-03-21 19:38:35 +08:00
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
"overflow": null,
"overflow_x": null,
"overflow_y": null,
2021-08-25 11:45:47 +08:00
"padding": null,
2022-03-21 19:38:35 +08:00
"right": null,
"top": null,
"visibility": null,
"width": null
}
},
"3761f71633874fd39205adb5fafe98fe": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_model_module": "@jupyter-widgets/base",
"_model_module_version": "1.2.0",
"_model_name": "LayoutModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "LayoutView",
"align_content": null,
"align_items": null,
"align_self": null,
"border": null,
"bottom": null,
"display": null,
"flex": null,
"flex_flow": null,
"grid_area": null,
"grid_auto_columns": null,
"grid_auto_flow": null,
2021-08-25 11:45:47 +08:00
"grid_auto_rows": null,
2022-03-21 19:38:35 +08:00
"grid_column": null,
2021-08-25 11:45:47 +08:00
"grid_gap": null,
2022-03-21 19:38:35 +08:00
"grid_row": null,
2021-08-25 11:45:47 +08:00
"grid_template_areas": null,
2022-03-21 19:38:35 +08:00
"grid_template_columns": null,
"grid_template_rows": null,
"height": null,
"justify_content": null,
"justify_items": null,
"left": null,
2021-08-25 11:45:47 +08:00
"margin": null,
2022-03-21 19:38:35 +08:00
"max_height": null,
"max_width": null,
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
"order": null,
"overflow": null,
"overflow_x": null,
"overflow_y": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": null
2021-08-25 11:45:47 +08:00
}
},
2022-03-21 19:38:35 +08:00
"12377605aaa24988b2075e88c5fd77cc": {
2021-08-25 11:45:47 +08:00
"model_module": "@jupyter-widgets/controls",
2022-03-21 19:38:35 +08:00
"model_name": "DescriptionStyleModel",
2021-08-25 11:45:47 +08:00
"model_module_version": "1.5.0",
"state": {
2022-03-21 19:38:35 +08:00
"_model_module": "@jupyter-widgets/controls",
2021-08-25 11:45:47 +08:00
"_model_module_version": "1.5.0",
2022-03-21 19:38:35 +08:00
"_model_name": "DescriptionStyleModel",
2021-08-25 11:45:47 +08:00
"_view_count": null,
2022-03-21 19:38:35 +08:00
"_view_module": "@jupyter-widgets/base",
2021-08-25 11:45:47 +08:00
"_view_module_version": "1.2.0",
2022-03-21 19:38:35 +08:00
"_view_name": "StyleView",
"description_width": ""
2021-08-25 11:45:47 +08:00
}
},
2022-03-21 19:38:35 +08:00
"39bb6e08d13c4979a731ca6c8a8e5668": {
2021-08-25 11:45:47 +08:00
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
2022-03-21 19:38:35 +08:00
"_model_module": "@jupyter-widgets/base",
2021-08-25 11:45:47 +08:00
"_model_module_version": "1.2.0",
2022-03-21 19:38:35 +08:00
"_model_name": "LayoutModel",
2021-08-25 11:45:47 +08:00
"_view_count": null,
2022-03-21 19:38:35 +08:00
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "LayoutView",
"align_content": null,
2021-08-25 11:45:47 +08:00
"align_items": null,
2022-03-21 19:38:35 +08:00
"align_self": null,
"border": null,
2021-08-25 11:45:47 +08:00
"bottom": null,
2022-03-21 19:38:35 +08:00
"display": null,
"flex": null,
"flex_flow": null,
2021-08-25 11:45:47 +08:00
"grid_area": null,
2022-03-21 19:38:35 +08:00
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
2021-08-25 11:45:47 +08:00
"grid_template_columns": null,
2022-03-21 19:38:35 +08:00
"grid_template_rows": null,
"height": null,
"justify_content": null,
2021-08-25 11:45:47 +08:00
"justify_items": null,
2022-03-21 19:38:35 +08:00
"left": null,
"margin": null,
2021-08-25 11:45:47 +08:00
"max_height": null,
"max_width": null,
2022-03-21 19:38:35 +08:00
"min_height": null,
"min_width": null,
2021-08-25 11:45:47 +08:00
"object_fit": null,
2022-03-21 19:38:35 +08:00
"object_position": null,
"order": null,
"overflow": null,
"overflow_x": null,
"overflow_y": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": null
2021-08-25 11:45:47 +08:00
}
},
2022-03-21 19:38:35 +08:00
"97992daf80b5487595712d675d17a9da": {
2021-08-25 11:45:47 +08:00
"model_module": "@jupyter-widgets/controls",
2022-03-21 19:38:35 +08:00
"model_name": "ProgressStyleModel",
2021-08-25 11:45:47 +08:00
"model_module_version": "1.5.0",
"state": {
2022-03-21 19:38:35 +08:00
"_model_module": "@jupyter-widgets/controls",
2021-08-25 11:45:47 +08:00
"_model_module_version": "1.5.0",
2022-03-21 19:38:35 +08:00
"_model_name": "ProgressStyleModel",
2021-08-25 11:45:47 +08:00
"_view_count": null,
2022-03-21 19:38:35 +08:00
"_view_module": "@jupyter-widgets/base",
2021-08-25 11:45:47 +08:00
"_view_module_version": "1.2.0",
2022-03-21 19:38:35 +08:00
"_view_name": "StyleView",
"bar_color": null,
"description_width": ""
2021-08-25 11:45:47 +08:00
}
},
2022-03-21 19:38:35 +08:00
"f1d3884457d8426db6a59bda51249444": {
2021-08-25 11:45:47 +08:00
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
2022-03-21 19:38:35 +08:00
"_model_module": "@jupyter-widgets/base",
2021-08-25 11:45:47 +08:00
"_model_module_version": "1.2.0",
2022-03-21 19:38:35 +08:00
"_model_name": "LayoutModel",
2021-08-25 11:45:47 +08:00
"_view_count": null,
2022-03-21 19:38:35 +08:00
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "LayoutView",
"align_content": null,
2021-08-25 11:45:47 +08:00
"align_items": null,
2022-03-21 19:38:35 +08:00
"align_self": null,
"border": null,
2021-08-25 11:45:47 +08:00
"bottom": null,
2022-03-21 19:38:35 +08:00
"display": null,
"flex": null,
"flex_flow": null,
2021-08-25 11:45:47 +08:00
"grid_area": null,
2022-03-21 19:38:35 +08:00
"grid_auto_columns": null,
"grid_auto_flow": null,
"grid_auto_rows": null,
"grid_column": null,
"grid_gap": null,
"grid_row": null,
"grid_template_areas": null,
2021-08-25 11:45:47 +08:00
"grid_template_columns": null,
2022-03-21 19:38:35 +08:00
"grid_template_rows": null,
"height": null,
"justify_content": null,
2021-08-25 11:45:47 +08:00
"justify_items": null,
2022-03-21 19:38:35 +08:00
"left": null,
"margin": null,
2021-08-25 11:45:47 +08:00
"max_height": null,
"max_width": null,
2022-03-21 19:38:35 +08:00
"min_height": null,
"min_width": null,
"object_fit": null,
"object_position": null,
2021-08-25 11:45:47 +08:00
"order": null,
2022-03-21 19:38:35 +08:00
"overflow": null,
"overflow_x": null,
"overflow_y": null,
"padding": null,
"right": null,
"top": null,
"visibility": null,
"width": null
}
},
"a2220a97632e449e95ff559987245b0b": {
"model_module": "@jupyter-widgets/controls",
"model_name": "DescriptionStyleModel",
"model_module_version": "1.5.0",
"state": {
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "DescriptionStyleModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
2021-08-25 11:45:47 +08:00
"_view_module_version": "1.2.0",
2022-03-21 19:38:35 +08:00
"_view_name": "StyleView",
"description_width": ""
2021-08-25 11:45:47 +08:00
}
}
}
}
2021-05-18 11:13:07 +08:00
},
"cells": [
{
"cell_type": "markdown",
"source": [
"# MMOCR Tutorial\n",
"\n",
"Welcome to MMOCR! This is the official colab tutorial for using MMOCR. In this tutorial, you will learn how to\n",
"\n",
2021-08-25 11:45:47 +08:00
"- Perform inference with a pretrained text recognizer\n",
"- Perform inference with a pretrained text detector\n",
"- Perform end-to-end OCR with pretrained recognizer and detector\n",
"- Combine OCR with downstream tasks\n",
"- Perform inference with a pretrained Key Information Extraction (KIE) model\n",
"- Train a text recognizer with a toy dataset\n",
2021-05-18 11:13:07 +08:00
"\n",
"Let's start!"
2021-08-25 16:41:07 +08:00
],
"metadata": {
"id": "jU9T31gbQmvs"
}
2021-05-18 11:13:07 +08:00
},
{
"cell_type": "markdown",
"source": [
"## Install MMOCR"
2021-08-25 16:41:07 +08:00
],
"metadata": {
"id": "Sfvz1sywQ9_4"
}
2021-05-18 11:13:07 +08:00
},
{
2021-08-25 11:45:47 +08:00
"cell_type": "markdown",
2021-05-18 11:13:07 +08:00
"source": [
"When installing dependencies for mmocr, please ensure that all the dependency versions are compatible with each other. For instance, if CUDA 10.1 is installed, then the Pytorch version must be compatible with cu10.1. Please see [getting_started.md](docs/getting_started.md) for more details. "
2021-08-25 16:41:07 +08:00
],
"metadata": {
"id": "q3fZP1LspEUp"
}
2021-05-18 11:13:07 +08:00
},
{
"cell_type": "code",
2022-03-21 19:38:35 +08:00
"execution_count": 1,
2021-08-25 11:45:47 +08:00
"source": [
"%cd .."
],
2021-05-18 11:13:07 +08:00
"outputs": [
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stdout",
2021-05-18 11:13:07 +08:00
"text": [
2021-08-25 11:45:47 +08:00
"/\n"
2021-08-25 16:41:07 +08:00
]
2021-05-18 11:13:07 +08:00
}
2021-08-25 16:41:07 +08:00
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "rB3qciTXpEUq",
2022-03-21 19:38:35 +08:00
"outputId": "8d40f08d-47d5-48d4-dd2a-e43d5ae67529"
2021-08-25 16:41:07 +08:00
}
2021-05-18 11:13:07 +08:00
},
{
2021-08-25 11:45:47 +08:00
"cell_type": "markdown",
2021-05-18 11:13:07 +08:00
"source": [
2022-03-21 19:38:35 +08:00
"### Check PyTorch version"
2021-08-25 16:41:07 +08:00
],
"metadata": {
"id": "mSkZOdrMpEUr"
}
2021-05-18 11:13:07 +08:00
},
{
"cell_type": "code",
2022-03-21 19:38:35 +08:00
"execution_count": 3,
2021-05-18 11:13:07 +08:00
"source": [
2022-03-21 19:38:35 +08:00
"!pip show torch\n"
2021-05-18 11:13:07 +08:00
],
"outputs": [
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stdout",
2021-05-18 11:13:07 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"Name: torch\n",
"Version: 1.10.0+cu111\n",
"Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration\n",
"Home-page: https://pytorch.org/\n",
"Author: PyTorch Team\n",
"Author-email: packages@pytorch.org\n",
"License: BSD-3\n",
"Location: /usr/local/lib/python3.7/dist-packages\n",
"Requires: typing-extensions\n",
"Required-by: torchvision, torchtext, torchaudio, fastai\n"
2021-08-25 16:41:07 +08:00
]
2021-05-18 11:13:07 +08:00
}
2021-08-25 16:41:07 +08:00
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "2DBpcKj2RDfu",
2022-03-21 19:38:35 +08:00
"outputId": "68295988-9769-4667-bc14-dc308a61d69d"
2021-08-25 16:41:07 +08:00
}
2021-05-18 11:13:07 +08:00
},
{
2021-08-25 11:45:47 +08:00
"cell_type": "markdown",
2021-05-18 11:13:07 +08:00
"source": [
"### Install Dependencies "
2021-08-25 16:41:07 +08:00
],
"metadata": {
"id": "Tw7u_baQpEUs"
}
2021-05-18 11:13:07 +08:00
},
{
"cell_type": "code",
2022-03-21 19:38:35 +08:00
"execution_count": 4,
2021-05-18 11:13:07 +08:00
"source": [
"# Install mmcv-full thus we could use CUDA operators\n",
2022-03-21 19:38:35 +08:00
"!pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.10.0/index.html\n",
2021-05-18 11:13:07 +08:00
"\n",
"# Install mmdetection\n",
2021-08-25 11:45:47 +08:00
"!pip install mmdet\n",
2021-05-18 11:13:07 +08:00
"\n",
"# Install mmocr\n",
"!git clone https://github.com/open-mmlab/mmocr.git\n",
2021-06-29 17:00:47 +08:00
"%cd mmocr\n",
2021-05-18 11:13:07 +08:00
"!pip install -r requirements.txt\n",
2021-08-25 11:45:47 +08:00
"!pip install -v -e ."
2021-05-18 11:13:07 +08:00
],
"outputs": [
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stdout",
2021-05-18 11:13:07 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"Looking in links: https://download.openmmlab.com/mmcv/dist/cu111/torch1.10.0/index.html\n",
"Collecting mmcv-full\n",
" Downloading https://download.openmmlab.com/mmcv/dist/cu111/torch1.10.0/mmcv_full-1.4.6-cp37-cp37m-manylinux1_x86_64.whl (46.0 MB)\n",
"\u001b[K |████████████████████████████████| 46.0 MB 50.2 MB/s \n",
"\u001b[?25hCollecting yapf\n",
" Downloading yapf-0.32.0-py2.py3-none-any.whl (190 kB)\n",
"\u001b[K |████████████████████████████████| 190 kB 3.9 MB/s \n",
"\u001b[?25hRequirement already satisfied: Pillow in /usr/local/lib/python3.7/dist-packages (from mmcv-full) (7.1.2)\n",
"Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from mmcv-full) (1.21.5)\n",
"Collecting addict\n",
" Downloading addict-2.4.0-py3-none-any.whl (3.8 kB)\n",
2021-08-25 11:45:47 +08:00
"Requirement already satisfied: pyyaml in /usr/local/lib/python3.7/dist-packages (from mmcv-full) (3.13)\n",
2022-03-21 19:38:35 +08:00
"Requirement already satisfied: opencv-python>=3 in /usr/local/lib/python3.7/dist-packages (from mmcv-full) (4.1.2.30)\n",
"Requirement already satisfied: packaging in /usr/local/lib/python3.7/dist-packages (from mmcv-full) (21.3)\n",
"Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /usr/local/lib/python3.7/dist-packages (from packaging->mmcv-full) (3.0.7)\n",
"Installing collected packages: yapf, addict, mmcv-full\n",
"Successfully installed addict-2.4.0 mmcv-full-1.4.6 yapf-0.32.0\n",
"Collecting mmdet\n",
" Downloading mmdet-2.22.0-py3-none-any.whl (1.3 MB)\n",
"\u001b[K |████████████████████████████████| 1.3 MB 4.1 MB/s \n",
"\u001b[?25hCollecting terminaltables\n",
" Downloading terminaltables-3.1.10-py2.py3-none-any.whl (15 kB)\n",
"Requirement already satisfied: pycocotools in /usr/local/lib/python3.7/dist-packages (from mmdet) (2.0.4)\n",
2021-08-25 11:45:47 +08:00
"Requirement already satisfied: six in /usr/local/lib/python3.7/dist-packages (from mmdet) (1.15.0)\n",
2022-03-21 19:38:35 +08:00
"Requirement already satisfied: matplotlib in /usr/local/lib/python3.7/dist-packages (from mmdet) (3.2.2)\n",
"Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from mmdet) (1.21.5)\n",
"Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.7/dist-packages (from matplotlib->mmdet) (0.11.0)\n",
"Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->mmdet) (1.3.2)\n",
2021-08-25 11:45:47 +08:00
"Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->mmdet) (2.8.2)\n",
2022-03-21 19:38:35 +08:00
"Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->mmdet) (3.0.7)\n",
"Installing collected packages: terminaltables, mmdet\n",
"Successfully installed mmdet-2.22.0 terminaltables-3.1.10\n",
"Cloning into 'mmocr'...\n",
"remote: Enumerating objects: 5670, done.\u001b[K\n",
"remote: Counting objects: 100% (560/560), done.\u001b[K\n",
"remote: Compressing objects: 100% (375/375), done.\u001b[K\n",
"remote: Total 5670 (delta 252), reused 381 (delta 177), pack-reused 5110\u001b[K\n",
"Receiving objects: 100% (5670/5670), 12.35 MiB | 14.10 MiB/s, done.\n",
"Resolving deltas: 100% (3360/3360), done.\n",
2021-08-25 11:45:47 +08:00
"/mmocr\n",
2022-03-21 19:38:35 +08:00
"Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from -r requirements/build.txt (line 2)) (1.21.5)\n",
"Collecting pyclipper\n",
" Downloading pyclipper-1.3.0.post2-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (603 kB)\n",
"\u001b[K |████████████████████████████████| 603 kB 4.4 MB/s \n",
"\u001b[?25hRequirement already satisfied: torch>=1.1 in /usr/local/lib/python3.7/dist-packages (from -r requirements/build.txt (line 4)) (1.10.0+cu111)\n",
"Collecting albumentations>=1.1.0\n",
" Downloading albumentations-1.1.0-py3-none-any.whl (102 kB)\n",
"\u001b[K |████████████████████████████████| 102 kB 49.2 MB/s \n",
"\u001b[?25hRequirement already satisfied: imgaug in /usr/local/lib/python3.7/dist-packages (from -r requirements/runtime.txt (line 1)) (0.2.9)\n",
"Collecting lanms-neo==1.0.2\n",
" Downloading lanms_neo-1.0.2.tar.gz (39 kB)\n",
" Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n",
" Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n",
" Preparing wheel metadata ... \u001b[?25l\u001b[?25hdone\n",
2021-08-25 11:45:47 +08:00
"Requirement already satisfied: lmdb in /usr/local/lib/python3.7/dist-packages (from -r requirements/runtime.txt (line 3)) (0.99)\n",
"Requirement already satisfied: matplotlib in /usr/local/lib/python3.7/dist-packages (from -r requirements/runtime.txt (line 4)) (3.2.2)\n",
"Requirement already satisfied: numba>=0.45.1 in /usr/local/lib/python3.7/dist-packages (from -r requirements/runtime.txt (line 5)) (0.51.2)\n",
2022-03-21 19:38:35 +08:00
"Collecting opencv-python-headless<=4.5.4.60\n",
" Downloading opencv_python_headless-4.5.4.60-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (47.6 MB)\n",
"\u001b[K |████████████████████████████████| 47.6 MB 2.2 MB/s \n",
"\u001b[?25hCollecting pycocotools<=2.0.2\n",
" Downloading pycocotools-2.0.2.tar.gz (23 kB)\n",
"Collecting rapidfuzz\n",
" Downloading rapidfuzz-2.0.7-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB)\n",
"\u001b[K |████████████████████████████████| 1.6 MB 38.8 MB/s \n",
"\u001b[?25hRequirement already satisfied: scikit-image in /usr/local/lib/python3.7/dist-packages (from -r requirements/runtime.txt (line 11)) (0.18.3)\n",
"Requirement already satisfied: six in /usr/local/lib/python3.7/dist-packages (from -r requirements/runtime.txt (line 12)) (1.15.0)\n",
"Requirement already satisfied: terminaltables in /usr/local/lib/python3.7/dist-packages (from -r requirements/runtime.txt (line 13)) (3.1.10)\n",
"Collecting asynctest\n",
" Downloading asynctest-0.13.0-py3-none-any.whl (26 kB)\n",
"Collecting codecov\n",
" Downloading codecov-2.1.12-py2.py3-none-any.whl (16 kB)\n",
"Collecting flake8\n",
" Downloading flake8-4.0.1-py2.py3-none-any.whl (64 kB)\n",
"\u001b[K |████████████████████████████████| 64 kB 2.6 MB/s \n",
"\u001b[?25hCollecting isort\n",
" Downloading isort-5.10.1-py3-none-any.whl (103 kB)\n",
"\u001b[K |████████████████████████████████| 103 kB 45.2 MB/s \n",
"\u001b[?25hCollecting kwarray\n",
" Downloading kwarray-0.6.0-py3-none-any.whl (78 kB)\n",
"\u001b[K |████████████████████████████████| 78 kB 7.4 MB/s \n",
"\u001b[?25hRequirement already satisfied: pytest in /usr/local/lib/python3.7/dist-packages (from -r requirements/tests.txt (line 7)) (3.6.4)\n",
"Collecting pytest-cov\n",
" Downloading pytest_cov-3.0.0-py3-none-any.whl (20 kB)\n",
"Collecting pytest-runner\n",
" Downloading pytest_runner-6.0.0-py3-none-any.whl (7.2 kB)\n",
"Collecting ubelt\n",
" Downloading ubelt-1.0.1-py3-none-any.whl (151 kB)\n",
"\u001b[K |████████████████████████████████| 151 kB 36.4 MB/s \n",
"\u001b[?25hCollecting xdoctest>=0.10.0\n",
" Downloading xdoctest-0.15.10-py3-none-any.whl (116 kB)\n",
"\u001b[K |████████████████████████████████| 116 kB 27.1 MB/s \n",
"\u001b[?25hRequirement already satisfied: yapf in /usr/local/lib/python3.7/dist-packages (from -r requirements/tests.txt (line 12)) (0.32.0)\n",
"Requirement already satisfied: typing-extensions in /usr/local/lib/python3.7/dist-packages (from torch>=1.1->-r requirements/build.txt (line 4)) (3.10.0.2)\n",
"Requirement already satisfied: PyYAML in /usr/local/lib/python3.7/dist-packages (from albumentations>=1.1.0->-r requirements/optional.txt (line 1)) (3.13)\n",
"Requirement already satisfied: scipy in /usr/local/lib/python3.7/dist-packages (from albumentations>=1.1.0->-r requirements/optional.txt (line 1)) (1.4.1)\n",
"Collecting qudida>=0.0.4\n",
" Downloading qudida-0.0.4-py3-none-any.whl (3.5 kB)\n",
2021-08-25 11:45:47 +08:00
"Requirement already satisfied: setuptools in /usr/local/lib/python3.7/dist-packages (from numba>=0.45.1->-r requirements/runtime.txt (line 5)) (57.4.0)\n",
"Requirement already satisfied: llvmlite<0.35,>=0.34.0.dev0 in /usr/local/lib/python3.7/dist-packages (from numba>=0.45.1->-r requirements/runtime.txt (line 5)) (0.34.0)\n",
2022-03-21 19:38:35 +08:00
"Requirement already satisfied: cython>=0.27.3 in /usr/local/lib/python3.7/dist-packages (from pycocotools<=2.0.2->-r requirements/runtime.txt (line 9)) (0.29.28)\n",
"Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->-r requirements/runtime.txt (line 4)) (1.3.2)\n",
"Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.7/dist-packages (from matplotlib->-r requirements/runtime.txt (line 4)) (0.11.0)\n",
2021-08-25 11:45:47 +08:00
"Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->-r requirements/runtime.txt (line 4)) (2.8.2)\n",
2022-03-21 19:38:35 +08:00
"Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->-r requirements/runtime.txt (line 4)) (3.0.7)\n",
"Requirement already satisfied: PyWavelets>=1.1.1 in /usr/local/lib/python3.7/dist-packages (from scikit-image->-r requirements/runtime.txt (line 11)) (1.2.0)\n",
"Requirement already satisfied: networkx>=2.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image->-r requirements/runtime.txt (line 11)) (2.6.3)\n",
"Requirement already satisfied: pillow!=7.1.0,!=7.1.1,>=4.3.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image->-r requirements/runtime.txt (line 11)) (7.1.2)\n",
"Requirement already satisfied: tifffile>=2019.7.26 in /usr/local/lib/python3.7/dist-packages (from scikit-image->-r requirements/runtime.txt (line 11)) (2021.11.2)\n",
"Requirement already satisfied: imageio>=2.3.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image->-r requirements/runtime.txt (line 11)) (2.4.1)\n",
"Requirement already satisfied: scikit-learn>=0.19.1 in /usr/local/lib/python3.7/dist-packages (from qudida>=0.0.4->albumentations>=1.1.0->-r requirements/optional.txt (line 1)) (1.0.2)\n",
"Requirement already satisfied: joblib>=0.11 in /usr/local/lib/python3.7/dist-packages (from scikit-learn>=0.19.1->qudida>=0.0.4->albumentations>=1.1.0->-r requirements/optional.txt (line 1)) (1.1.0)\n",
"Requirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/lib/python3.7/dist-packages (from scikit-learn>=0.19.1->qudida>=0.0.4->albumentations>=1.1.0->-r requirements/optional.txt (line 1)) (3.1.0)\n",
"Requirement already satisfied: opencv-python in /usr/local/lib/python3.7/dist-packages (from imgaug->-r requirements/runtime.txt (line 1)) (4.1.2.30)\n",
"Requirement already satisfied: Shapely in /usr/local/lib/python3.7/dist-packages (from imgaug->-r requirements/runtime.txt (line 1)) (1.8.1.post1)\n",
"Collecting jarowinkler<1.1.0,>=1.0.2\n",
" Downloading jarowinkler-1.0.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (103 kB)\n",
"\u001b[K |████████████████████████████████| 103 kB 14.3 MB/s \n",
"\u001b[?25hRequirement already satisfied: coverage in /usr/local/lib/python3.7/dist-packages (from codecov->-r requirements/tests.txt (line 2)) (3.7.1)\n",
2021-08-25 11:45:47 +08:00
"Requirement already satisfied: requests>=2.7.9 in /usr/local/lib/python3.7/dist-packages (from codecov->-r requirements/tests.txt (line 2)) (2.23.0)\n",
2022-03-21 19:38:35 +08:00
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/dist-packages (from requests>=2.7.9->codecov->-r requirements/tests.txt (line 2)) (2021.10.8)\n",
2021-08-25 11:45:47 +08:00
"Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/dist-packages (from requests>=2.7.9->codecov->-r requirements/tests.txt (line 2)) (1.24.3)\n",
"Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.7/dist-packages (from requests>=2.7.9->codecov->-r requirements/tests.txt (line 2)) (3.0.4)\n",
2022-03-21 19:38:35 +08:00
"Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.7/dist-packages (from requests>=2.7.9->codecov->-r requirements/tests.txt (line 2)) (2.10)\n",
"Collecting importlib-metadata<4.3\n",
" Downloading importlib_metadata-4.2.0-py3-none-any.whl (16 kB)\n",
"Collecting mccabe<0.7.0,>=0.6.0\n",
" Downloading mccabe-0.6.1-py2.py3-none-any.whl (8.6 kB)\n",
"Collecting pyflakes<2.5.0,>=2.4.0\n",
" Downloading pyflakes-2.4.0-py2.py3-none-any.whl (69 kB)\n",
"\u001b[K |████████████████████████████████| 69 kB 7.6 MB/s \n",
"\u001b[?25hCollecting pycodestyle<2.9.0,>=2.8.0\n",
" Downloading pycodestyle-2.8.0-py2.py3-none-any.whl (42 kB)\n",
"\u001b[K |████████████████████████████████| 42 kB 860 kB/s \n",
"\u001b[?25hRequirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.7/dist-packages (from importlib-metadata<4.3->flake8->-r requirements/tests.txt (line 3)) (3.7.0)\n",
"Requirement already satisfied: more-itertools>=4.0.0 in /usr/local/lib/python3.7/dist-packages (from pytest->-r requirements/tests.txt (line 7)) (8.12.0)\n",
"Requirement already satisfied: atomicwrites>=1.0 in /usr/local/lib/python3.7/dist-packages (from pytest->-r requirements/tests.txt (line 7)) (1.4.0)\n",
"Requirement already satisfied: attrs>=17.4.0 in /usr/local/lib/python3.7/dist-packages (from pytest->-r requirements/tests.txt (line 7)) (21.4.0)\n",
"Requirement already satisfied: pluggy<0.8,>=0.5 in /usr/local/lib/python3.7/dist-packages (from pytest->-r requirements/tests.txt (line 7)) (0.7.1)\n",
"Requirement already satisfied: py>=1.5.0 in /usr/local/lib/python3.7/dist-packages (from pytest->-r requirements/tests.txt (line 7)) (1.11.0)\n",
"Collecting pytest\n",
" Downloading pytest-7.1.1-py3-none-any.whl (297 kB)\n",
"\u001b[K |████████████████████████████████| 297 kB 51.4 MB/s \n",
"\u001b[?25hCollecting coverage[toml]>=5.2.1\n",
" Downloading coverage-6.3.2-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (207 kB)\n",
"\u001b[K |████████████████████████████████| 207 kB 48.1 MB/s \n",
"\u001b[?25hRequirement already satisfied: packaging in /usr/local/lib/python3.7/dist-packages (from pytest->-r requirements/tests.txt (line 7)) (21.3)\n",
"Requirement already satisfied: tomli>=1.0.0 in /usr/local/lib/python3.7/dist-packages (from pytest->-r requirements/tests.txt (line 7)) (2.0.1)\n",
"Requirement already satisfied: iniconfig in /usr/local/lib/python3.7/dist-packages (from pytest->-r requirements/tests.txt (line 7)) (1.1.1)\n",
"Collecting pytest\n",
" Downloading pytest-7.1.0-py3-none-any.whl (297 kB)\n",
"\u001b[K |████████████████████████████████| 297 kB 32.1 MB/s \n",
"\u001b[?25h Downloading pytest-7.0.1-py3-none-any.whl (296 kB)\n",
"\u001b[K |████████████████████████████████| 296 kB 51.9 MB/s \n",
"\u001b[?25h Downloading pytest-7.0.0-py3-none-any.whl (296 kB)\n",
"\u001b[K |████████████████████████████████| 296 kB 51.2 MB/s \n",
"\u001b[?25h Downloading pytest-6.2.5-py3-none-any.whl (280 kB)\n",
"\u001b[K |████████████████████████████████| 280 kB 50.5 MB/s \n",
"\u001b[?25hCollecting toml\n",
" Downloading toml-0.10.2-py2.py3-none-any.whl (16 kB)\n",
"Collecting pytest\n",
" Downloading pytest-6.2.4-py3-none-any.whl (280 kB)\n",
"\u001b[K |████████████████████████████████| 280 kB 50.2 MB/s \n",
"\u001b[?25h Downloading pytest-6.2.3-py3-none-any.whl (280 kB)\n",
"\u001b[K |████████████████████████████████| 280 kB 52.3 MB/s \n",
"\u001b[?25h Downloading pytest-6.2.2-py3-none-any.whl (280 kB)\n",
"\u001b[K |████████████████████████████████| 280 kB 33.3 MB/s \n",
"\u001b[?25h Downloading pytest-6.2.1-py3-none-any.whl (279 kB)\n",
"\u001b[K |████████████████████████████████| 279 kB 55.5 MB/s \n",
"\u001b[?25h Downloading pytest-6.2.0-py3-none-any.whl (279 kB)\n",
"\u001b[K |████████████████████████████████| 279 kB 49.7 MB/s \n",
"\u001b[?25h Downloading pytest-6.1.2-py3-none-any.whl (272 kB)\n",
"\u001b[K |████████████████████████████████| 272 kB 52.8 MB/s \n",
"\u001b[?25h Downloading pytest-6.1.1-py3-none-any.whl (272 kB)\n",
"\u001b[K |████████████████████████████████| 272 kB 56.1 MB/s \n",
"\u001b[?25h Downloading pytest-6.1.0-py3-none-any.whl (272 kB)\n",
"\u001b[K |████████████████████████████████| 272 kB 46.7 MB/s \n",
"\u001b[?25h Downloading pytest-6.0.2-py3-none-any.whl (270 kB)\n",
"\u001b[K |████████████████████████████████| 270 kB 50.1 MB/s \n",
"\u001b[?25h Downloading pytest-6.0.1-py3-none-any.whl (270 kB)\n",
"\u001b[K |████████████████████████████████| 270 kB 48.2 MB/s \n",
"\u001b[?25h Downloading pytest-6.0.0-py3-none-any.whl (270 kB)\n",
"\u001b[K |████████████████████████████████| 270 kB 48.1 MB/s \n",
"\u001b[?25h Downloading pytest-5.4.3-py3-none-any.whl (248 kB)\n",
"\u001b[K |████████████████████████████████| 248 kB 39.4 MB/s \n",
"\u001b[?25h Downloading pytest-5.4.2-py3-none-any.whl (247 kB)\n",
"\u001b[K |████████████████████████████████| 247 kB 50.6 MB/s \n",
"\u001b[?25h Downloading pytest-5.4.1-py3-none-any.whl (246 kB)\n",
"\u001b[K |████████████████████████████████| 246 kB 49.3 MB/s \n",
"\u001b[?25h Downloading pytest-5.4.0-py3-none-any.whl (247 kB)\n",
"\u001b[K |████████████████████████████████| 247 kB 53.6 MB/s \n",
"\u001b[?25h Downloading pytest-5.3.5-py3-none-any.whl (235 kB)\n",
"\u001b[K |████████████████████████████████| 235 kB 48.2 MB/s \n",
"\u001b[?25h Downloading pytest-5.3.4-py3-none-any.whl (235 kB)\n",
"\u001b[K |████████████████████████████████| 235 kB 45.6 MB/s \n",
"\u001b[?25h Downloading pytest-5.3.3-py3-none-any.whl (235 kB)\n",
"\u001b[K |████████████████████████████████| 235 kB 48.5 MB/s \n",
"\u001b[?25h Downloading pytest-5.3.2-py3-none-any.whl (234 kB)\n",
"\u001b[K |████████████████████████████████| 234 kB 49.2 MB/s \n",
"\u001b[?25h Downloading pytest-5.3.1-py3-none-any.whl (233 kB)\n",
"\u001b[K |████████████████████████████████| 233 kB 44.0 MB/s \n",
"\u001b[?25h Downloading pytest-5.3.0-py3-none-any.whl (233 kB)\n",
"\u001b[K |████████████████████████████████| 233 kB 52.1 MB/s \n",
"\u001b[?25h Downloading pytest-5.2.4-py3-none-any.whl (227 kB)\n",
"\u001b[K |████████████████████████████████| 227 kB 51.8 MB/s \n",
"\u001b[?25h Downloading pytest-5.2.3-py3-none-any.whl (227 kB)\n",
"\u001b[K |████████████████████████████████| 227 kB 40.6 MB/s \n",
"\u001b[?25h Downloading pytest-5.2.2-py3-none-any.whl (227 kB)\n",
"\u001b[K |████████████████████████████████| 227 kB 46.4 MB/s \n",
"\u001b[?25h Downloading pytest-5.2.1-py3-none-any.whl (226 kB)\n",
"\u001b[K |████████████████████████████████| 226 kB 52.0 MB/s \n",
"\u001b[?25h Downloading pytest-5.2.0-py3-none-any.whl (226 kB)\n",
"\u001b[K |████████████████████████████████| 226 kB 52.4 MB/s \n",
"\u001b[?25h Downloading pytest-5.1.3-py3-none-any.whl (224 kB)\n",
"\u001b[K |████████████████████████████████| 224 kB 46.2 MB/s \n",
"\u001b[?25h Downloading pytest-5.1.2-py3-none-any.whl (224 kB)\n",
"\u001b[K |████████████████████████████████| 224 kB 51.8 MB/s \n",
"\u001b[?25h Downloading pytest-5.1.1-py3-none-any.whl (223 kB)\n",
"\u001b[K |████████████████████████████████| 223 kB 39.0 MB/s \n",
"\u001b[?25h Downloading pytest-5.1.0-py3-none-any.whl (223 kB)\n",
"\u001b[K |████████████████████████████████| 223 kB 55.1 MB/s \n",
"\u001b[?25h Downloading pytest-5.0.1-py3-none-any.whl (221 kB)\n",
"\u001b[K |████████████████████████████████| 221 kB 51.1 MB/s \n",
"\u001b[?25h Downloading pytest-5.0.0-py3-none-any.whl (221 kB)\n",
"\u001b[K |████████████████████████████████| 221 kB 49.6 MB/s \n",
"\u001b[?25h Downloading pytest-4.6.11-py2.py3-none-any.whl (231 kB)\n",
"\u001b[K |████████████████████████████████| 231 kB 53.4 MB/s \n",
"\u001b[?25h Downloading pytest-4.6.10-py2.py3-none-any.whl (231 kB)\n",
"\u001b[K |████████████████████████████████| 231 kB 50.6 MB/s \n",
"\u001b[?25h Downloading pytest-4.6.9-py2.py3-none-any.whl (231 kB)\n",
"\u001b[K |████████████████████████████████| 231 kB 40.0 MB/s \n",
"\u001b[?25h Downloading pytest-4.6.8-py2.py3-none-any.whl (230 kB)\n",
"\u001b[K |████████████████████████████████| 230 kB 54.2 MB/s \n",
"\u001b[?25h Downloading pytest-4.6.7-py2.py3-none-any.whl (230 kB)\n",
"\u001b[K |████████████████████████████████| 230 kB 51.7 MB/s \n",
"\u001b[?25h Downloading pytest-4.6.6-py2.py3-none-any.whl (230 kB)\n",
"\u001b[K |████████████████████████████████| 230 kB 52.7 MB/s \n",
"\u001b[?25h Downloading pytest-4.6.5-py2.py3-none-any.whl (230 kB)\n",
"\u001b[K |████████████████████████████████| 230 kB 47.7 MB/s \n",
"\u001b[?25h Downloading pytest-4.6.4-py2.py3-none-any.whl (229 kB)\n",
"\u001b[K |████████████████████████████████| 229 kB 48.9 MB/s \n",
"\u001b[?25h Downloading pytest-4.6.3-py2.py3-none-any.whl (229 kB)\n",
"\u001b[K |████████████████████████████████| 229 kB 54.7 MB/s \n",
"\u001b[?25h Downloading pytest-4.6.2-py2.py3-none-any.whl (229 kB)\n",
"\u001b[K |████████████████████████████████| 229 kB 50.2 MB/s \n",
"\u001b[?25h Downloading pytest-4.6.1-py2.py3-none-any.whl (229 kB)\n",
"\u001b[K |████████████████████████████████| 229 kB 51.7 MB/s \n",
"\u001b[?25h Downloading pytest-4.6.0-py2.py3-none-any.whl (229 kB)\n",
"\u001b[K |████████████████████████████████| 229 kB 52.2 MB/s \n",
"\u001b[?25hINFO: pip is looking at multiple versions of pytest-cov to determine which version is compatible with other requirements. This could take a while.\n",
"Collecting pytest-cov\n",
" Downloading pytest_cov-2.12.1-py2.py3-none-any.whl (20 kB)\n",
" Downloading pytest_cov-2.12.0-py2.py3-none-any.whl (20 kB)\n",
" Downloading pytest_cov-2.11.1-py2.py3-none-any.whl (20 kB)\n",
" Downloading pytest_cov-2.11.0-py2.py3-none-any.whl (20 kB)\n",
" Downloading pytest_cov-2.10.1-py2.py3-none-any.whl (19 kB)\n",
" Downloading pytest_cov-2.10.0-py2.py3-none-any.whl (19 kB)\n",
" Downloading pytest_cov-2.9.0-py2.py3-none-any.whl (19 kB)\n",
"Collecting ordered-set\n",
" Downloading ordered_set-4.1.0-py3-none-any.whl (7.6 kB)\n",
"Building wheels for collected packages: lanms-neo, pycocotools\n",
" Building wheel for lanms-neo (PEP 517) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for lanms-neo: filename=lanms_neo-1.0.2-cp37-cp37m-linux_x86_64.whl size=107259 sha256=3e542a5f84605022e07797cdf0f3920886b8691eb51761e88efb22698aeafa1a\n",
" Stored in directory: /root/.cache/pip/wheels/09/7b/5e/1e4d24a8f94c1116afa284ce2968ef2f72b986a5457164b340\n",
" Building wheel for pycocotools (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for pycocotools: filename=pycocotools-2.0.2-cp37-cp37m-linux_x86_64.whl size=264430 sha256=07b5f1105f875f05483590366fdf06fcecbf6b6f2ca974d8fd53dea538a3b979\n",
" Stored in directory: /root/.cache/pip/wheels/bc/cf/1b/e95c99c5f9d1648be3f500ca55e7ce55f24818b0f48336adaf\n",
"Successfully built lanms-neo pycocotools\n",
"Installing collected packages: ordered-set, opencv-python-headless, ubelt, qudida, pyflakes, pycodestyle, mccabe, jarowinkler, importlib-metadata, coverage, xdoctest, rapidfuzz, pytest-runner, pytest-cov, pycocotools, pyclipper, lanms-neo, kwarray, isort, flake8, codecov, asynctest, albumentations\n",
" Attempting uninstall: importlib-metadata\n",
" Found existing installation: importlib-metadata 4.11.2\n",
" Uninstalling importlib-metadata-4.11.2:\n",
" Successfully uninstalled importlib-metadata-4.11.2\n",
" Attempting uninstall: coverage\n",
" Found existing installation: coverage 3.7.1\n",
" Uninstalling coverage-3.7.1:\n",
" Successfully uninstalled coverage-3.7.1\n",
" Attempting uninstall: pycocotools\n",
" Found existing installation: pycocotools 2.0.4\n",
" Uninstalling pycocotools-2.0.4:\n",
" Successfully uninstalled pycocotools-2.0.4\n",
" Attempting uninstall: albumentations\n",
" Found existing installation: albumentations 0.1.12\n",
" Uninstalling albumentations-0.1.12:\n",
" Successfully uninstalled albumentations-0.1.12\n",
"\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n",
"markdown 3.3.6 requires importlib-metadata>=4.4; python_version < \"3.10\", but you have importlib-metadata 4.2.0 which is incompatible.\n",
"datascience 0.10.6 requires coverage==3.7.1, but you have coverage 6.3.2 which is incompatible.\n",
"datascience 0.10.6 requires folium==0.2.1, but you have folium 0.8.3 which is incompatible.\n",
"coveralls 0.5 requires coverage<3.999,>=3.6, but you have coverage 6.3.2 which is incompatible.\u001b[0m\n",
"Successfully installed albumentations-1.1.0 asynctest-0.13.0 codecov-2.1.12 coverage-6.3.2 flake8-4.0.1 importlib-metadata-4.2.0 isort-5.10.1 jarowinkler-1.0.2 kwarray-0.6.0 lanms-neo-1.0.2 mccabe-0.6.1 opencv-python-headless-4.5.4.60 ordered-set-4.1.0 pyclipper-1.3.0.post2 pycocotools-2.0.2 pycodestyle-2.8.0 pyflakes-2.4.0 pytest-cov-2.9.0 pytest-runner-6.0.0 qudida-0.0.4 rapidfuzz-2.0.7 ubelt-1.0.1 xdoctest-0.15.10\n",
2021-08-25 11:45:47 +08:00
"Using pip 21.1.3 from /usr/local/lib/python3.7/dist-packages/pip (python 3.7)\n",
"Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/9617>\n",
"distutils: /usr/local/lib/python3.7/dist-packages\n",
"sysconfig: /usr/lib/python3.7/site-packages\n",
"Value for scheme.purelib does not match. Please report this to <https://github.com/pypa/pip/issues/9617>\n",
"distutils: /usr/local/lib/python3.7/dist-packages\n",
"sysconfig: /usr/lib/python3.7/site-packages\n",
"Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/9617>\n",
"distutils: /usr/local/include/python3.7/UNKNOWN\n",
"sysconfig: /usr/include/python3.7m/UNKNOWN\n",
"Value for scheme.scripts does not match. Please report this to <https://github.com/pypa/pip/issues/9617>\n",
"distutils: /usr/local/bin\n",
"sysconfig: /usr/bin\n",
"Value for scheme.data does not match. Please report this to <https://github.com/pypa/pip/issues/9617>\n",
"distutils: /usr/local\n",
"sysconfig: /usr\n",
"Additional context:\n",
"user = False\n",
"home = None\n",
"root = None\n",
"prefix = None\n",
2021-05-18 11:13:07 +08:00
"Non-user install because site-packages writeable\n",
2022-03-21 19:38:35 +08:00
"Created temporary directory: /tmp/pip-ephem-wheel-cache-m7z_fdwx\n",
"Created temporary directory: /tmp/pip-req-tracker-3hnmi5sj\n",
"Initialized build tracking at /tmp/pip-req-tracker-3hnmi5sj\n",
"Created build tracker: /tmp/pip-req-tracker-3hnmi5sj\n",
"Entered build tracker: /tmp/pip-req-tracker-3hnmi5sj\n",
"Created temporary directory: /tmp/pip-install-b370etpc\n",
2021-08-25 11:45:47 +08:00
"Obtaining file:///mmocr\n",
2022-03-21 19:38:35 +08:00
" Added file:///mmocr to build tracker '/tmp/pip-req-tracker-3hnmi5sj'\n",
2021-08-25 11:45:47 +08:00
" Running setup.py (path:/mmocr/setup.py) egg_info for package from file:///mmocr\n",
2022-03-21 19:38:35 +08:00
" Created temporary directory: /tmp/pip-pip-egg-info-3wcoj0vo\n",
2021-05-18 11:13:07 +08:00
" Running command python setup.py egg_info\n",
" running egg_info\n",
2022-03-21 19:38:35 +08:00
" creating /tmp/pip-pip-egg-info-3wcoj0vo/mmocr.egg-info\n",
" writing /tmp/pip-pip-egg-info-3wcoj0vo/mmocr.egg-info/PKG-INFO\n",
" writing dependency_links to /tmp/pip-pip-egg-info-3wcoj0vo/mmocr.egg-info/dependency_links.txt\n",
" writing requirements to /tmp/pip-pip-egg-info-3wcoj0vo/mmocr.egg-info/requires.txt\n",
" writing top-level names to /tmp/pip-pip-egg-info-3wcoj0vo/mmocr.egg-info/top_level.txt\n",
" writing manifest file '/tmp/pip-pip-egg-info-3wcoj0vo/mmocr.egg-info/SOURCES.txt'\n",
2021-05-18 11:13:07 +08:00
" reading manifest template 'MANIFEST.in'\n",
2022-03-21 19:38:35 +08:00
" warning: no files found matching 'mmocr/.mim/model-index.yml'\n",
" warning: no files found matching '*.py' under directory 'mmocr/.mim/configs'\n",
" warning: no files found matching '*.yml' under directory 'mmocr/.mim/configs'\n",
" warning: no files found matching '*.sh' under directory 'mmocr/.mim/tools'\n",
" warning: no files found matching '*.py' under directory 'mmocr/.mim/tools'\n",
2021-08-25 11:45:47 +08:00
" adding license file 'LICENSE'\n",
2022-03-21 19:38:35 +08:00
" writing manifest file '/tmp/pip-pip-egg-info-3wcoj0vo/mmocr.egg-info/SOURCES.txt'\n",
" Source in /mmocr has version 0.4.1, which satisfies requirement mmocr==0.4.1 from file:///mmocr\n",
" Removed mmocr==0.4.1 from file:///mmocr from build tracker '/tmp/pip-req-tracker-3hnmi5sj'\n",
"Requirement already satisfied: imgaug in /usr/local/lib/python3.7/dist-packages (from mmocr==0.4.1) (0.2.9)\n",
"Requirement already satisfied: lanms-neo==1.0.2 in /usr/local/lib/python3.7/dist-packages (from mmocr==0.4.1) (1.0.2)\n",
"Requirement already satisfied: lmdb in /usr/local/lib/python3.7/dist-packages (from mmocr==0.4.1) (0.99)\n",
"Requirement already satisfied: matplotlib in /usr/local/lib/python3.7/dist-packages (from mmocr==0.4.1) (3.2.2)\n",
"Requirement already satisfied: numba>=0.45.1 in /usr/local/lib/python3.7/dist-packages (from mmocr==0.4.1) (0.51.2)\n",
"Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from mmocr==0.4.1) (1.21.5)\n",
"Requirement already satisfied: opencv-python-headless<=4.5.4.60 in /usr/local/lib/python3.7/dist-packages (from mmocr==0.4.1) (4.5.4.60)\n",
"Requirement already satisfied: pyclipper in /usr/local/lib/python3.7/dist-packages (from mmocr==0.4.1) (1.3.0.post2)\n",
"Requirement already satisfied: pycocotools<=2.0.2 in /usr/local/lib/python3.7/dist-packages (from mmocr==0.4.1) (2.0.2)\n",
"Requirement already satisfied: rapidfuzz in /usr/local/lib/python3.7/dist-packages (from mmocr==0.4.1) (2.0.7)\n",
"Requirement already satisfied: scikit-image in /usr/local/lib/python3.7/dist-packages (from mmocr==0.4.1) (0.18.3)\n",
"Requirement already satisfied: six in /usr/local/lib/python3.7/dist-packages (from mmocr==0.4.1) (1.15.0)\n",
"Requirement already satisfied: terminaltables in /usr/local/lib/python3.7/dist-packages (from mmocr==0.4.1) (3.1.10)\n",
"Requirement already satisfied: llvmlite<0.35,>=0.34.0.dev0 in /usr/local/lib/python3.7/dist-packages (from numba>=0.45.1->mmocr==0.4.1) (0.34.0)\n",
"Requirement already satisfied: setuptools in /usr/local/lib/python3.7/dist-packages (from numba>=0.45.1->mmocr==0.4.1) (57.4.0)\n",
"Requirement already satisfied: cython>=0.27.3 in /usr/local/lib/python3.7/dist-packages (from pycocotools<=2.0.2->mmocr==0.4.1) (0.29.28)\n",
"Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->mmocr==0.4.1) (1.3.2)\n",
"Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.7/dist-packages (from matplotlib->mmocr==0.4.1) (0.11.0)\n",
"Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->mmocr==0.4.1) (2.8.2)\n",
"Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib->mmocr==0.4.1) (3.0.7)\n",
"Requirement already satisfied: imageio in /usr/local/lib/python3.7/dist-packages (from imgaug->mmocr==0.4.1) (2.4.1)\n",
"Requirement already satisfied: Pillow in /usr/local/lib/python3.7/dist-packages (from imgaug->mmocr==0.4.1) (7.1.2)\n",
"Requirement already satisfied: opencv-python in /usr/local/lib/python3.7/dist-packages (from imgaug->mmocr==0.4.1) (4.1.2.30)\n",
"Requirement already satisfied: scipy in /usr/local/lib/python3.7/dist-packages (from imgaug->mmocr==0.4.1) (1.4.1)\n",
"Requirement already satisfied: Shapely in /usr/local/lib/python3.7/dist-packages (from imgaug->mmocr==0.4.1) (1.8.1.post1)\n",
"Requirement already satisfied: PyWavelets>=1.1.1 in /usr/local/lib/python3.7/dist-packages (from scikit-image->mmocr==0.4.1) (1.2.0)\n",
"Requirement already satisfied: tifffile>=2019.7.26 in /usr/local/lib/python3.7/dist-packages (from scikit-image->mmocr==0.4.1) (2021.11.2)\n",
"Requirement already satisfied: networkx>=2.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image->mmocr==0.4.1) (2.6.3)\n",
"Requirement already satisfied: jarowinkler<1.1.0,>=1.0.2 in /usr/local/lib/python3.7/dist-packages (from rapidfuzz->mmocr==0.4.1) (1.0.2)\n",
"Created temporary directory: /tmp/pip-unpack-iha62low\n",
2021-05-18 11:13:07 +08:00
"Installing collected packages: mmocr\n",
2021-08-25 11:45:47 +08:00
" Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/9617>\n",
" distutils: /usr/local/lib/python3.7/dist-packages\n",
" sysconfig: /usr/lib/python3.7/site-packages\n",
" Value for scheme.purelib does not match. Please report this to <https://github.com/pypa/pip/issues/9617>\n",
" distutils: /usr/local/lib/python3.7/dist-packages\n",
" sysconfig: /usr/lib/python3.7/site-packages\n",
" Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/9617>\n",
" distutils: /usr/local/include/python3.7/mmocr\n",
" sysconfig: /usr/include/python3.7m/mmocr\n",
" Value for scheme.scripts does not match. Please report this to <https://github.com/pypa/pip/issues/9617>\n",
" distutils: /usr/local/bin\n",
" sysconfig: /usr/bin\n",
" Value for scheme.data does not match. Please report this to <https://github.com/pypa/pip/issues/9617>\n",
" distutils: /usr/local\n",
" sysconfig: /usr\n",
" Additional context:\n",
" user = False\n",
" home = None\n",
" root = None\n",
" prefix = None\n",
2021-05-18 11:13:07 +08:00
" Running setup.py develop for mmocr\n",
2021-08-25 11:45:47 +08:00
" Running command /usr/bin/python3 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '\"'\"'/mmocr/setup.py'\"'\"'; __file__='\"'\"'/mmocr/setup.py'\"'\"';f = getattr(tokenize, '\"'\"'open'\"'\"', open)(__file__) if os.path.exists(__file__) else io.StringIO('\"'\"'from setuptools import setup; setup()'\"'\"');code = f.read().replace('\"'\"'\\r\\n'\"'\"', '\"'\"'\\n'\"'\"');f.close();exec(compile(code, __file__, '\"'\"'exec'\"'\"'))' develop --no-deps\n",
2021-05-18 11:13:07 +08:00
" running develop\n",
" running egg_info\n",
2022-03-21 19:38:35 +08:00
" creating mmocr.egg-info\n",
2021-05-18 11:13:07 +08:00
" writing mmocr.egg-info/PKG-INFO\n",
" writing dependency_links to mmocr.egg-info/dependency_links.txt\n",
" writing requirements to mmocr.egg-info/requires.txt\n",
" writing top-level names to mmocr.egg-info/top_level.txt\n",
2022-03-21 19:38:35 +08:00
" writing manifest file 'mmocr.egg-info/SOURCES.txt'\n",
2021-05-18 11:13:07 +08:00
" reading manifest template 'MANIFEST.in'\n",
2021-08-25 11:45:47 +08:00
" adding license file 'LICENSE'\n",
2021-05-18 11:13:07 +08:00
" writing manifest file 'mmocr.egg-info/SOURCES.txt'\n",
" running build_ext\n",
2021-08-25 11:45:47 +08:00
" Creating /usr/local/lib/python3.7/dist-packages/mmocr.egg-link (link to .)\n",
2022-03-21 19:38:35 +08:00
" Adding mmocr 0.4.1 to easy-install.pth file\n",
2021-05-18 11:13:07 +08:00
"\n",
2021-08-25 11:45:47 +08:00
" Installed /mmocr\n",
"Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/9617>\n",
"distutils: /usr/local/lib/python3.7/dist-packages\n",
"sysconfig: /usr/lib/python3.7/site-packages\n",
"Value for scheme.purelib does not match. Please report this to <https://github.com/pypa/pip/issues/9617>\n",
"distutils: /usr/local/lib/python3.7/dist-packages\n",
"sysconfig: /usr/lib/python3.7/site-packages\n",
"Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/9617>\n",
"distutils: /usr/local/include/python3.7/UNKNOWN\n",
"sysconfig: /usr/include/python3.7m/UNKNOWN\n",
"Value for scheme.scripts does not match. Please report this to <https://github.com/pypa/pip/issues/9617>\n",
"distutils: /usr/local/bin\n",
"sysconfig: /usr/bin\n",
"Value for scheme.data does not match. Please report this to <https://github.com/pypa/pip/issues/9617>\n",
"distutils: /usr/local\n",
"sysconfig: /usr\n",
"Additional context:\n",
"user = False\n",
"home = None\n",
"root = None\n",
"prefix = None\n",
2022-03-21 19:38:35 +08:00
"Successfully installed mmocr-0.4.1\n",
"Removed build tracker: '/tmp/pip-req-tracker-3hnmi5sj'\n"
2021-08-25 16:41:07 +08:00
]
2021-05-18 11:13:07 +08:00
}
2021-08-25 16:41:07 +08:00
],
2021-08-25 11:45:47 +08:00
"metadata": {
"colab": {
2022-03-21 19:38:35 +08:00
"base_uri": "https://localhost:8080/"
2021-08-25 16:41:07 +08:00
},
"id": "DwDY3puNNmhe",
"tags": [
"outputPrepend"
],
2022-03-21 19:38:35 +08:00
"outputId": "5058e757-1742-499a-dcda-aa3e800a72a3"
2021-08-25 16:41:07 +08:00
}
2021-08-25 11:45:47 +08:00
},
{
2021-05-18 11:13:07 +08:00
"cell_type": "markdown",
2021-08-25 11:45:47 +08:00
"source": [
"### Check Installed Dependencies Versions"
2021-08-25 16:41:07 +08:00
],
"metadata": {
"id": "DY64JCc0pEUu"
}
2021-05-18 11:13:07 +08:00
},
{
"cell_type": "code",
2022-03-21 19:38:35 +08:00
"execution_count": 5,
2021-05-18 11:13:07 +08:00
"source": [
"# Check Pytorch installation\n",
"import torch, torchvision\n",
"print(torch.__version__, torch.cuda.is_available())\n",
"\n",
"# Check MMDetection installation\n",
"import mmdet\n",
"print(mmdet.__version__)\n",
"\n",
"# Check mmcv installation\n",
"import mmcv\n",
"from mmcv.ops import get_compiling_cuda_version, get_compiler_version\n",
"print(mmcv.__version__)\n",
"print(get_compiling_cuda_version())\n",
"print(get_compiler_version())\n",
"\n",
"# Check mmocr installation\n",
"import mmocr\n",
2021-08-25 11:45:47 +08:00
"print(mmocr.__version__)\n",
"\n",
"%cd /mmocr/\n",
"!ls"
2021-05-18 11:13:07 +08:00
],
"outputs": [
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stdout",
2021-05-18 11:13:07 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"1.10.0+cu111 True\n",
"2.22.0\n",
"1.4.6\n",
"11.1\n",
"GCC 7.3\n",
"0.4.1\n",
2021-08-25 11:45:47 +08:00
"/mmocr\n",
2022-03-21 19:38:35 +08:00
"CITATION.cff docs\t mmocr.egg-info requirements setup.py\n",
"configs LICENSE\t model-index.yml requirements.txt tests\n",
"demo\t MANIFEST.in README.md\t resources\t tools\n",
"docker\t mmocr\t README_zh-CN.md setup.cfg\n"
2021-08-25 16:41:07 +08:00
]
2021-05-18 11:13:07 +08:00
}
2021-08-25 16:41:07 +08:00
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "JABQfPwQN52g",
2022-03-21 19:38:35 +08:00
"outputId": "61fa6153-4128-45b8-f684-fb96d6b557ab"
2021-08-25 16:41:07 +08:00
}
2021-05-18 11:13:07 +08:00
},
{
2021-08-25 11:45:47 +08:00
"cell_type": "markdown",
2021-05-18 11:13:07 +08:00
"source": [
2021-08-25 11:45:47 +08:00
"# Inference\n",
2021-05-18 11:13:07 +08:00
"\n",
2021-08-25 11:45:47 +08:00
"We provide an easy-to-use inference script, `mmocr/utils/ocr.py`, that can be either called through command line or imported as an object (the `MMOCR` class inside). In this notebook, we choose the latter option for ease of demonstration. You can check out its full usage and examples in our [official documentation](https://mmocr.readthedocs.io/en/latest/demo.html)."
2021-08-25 16:41:07 +08:00
],
"metadata": {
"id": "YCLL7zlu5Hm1"
}
2021-08-25 11:45:47 +08:00
},
{
2021-05-18 11:13:07 +08:00
"cell_type": "markdown",
2021-08-25 11:45:47 +08:00
"source": [
"## Perform Inference with a Pretrained Text Recognizer \n",
"\n",
"We now demonstrate how to inference on a [demo text recognition image](https://github.com/open-mmlab/mmocr/raw/main/demo/demo_text_recog.jpg) with a pretrained text recognizer using command line. SAR text recognizer is used for this demo, whose checkpoint can be found in the [official documentation](https://mmocr.readthedocs.io/en/latest/textrecog_models.html#show-attend-and-read-a-simple-and-strong-baseline-for-irregular-text-recognition). But you don't need to download it manually -- Our inference script handles these cumbersome setup steps for you! \n",
"\n",
"Run the following command and the recognition result will be saved to `outputs/demo_text_recog_pred.jpg`. We will visualize the result in the end."
2021-08-25 16:41:07 +08:00
],
"metadata": {
"id": "59gHy8Y4pEUv"
}
2021-05-18 11:13:07 +08:00
},
{
"cell_type": "code",
2022-03-21 19:38:35 +08:00
"execution_count": 6,
2021-08-25 11:45:47 +08:00
"source": [
"from mmocr.utils.ocr import MMOCR\n",
"mmocr = MMOCR(det=None, recog='SAR')\n",
"mmocr.readtext('demo/demo_text_recog.jpg', print_result=True, output='outputs/demo_text_recog_pred.jpg')"
],
2021-05-18 11:13:07 +08:00
"outputs": [
2022-03-21 19:38:35 +08:00
{
"output_type": "stream",
"name": "stderr",
"text": [
"/usr/local/lib/python3.7/dist-packages/mmdet/datasets/pipelines/formating.py:7: UserWarning: DeprecationWarning: mmdet.datasets.pipelines.formating will be deprecated, please replace it with mmdet.datasets.pipelines.formatting.\n",
" warnings.warn('DeprecationWarning: mmdet.datasets.pipelines.formating will be '\n"
]
},
2021-05-18 11:13:07 +08:00
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stdout",
2021-05-18 11:13:07 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"load checkpoint from http path: https://download.openmmlab.com/mmocr/textrecog/sar/sar_r31_parallel_decoder_academic-dba3a4a3.pth\n"
]
},
{
"output_type": "stream",
"name": "stderr",
"text": [
"Downloading: \"https://download.openmmlab.com/mmocr/textrecog/sar/sar_r31_parallel_decoder_academic-dba3a4a3.pth\" to /root/.cache/torch/hub/checkpoints/sar_r31_parallel_decoder_academic-dba3a4a3.pth\n"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
},
2022-03-21 19:38:35 +08:00
{
"output_type": "display_data",
"data": {
"text/plain": [
" 0%| | 0.00/219M [00:00<?, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "9922c33a131f41cfac84af47b5e5981c"
}
},
"metadata": {}
},
2021-08-25 11:45:47 +08:00
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stderr",
2021-08-25 11:45:47 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"/mmocr/mmocr/apis/inference.py:50: UserWarning: Class names are not saved in the checkpoint's meta data, use COCO classes by default.\n",
2021-08-25 11:45:47 +08:00
" warnings.warn('Class names are not saved in the checkpoint\\'s '\n"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
},
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stdout",
2021-08-25 11:45:47 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"{'text': 'STAR', 'score': 0.9664110243320465}\n",
2021-08-25 11:45:47 +08:00
"\n"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
2022-03-21 19:38:35 +08:00
"[{'score': 0.9664110243320465, 'text': 'STAR'}]"
2021-08-25 11:45:47 +08:00
]
},
"metadata": {},
2022-03-21 19:38:35 +08:00
"execution_count": 6
2021-05-18 11:13:07 +08:00
}
2021-08-25 16:41:07 +08:00
],
2021-08-25 11:45:47 +08:00
"metadata": {
"colab": {
2022-03-21 19:38:35 +08:00
"base_uri": "https://localhost:8080/",
"height": 229,
"referenced_widgets": [
"9922c33a131f41cfac84af47b5e5981c",
"9be2b6bd525c4b31be2d386b37d573b6",
"edb36ab14ab44bc98983d447c1cb150a",
"46dafdb514c049a7bb18ada61c7dee49",
"c267e0b248154c028a93390ea187ef7f",
"e2bc0c96bdee4d9c981f71c1001ec637",
"b735ff5dcd114345bc89b462bc276759",
"5ef02d42f1d34f6a81dbbe8b4fbd7ffc",
"1712f2cbff4a4cbdaaa238d89905ec21",
"1e43262b71ef45f1a5535d78594a0235",
"5e7c98e0dbc4463c81b15c56c48ba1cf"
]
2021-08-25 11:45:47 +08:00
},
2021-08-25 16:41:07 +08:00
"id": "iQQIVH9ApEUv",
2022-03-21 19:38:35 +08:00
"outputId": "565fff52-5f8f-4614-df2b-3d3e7f0c166b"
2021-08-25 16:41:07 +08:00
}
},
{
"cell_type": "code",
2022-03-21 19:38:35 +08:00
"execution_count": 7,
2021-08-25 11:45:47 +08:00
"source": [
"# Visualize the results\n",
"import matplotlib.pyplot as plt\n",
"predicted_img = mmcv.imread('./outputs/demo_text_recog_pred.jpg')\n",
"plt.imshow(mmcv.bgr2rgb(predicted_img))\n",
"plt.show()"
2021-05-18 11:13:07 +08:00
],
2021-08-25 11:45:47 +08:00
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
2021-08-25 16:41:07 +08:00
],
2022-03-21 19:38:35 +08:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAKIAAAD7CAYAAADpc08kAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nOy9e9xlR1Xn/V1Ve+9znvPc+pruTjqX7iTkThIIBLwAAXFkwBej6GfED4LyOuO884rjjAgO6EdnZNRRX2+jOHgZdfR9GRQYUYKgoGiUSwhCQhISkpBLJ52+dz+3c9m7ar1/VNXe+5zn6U5CkplH5qz+PH3O2bt27br8atVaq1atElVlSlP6X03mf3UBpjQlmAJxSpuEpkCc0qagKRCntCloCsQpbQqaAnFKm4KeMSCKyDeJyN0icq+IvPWZes+UvjpIngk7oohY4B7g5cAB4BbgO1X1zqf9ZVP6qqDsGcr3+cC9qno/gIi8G3g1sCEQd+zYoRdccMEz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io0cY3FYYRzMeeHwH/531i67lHNe862YmS7kBVe8/BvZc965nPj936M6eRJFMRqe7WDIVMkRCu/oqKPjBKNKZYWBtZwqCoY2oxKL5BYnln5WsJJnrBQ5+179rWy54nJsdwZsUmKiIpCUNI2mFe/IyxGzoxE7K8dwbY35csTR972X1S/exQXf+73YxS2YLMmM0jRtPZfG6VE9eIOpoNsf0fMwKxYvwtAIlbEMjTKyUFnBi4DPajgn1TFzjszDrGp4pyqz5YjMO0Z4+p+6hc+/853s+yffxOL555+295+K1izAbwN3q
2021-08-25 11:45:47 +08:00
},
"metadata": {
"needs_background": "light"
}
}
2021-08-25 16:41:07 +08:00
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 268
},
"id": "0ab_YJnXpEUw",
2022-03-21 19:38:35 +08:00
"outputId": "e514b1c0-25af-4b18-b9a2-686a4a2aa47a"
2021-08-25 16:41:07 +08:00
}
2021-08-25 11:45:47 +08:00
},
{
"cell_type": "markdown",
2021-05-18 11:13:07 +08:00
"source": [
2021-08-25 11:45:47 +08:00
"## Perform Inference with a Pretrained Text Detector \n",
"\n",
"Next, we perform inference with a pretrained TextSnake text detector and visualize the bounding box results for the demo text detection image provided in [demo_text_det.jpg](https://raw.githubusercontent.com/open-mmlab/mmocr/main/demo/demo_text_det.jpg)."
2021-08-25 16:41:07 +08:00
],
"metadata": {
"id": "NgoH6qEcC9CL"
}
2021-05-18 11:13:07 +08:00
},
{
"cell_type": "code",
2022-03-21 19:38:35 +08:00
"execution_count": 8,
2021-08-25 16:41:07 +08:00
"source": [
"from mmocr.utils.ocr import MMOCR\n",
"mmocr = MMOCR(det='TextSnake', recog=None)\n",
"_ = mmocr.readtext('demo/demo_text_det.jpg', output='outputs/demo_text_det_pred.jpg')"
],
2022-03-21 19:38:35 +08:00
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"load checkpoint from http path: https://download.openmmlab.com/mmocr/textdet/textsnake/textsnake_r50_fpn_unet_1200e_ctw1500-27f65b64.pth\n"
]
},
{
"output_type": "stream",
"name": "stderr",
"text": [
"Downloading: \"https://download.openmmlab.com/mmocr/textdet/textsnake/textsnake_r50_fpn_unet_1200e_ctw1500-27f65b64.pth\" to /root/.cache/torch/hub/checkpoints/textsnake_r50_fpn_unet_1200e_ctw1500-27f65b64.pth\n"
]
},
{
"output_type": "display_data",
"data": {
"text/plain": [
" 0%| | 0.00/139M [00:00<?, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "0cfa2ece94314ed186b834646623852a"
}
},
"metadata": {}
},
{
"output_type": "stream",
"name": "stderr",
"text": [
"/usr/local/lib/python3.7/dist-packages/mmdet/datasets/utils.py:70: UserWarning: \"ImageToTensor\" pipeline is replaced by \"DefaultFormatBundle\" for batch inference. It is recommended to manually replace it in the test data pipeline in your config file.\n",
" 'data pipeline in your config file.', UserWarning)\n",
"/mmocr/mmocr/models/textdet/postprocess/utils.py:51: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.\n",
"Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
" canvas = canvas[1:h + 1, 1:w + 1].astype(np.bool)\n"
]
}
],
2021-08-25 11:45:47 +08:00
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
2022-03-21 19:38:35 +08:00
"height": 194,
2021-08-25 11:45:47 +08:00
"referenced_widgets": [
2022-03-21 19:38:35 +08:00
"0cfa2ece94314ed186b834646623852a",
"5f5f9ed460404047bfda112283b4f159",
"7c6bbe29702444b9a6adfef0d11f2a5c",
"b48490fd9f0d4cc38acd6c0ccf57b68a",
"6f6240bf87a3442dbce39764c97dbd8f",
"b3adfe1225ac4497ae818e5a78132c34",
"c36a853d851249c49c63599219f73c38",
"a4d14f12345b4956a7861d5c54a51fad",
"592582312a0c4ddfa40e55026fd51e3f",
"3947416ef2c245d197e7b254d0d513b8",
"dc187713177749469e49eed82769df1c"
2021-08-25 11:45:47 +08:00
]
},
"id": "u0YyG9y0TzL4",
2022-03-21 19:38:35 +08:00
"outputId": "c781af52-61c7-48ca-bf3e-b0fe16819224"
2021-08-25 16:41:07 +08:00
}
2021-08-25 11:45:47 +08:00
},
{
"cell_type": "code",
2022-03-21 19:38:35 +08:00
"execution_count": 9,
2021-08-25 11:45:47 +08:00
"source": [
"# Visualize the results\n",
"import matplotlib.pyplot as plt\n",
"predicted_img = mmcv.imread('./outputs/demo_text_det_pred.jpg')\n",
"plt.figure(figsize=(9, 16))\n",
"plt.imshow(mmcv.bgr2rgb(predicted_img))\n",
"plt.show()"
],
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
"<Figure size 648x1152 with 1 Axes>"
2021-08-25 16:41:07 +08:00
],
2022-03-21 19:38:35 +08:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAh4AAAFQCAYAAADweXfLAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nOy9y45kSZKm94mo6jEzj4jMqu7hzDRnhhcQTQLkhivyCQhwxx1B8gFmxQfgs8yCOwJ8gga4Ighw1wMMAV4ADrrJHvSlblmZlRkR7m5HVUW4ENFjFlGRdSE7u7OartXeGe5mduxcVEV++eUXUXF3XsbLeBkv42W8jJfxMv4mhv5tn8DLeBkv42W8jJfxMv7/M16Ax8t4GS/jZbyMl/Ey/sbGC/B4GS/jZbyMl/EyXsbf2HgBHi/jZbyMl/EyXsbL+BsbL8DjZbyMl/EyXsbLeBl/Y+MFeLyMl/EyXsbLeBkv429sfGfAQ0T+UxH5P0XkT0Tkv/muvudlvIyX8TJexst4Gb87Q76LPh4iUoB/CfwnwF8Afwz8l+7+f/y1f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GpEdbkkGWE8/2LooxU0C0qifTFLRqZvcePGZih4hQr+DTGGOzA1HRgYrhLRqNCFaUuo/9sPD8/gwhbOnrcGb3TdVJsggeFugDKoo8l/+ZmiEY6wKdhDJwAVADXa8c0GBHDmRa3Q0WoGeXYnPicAQjcmGNQegfAHGprOLBfO2OMYBC00UQwqVAa1xmOTySTDH5Lkbk64pPz6YyNQfgWv6XU8mkIS
2021-05-18 11:13:07 +08:00
},
"metadata": {
"needs_background": "light"
}
}
2021-08-25 16:41:07 +08:00
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 353
},
"id": "2-UHsqkZJFND",
2022-03-21 19:38:35 +08:00
"outputId": "edc80599-0da0-45aa-9467-46f9eef6c4a4"
2021-08-25 16:41:07 +08:00
}
2021-08-25 11:45:47 +08:00
},
{
"cell_type": "markdown",
"source": [
"## Perform end-to-end OCR with pretrained recognizer and detector\n",
"\n",
"With the help of `ocr.py`, we can easily combine any text detector and recognizer into a pipeline that forms a standard OCR step. Now we build our own OCR pipeline with TextSnake and SAR and apply it to [demo_text_ocr.jpg](https://raw.githubusercontent.com/open-mmlab/mmocr/main/demo/demo_text_ocr.jpg)."
2021-08-25 16:41:07 +08:00
],
"metadata": {
"id": "x-uRAtLa63sz"
}
2021-08-25 11:45:47 +08:00
},
{
"cell_type": "code",
2022-03-21 19:38:35 +08:00
"execution_count": 10,
2021-08-25 11:45:47 +08:00
"source": [
"from mmocr.utils.ocr import MMOCR\n",
"mmocr = MMOCR(det='TextSnake', recog='SAR')\n",
"mmocr.readtext('demo/demo_text_ocr.jpg', print_result=True, output='outputs/demo_text_ocr_pred.jpg')"
2021-05-18 11:13:07 +08:00
],
2021-08-25 11:45:47 +08:00
"outputs": [
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stdout",
2021-08-25 11:45:47 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"load checkpoint from http path: https://download.openmmlab.com/mmocr/textdet/textsnake/textsnake_r50_fpn_unet_1200e_ctw1500-27f65b64.pth\n",
"load checkpoint from http path: https://download.openmmlab.com/mmocr/textrecog/sar/sar_r31_parallel_decoder_academic-dba3a4a3.pth\n"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
},
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stderr",
2021-08-25 11:45:47 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"/mmocr/mmocr/apis/inference.py:50: UserWarning: Class names are not saved in the checkpoint's meta data, use COCO classes by default.\n",
2021-08-25 11:45:47 +08:00
" warnings.warn('Class names are not saved in the checkpoint\\'s '\n",
2022-03-21 19:38:35 +08:00
"/usr/local/lib/python3.7/dist-packages/mmdet/datasets/utils.py:70: UserWarning: \"ImageToTensor\" pipeline is replaced by \"DefaultFormatBundle\" for batch inference. It is recommended to manually replace it in the test data pipeline in your config file.\n",
" 'data pipeline in your config file.', UserWarning)\n",
"/mmocr/mmocr/models/textdet/postprocess/utils.py:51: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.\n",
"Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
" canvas = canvas[1:h + 1, 1:w + 1].astype(np.bool)\n"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
},
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stdout",
2021-08-25 11:45:47 +08:00
"text": [
"{'filename': 'demo_text_ocr', 'text': ['OCBCBANK', 'soculationists', 'sanetal.enance.ounces', '70%', 'ROUND', 'SALE', 'ALLYEAR', 'is', 'SALE']}\n",
"\n"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"[{'filename': 'demo_text_ocr',\n",
" 'text': ['OCBCBANK',\n",
" 'soculationists',\n",
" 'sanetal.enance.ounces',\n",
" '70%',\n",
" 'ROUND',\n",
" 'SALE',\n",
" 'ALLYEAR',\n",
" 'is',\n",
" 'SALE']}]"
]
},
"metadata": {},
2022-03-21 19:38:35 +08:00
"execution_count": 10
2021-08-25 11:45:47 +08:00
}
2021-08-25 16:41:07 +08:00
],
2021-08-25 11:45:47 +08:00
"metadata": {
2021-08-25 16:41:07 +08:00
"id": "xu68YizP8qu6",
2022-03-21 19:38:35 +08:00
"outputId": "b16dc3bd-253e-4b63-ad88-8b79ededf7a9",
2021-08-25 11:45:47 +08:00
"colab": {
2021-08-25 16:41:07 +08:00
"base_uri": "https://localhost:8080/"
2021-08-25 11:45:47 +08:00
}
2021-08-25 16:41:07 +08:00
}
},
{
"cell_type": "code",
2022-03-21 19:38:35 +08:00
"execution_count": 11,
2021-05-18 11:13:07 +08:00
"source": [
"# Visualize the results\n",
"import matplotlib.pyplot as plt\n",
2021-08-25 11:45:47 +08:00
"predicted_img = mmcv.imread('./outputs/demo_text_ocr_pred.jpg')\n",
"plt.figure(figsize=(9, 16))\n",
2021-05-18 11:13:07 +08:00
"plt.imshow(mmcv.bgr2rgb(predicted_img))\n",
"plt.show()"
2021-08-25 11:45:47 +08:00
],
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
"<Figure size 648x1152 with 1 Axes>"
2021-08-25 16:41:07 +08:00
],
2022-03-21 19:38:35 +08:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAh4AAAD1CAYAAAAf3/wiAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nOy92ZNl2XXe99vDOXfKObOyqrKG7qqeIZBAAyAICiAAkaZgwxSpCPtBNmWHn2Q/+NWy/xY5QqbDpqSwwhEyZJOUFaDEAWgCDRBoNBqNrqruGrqmrJzzTmfYey8/7H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+c+Ux6qBkvs7836zbLHv7ufcbqI4DJTIQEdWIW26wXQoxUIAFRARE/Scmd3M/0HIOKESiRlPIKoHWM60wj7w23ogEfQl1XuLpO4DHEpSkSiBKUNRwcH+LKGt3XFEVBS0FIQFFEYprIObxAlmXkWYZvtWm32+l6Qkyz+ADNtSFICBGo+gAiuBDwSpHnLYbjMf3hgE7ejlGUgwO279zmje9/n9VTaywt9mgbS2YNq2trdNsd7t65w/qlp9/3mXw4bXacBUajPoNhP743rMV5NzP+DZ12F2MMed5CG4tCo5V5aD8wRyVz+6jaz4XjISJ/CPzhT76FSs7eIlrjJebFY+RhGpEIgCemB1RKufi8xcbTl7h79y6t5XXcuMDWY6j6oGqcETwZVhQEm2benkAAZOJISUdxImhtqYOibOWUQDUasCgVbT1A7/QpDm+QKYP2Dh+n7mhiNCB4GI1HZDqgr95m+PY27pefo/XFT6NPb+KrkqODIbZS5EtrhPVFdu7exxyN0GWFF8EdD6n39xkNBlAGf
2021-08-25 11:45:47 +08:00
},
"metadata": {
"needs_background": "light"
}
}
2021-08-25 16:41:07 +08:00
],
"metadata": {
"id": "2AZqwCt09XqR",
2022-03-21 19:38:35 +08:00
"outputId": "ba5009b3-fc09-4561-b9d6-f5fba6353fdd",
2021-08-25 16:41:07 +08:00
"colab": {
"base_uri": "https://localhost:8080/",
"height": 262
}
}
2021-05-18 11:13:07 +08:00
},
{
"cell_type": "markdown",
"source": [
2021-08-25 11:45:47 +08:00
"## Combine OCR with Downstream Tasks\n",
2021-05-18 11:13:07 +08:00
"\n",
2021-08-25 11:45:47 +08:00
"MMOCR also supports downstream tasks of OCR, such as key information extraction (KIE). We can even add a KIE model, SDMG-R, to the pipeline applied to [demo_kie.jpeg](https://raw.githubusercontent.com/open-mmlab/mmocr/main/demo/demo_kie.jpeg) and visualize its prediction based on the OCR result.\n"
2021-08-25 16:41:07 +08:00
],
2021-05-18 11:13:07 +08:00
"metadata": {
2021-08-25 16:41:07 +08:00
"id": "WQ9zzYMa9p9Y"
}
},
{
"cell_type": "code",
2022-03-21 19:38:35 +08:00
"execution_count": 12,
2021-05-18 11:13:07 +08:00
"source": [
2021-08-25 11:45:47 +08:00
"# SDMGR relies on the dictionary provided in wildreceipt\n",
"# First download the KIE dataset .tar file and extract it to ./data\n",
"!mkdir data\n",
"!wget https://download.openmmlab.com/mmocr/data/wildreceipt.tar\n",
"!tar -xf wildreceipt.tar \n",
"!mv wildreceipt ./data"
2021-05-18 11:13:07 +08:00
],
2021-08-25 11:45:47 +08:00
"outputs": [
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stdout",
2021-08-25 11:45:47 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"--2022-03-18 07:02:24-- https://download.openmmlab.com/mmocr/data/wildreceipt.tar\n",
"Resolving download.openmmlab.com (download.openmmlab.com)... 47.252.96.28\n",
"Connecting to download.openmmlab.com (download.openmmlab.com)|47.252.96.28|:443... connected.\n",
2021-08-25 11:45:47 +08:00
"HTTP request sent, awaiting response... 200 OK\n",
"Length: 185323520 (177M) [application/x-tar]\n",
"Saving to: ‘ wildreceipt.tar’ \n",
"\n",
2022-03-21 19:38:35 +08:00
"wildreceipt.tar 100%[===================>] 176.74M 6.76MB/s in 23s \n",
2021-08-25 11:45:47 +08:00
"\n",
2022-03-21 19:38:35 +08:00
"2022-03-18 07:02:49 (7.55 MB/s) - ‘ wildreceipt.tar’ saved [185323520/185323520]\n",
2021-08-25 11:45:47 +08:00
"\n"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
}
2021-08-25 16:41:07 +08:00
],
2021-08-25 11:45:47 +08:00
"metadata": {
2021-08-25 16:41:07 +08:00
"id": "oALHgzmrAqik",
2022-03-21 19:38:35 +08:00
"outputId": "d1344657-ee01-459e-a6b5-34c0e370321a",
2021-08-25 11:45:47 +08:00
"colab": {
"base_uri": "https://localhost:8080/"
}
2021-08-25 16:41:07 +08:00
}
},
{
"cell_type": "code",
2022-03-21 19:38:35 +08:00
"execution_count": 13,
2021-08-25 11:45:47 +08:00
"source": [
"from mmocr.utils.ocr import MMOCR\n",
"mmocr = MMOCR(det='TextSnake', recog='SAR', kie='SDMGR')\n",
"mmocr.readtext('demo/demo_kie.jpeg', print_result=True, output='outputs/demo_kie_pred.jpg')"
],
2021-05-18 11:13:07 +08:00
"outputs": [
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stdout",
2021-05-18 11:13:07 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"load checkpoint from http path: https://download.openmmlab.com/mmocr/textdet/textsnake/textsnake_r50_fpn_unet_1200e_ctw1500-27f65b64.pth\n",
"load checkpoint from http path: https://download.openmmlab.com/mmocr/textrecog/sar/sar_r31_parallel_decoder_academic-dba3a4a3.pth\n"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
},
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stderr",
2021-08-25 11:45:47 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"/mmocr/mmocr/apis/inference.py:50: UserWarning: Class names are not saved in the checkpoint's meta data, use COCO classes by default.\n",
" warnings.warn('Class names are not saved in the checkpoint\\'s '\n",
"Downloading: \"https://download.openmmlab.com/mmocr/kie/sdmgr/sdmgr_unet16_60e_wildreceipt_20210520-7489e6de.pth\" to /root/.cache/torch/hub/checkpoints/sdmgr_unet16_60e_wildreceipt_20210520-7489e6de.pth\n"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
},
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stdout",
2021-08-25 11:45:47 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"load checkpoint from http path: https://download.openmmlab.com/mmocr/kie/sdmgr/sdmgr_unet16_60e_wildreceipt_20210520-7489e6de.pth\n"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
},
2022-03-21 19:38:35 +08:00
{
"output_type": "display_data",
"data": {
"text/plain": [
" 0%| | 0.00/18.4M [00:00<?, ?B/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "cd5e91174a6441ad9d7b8c0a05f18f60"
}
},
"metadata": {}
},
2021-08-25 11:45:47 +08:00
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stderr",
2021-08-25 11:45:47 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"/usr/local/lib/python3.7/dist-packages/mmdet/datasets/utils.py:70: UserWarning: \"ImageToTensor\" pipeline is replaced by \"DefaultFormatBundle\" for batch inference. It is recommended to manually replace it in the test data pipeline in your config file.\n",
2021-08-25 11:45:47 +08:00
" 'data pipeline in your config file.', UserWarning)\n",
2022-03-21 19:38:35 +08:00
"/mmocr/mmocr/models/textdet/postprocess/utils.py:51: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.\n",
"Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
" canvas = canvas[1:h + 1, 1:w + 1].astype(np.bool)\n",
2021-08-25 11:45:47 +08:00
"/mmocr/mmocr/datasets/kie_dataset.py:46: UserWarning: KIEDataset is only initialized as a downstream demo task of text detection and recognition without an annotation file.\n",
2022-03-21 19:38:35 +08:00
" 'without an annotation file.', UserWarning)\n",
"/mmocr/mmocr/datasets/pipelines/box_utils.py:44: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.\n",
"Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations\n",
" indexes = (np.arange(N, dtype=np.int) + lefttop_idx) % N\n"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
},
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stdout",
2021-08-25 11:45:47 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"Downloading https://download.openmmlab.com/mmocr/data/font.TTF ...\n",
2021-08-25 11:45:47 +08:00
"{'filename': 'demo_kie', 'text': ['Appraval:052723', 'Acct:Xexexxx8425', '128.27', 'Master', '128.27', 'Total', 'Tax', '11.02', '117.25', 'subTotal', 'Cheese', '10.47', '3.Perreroni', '11.07', '3Supreme', '11.97', '26', '43.94', '0.00', '12.Crunchy.Taco', '10.00', 'SLACOMPARTY', '0.00', '12SFTTACO', '10.00', 'SFtt.Tac.Party.', '0.00', 'MONODELONS', '0.00', '10.Bean', 'Grande', '9.90', 'Beatean', '0.00', 'grande', '9.90', '0rder-113533', 'Cashier:.Eric', '7/30/2012', '8:27:32', '=Article-I.D.:']}\n",
"\n"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"[{'filename': 'demo_kie',\n",
" 'text': ['Appraval:052723',\n",
" 'Acct:Xexexxx8425',\n",
" '128.27',\n",
" 'Master',\n",
" '128.27',\n",
" 'Total',\n",
" 'Tax',\n",
" '11.02',\n",
" '117.25',\n",
" 'subTotal',\n",
" 'Cheese',\n",
" '10.47',\n",
" '3.Perreroni',\n",
" '11.07',\n",
" '3Supreme',\n",
" '11.97',\n",
" '26',\n",
" '43.94',\n",
" '0.00',\n",
" '12.Crunchy.Taco',\n",
" '10.00',\n",
" 'SLACOMPARTY',\n",
" '0.00',\n",
" '12SFTTACO',\n",
" '10.00',\n",
" 'SFtt.Tac.Party.',\n",
" '0.00',\n",
" 'MONODELONS',\n",
" '0.00',\n",
" '10.Bean',\n",
" 'Grande',\n",
" '9.90',\n",
" 'Beatean',\n",
" '0.00',\n",
" 'grande',\n",
" '9.90',\n",
" '0rder-113533',\n",
" 'Cashier:.Eric',\n",
" '7/30/2012',\n",
" '8:27:32',\n",
" '=Article-I.D.:']}]"
]
},
"metadata": {},
2022-03-21 19:38:35 +08:00
"execution_count": 13
2021-05-18 11:13:07 +08:00
}
2021-08-25 16:41:07 +08:00
],
2021-05-18 11:13:07 +08:00
"metadata": {
2021-08-25 16:41:07 +08:00
"id": "2KPRTdHVAGfF",
2022-03-21 19:38:35 +08:00
"outputId": "b77885e0-2c12-4eb3-b7f3-e7db80615f29",
2021-05-18 11:13:07 +08:00
"colab": {
2022-03-21 19:38:35 +08:00
"base_uri": "https://localhost:8080/",
"height": 1000,
"referenced_widgets": [
"cd5e91174a6441ad9d7b8c0a05f18f60",
"7f0e77d508574ec485243125375cedfb",
"45cc8c746da74a8fbc32d5bdfb1e350e",
"4153b5f7dd474c079cb9b38f79d515d8",
"31a4e677ff8849e8b9050ece3e516413",
"3761f71633874fd39205adb5fafe98fe",
"12377605aaa24988b2075e88c5fd77cc",
"39bb6e08d13c4979a731ca6c8a8e5668",
"97992daf80b5487595712d675d17a9da",
"f1d3884457d8426db6a59bda51249444",
"a2220a97632e449e95ff559987245b0b"
]
2021-08-25 11:45:47 +08:00
}
2021-08-25 16:41:07 +08:00
}
},
{
"cell_type": "code",
2022-03-21 19:38:35 +08:00
"execution_count": 14,
2021-05-18 11:13:07 +08:00
"source": [
"# Visualize the results\n",
"import matplotlib.pyplot as plt\n",
2021-08-25 11:45:47 +08:00
"predicted_img = mmcv.imread('./outputs/demo_kie_pred.jpg')\n",
"plt.figure(figsize=(18, 32))\n",
2021-05-18 11:13:07 +08:00
"plt.imshow(mmcv.bgr2rgb(predicted_img))\n",
"plt.show()"
],
"outputs": [
{
"output_type": "display_data",
"data": {
2021-08-25 11:45:47 +08:00
"text/plain": [
"<Figure size 1296x2304 with 1 Axes>"
2021-08-25 16:41:07 +08:00
],
2022-03-21 19:38:35 +08:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAABBQAAAHhCAYAAADeeO2RAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpY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kCrQhOIcPoIIg4jHG4NO6jE37XAnKRJVDVI1LPLakzLTEjK+KOwhCiGRPKlEwNsO7Ai8KbTMkuKoEQuuklOgE9UmCrxPRUKbXpSsoVUrhgiczOr0XiayQyhwE0NYiPipPFD4G89ZgdMq+CyhSuU6aK6UrYxDuBGM13geUjaST1gZCLOXRJgbdRRpbYRrstr3s1gFnLcYrJAe0StJ3hRiLZFKRSUbHsfukHvAqQ6XXRIHvLpUhKjg0RBIKheQ2lZ+kGVyVTERCQSdyxDdcnBeJGPASqpIHlc7hSERJVdXQKccQCYk0SkvolJ3odO4ZA6hIygH09KB1UvbLRGlB55iFLrVEnOGOrNHDHDtO81ALK22aJsM4iXPOaoISTJzYkTAR4v7HYVAYYwmJyAvBo7XQ61qcLcIFe3fw0He/y3NPPodqN6HM0KaHYKDNUV69+lwueNM12Ab4KLOIBJeGUJYYZdBKocSDH2d4ZCdzR3bgW4fQIaBEYY3GWk1mM8bHj2OtpWwVxMtRnLcKhctzxHgGZi6DksTI1ahRo0aNGjVq1Kjxq8HLTiiIiFNKfQC4DzDAl0XkyRf+Doho2i4QlEbZnDBReE9mLSrEjPTItD7WT5uFsb2ooNFZFrPzmPggT0ApISgLRDm6UjFLGoLHGhtLC5IvA8QgSREz6zGZGrPhsUxCg4CXqAQgBU0kmb9WhiCdMoakpiDW0ms0IjHzC
2021-05-18 11:13:07 +08:00
},
"metadata": {
"needs_background": "light"
}
}
2021-08-25 16:41:07 +08:00
],
"metadata": {
"id": "96hqfaovAGhl",
2022-03-21 19:38:35 +08:00
"outputId": "5d1a8f38-aac4-4f14-b65c-5792e8d496d8",
2021-08-25 16:41:07 +08:00
"colab": {
"base_uri": "https://localhost:8080/",
2022-03-21 19:38:35 +08:00
"height": 306
2021-08-25 16:41:07 +08:00
}
}
2021-05-18 11:13:07 +08:00
},
{
"cell_type": "markdown",
"source": [
"## Perform Testing with a Pretrained KIE Model\n",
"\n",
"We perform testing on the WildReceipt dataset for KIE model by first downloading the .tar file from [Datasets Preparation](https://mmocr.readthedocs.io/en/latest/datasets.html) in MMOCR documentation and then extract the dataset. We have chosen the Visual + Textual moduality test dataset, which we evaluate with Macro F1 metrics."
2021-08-25 16:41:07 +08:00
],
"metadata": {
"id": "PTWMzvd3E_h8"
}
2021-05-18 11:13:07 +08:00
},
{
"cell_type": "code",
2022-03-21 19:38:35 +08:00
"execution_count": 15,
2021-05-18 11:13:07 +08:00
"source": [
2021-08-25 11:45:47 +08:00
"# Can skip this step if you have downloaded wildreceipt in the last section\n",
"# Download the KIE dataset .tar file and extract it to ./data\n",
2021-05-18 11:13:07 +08:00
"!mkdir data\n",
"!wget https://download.openmmlab.com/mmocr/data/wildreceipt.tar\n",
"!tar -xf wildreceipt.tar \n",
"!mv wildreceipt ./data"
],
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
2022-03-21 19:38:35 +08:00
"mkdir: cannot create directory ‘ data’ : File exists\n",
"--2022-03-18 07:03:33-- https://download.openmmlab.com/mmocr/data/wildreceipt.tar\n",
"Resolving download.openmmlab.com (download.openmmlab.com)... 47.75.20.18\n",
"Connecting to download.openmmlab.com (download.openmmlab.com)|47.75.20.18|:443... connected.\n",
2021-05-18 11:13:07 +08:00
"HTTP request sent, awaiting response... 200 OK\n",
"Length: 185323520 (177M) [application/x-tar]\n",
2022-03-21 19:38:35 +08:00
"Saving to: ‘ wildreceipt.tar.1’ \n",
2021-05-18 11:13:07 +08:00
"\n",
2022-03-21 19:38:35 +08:00
"wildreceipt.tar.1 100%[===================>] 176.74M 6.24MB/s in 20s \n",
2021-05-18 11:13:07 +08:00
"\n",
2022-03-21 19:38:35 +08:00
"2022-03-18 07:03:54 (8.90 MB/s) - ‘ wildreceipt.tar.1’ saved [185323520/185323520]\n",
"\n",
"mv: cannot move 'wildreceipt' to './data/wildreceipt': Directory not empty\n"
2021-05-18 11:13:07 +08:00
]
}
2021-08-25 16:41:07 +08:00
],
2021-05-18 11:13:07 +08:00
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
2021-08-25 16:41:07 +08:00
"id": "3VEW3PQrFZ0g",
2022-03-21 19:38:35 +08:00
"outputId": "6604ea25-cbf6-4c74-bc8e-8413abf3adba"
2021-08-25 16:41:07 +08:00
}
},
{
"cell_type": "code",
2022-03-21 19:38:35 +08:00
"execution_count": 16,
2021-05-18 11:13:07 +08:00
"source": [
"# Test the dataset with macro f1 metrics \n",
"!python tools/test.py configs/kie/sdmgr/sdmgr_unet16_60e_wildreceipt.py https://download.openmmlab.com/mmocr/kie/sdmgr/sdmgr_unet16_60e_wildreceipt_20210405-16a47642.pth --eval macro_f1"
],
"outputs": [
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stdout",
2021-05-18 11:13:07 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"/usr/local/lib/python3.7/dist-packages/mmdet/datasets/pipelines/formating.py:7: UserWarning: DeprecationWarning: mmdet.datasets.pipelines.formating will be deprecated, please replace it with mmdet.datasets.pipelines.formatting.\n",
" warnings.warn('DeprecationWarning: mmdet.datasets.pipelines.formating will be '\n",
"/mmocr/mmocr/utils/setup_env.py:33: UserWarning: Setting OMP_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed.\n",
" f'Setting OMP_NUM_THREADS environment variable for each process '\n",
"/mmocr/mmocr/utils/setup_env.py:43: UserWarning: Setting MKL_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed.\n",
" f'Setting MKL_NUM_THREADS environment variable for each process '\n",
"/mmocr/mmocr/datasets/utils/loader.py:86: UserWarning: HardDiskLoader is deprecated, please use AnnFileLoader instead.\n",
" 'AnnFileLoader instead.', UserWarning)\n",
"/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py:481: UserWarning: This DataLoader will create 4 worker processes in total. Our suggested max number of worker in current system is 2, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary.\n",
" cpuset_checked))\n",
"load checkpoint from http path: https://download.openmmlab.com/mmocr/kie/sdmgr/sdmgr_unet16_60e_wildreceipt_20210405-16a47642.pth\n",
2021-08-25 11:45:47 +08:00
"Downloading: \"https://download.openmmlab.com/mmocr/kie/sdmgr/sdmgr_unet16_60e_wildreceipt_20210405-16a47642.pth\" to /root/.cache/torch/hub/checkpoints/sdmgr_unet16_60e_wildreceipt_20210405-16a47642.pth\n",
2022-03-21 19:38:35 +08:00
"100% 18.4M/18.4M [00:03<00:00, 6.25MB/s]\n",
"[>>] 472/472, 12.9 task/s, elapsed: 36s, ETA: 0s{'macro_f1': 0.87641114}\n"
2021-08-25 16:41:07 +08:00
]
2021-05-18 11:13:07 +08:00
}
2021-08-25 16:41:07 +08:00
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "p0MHNwybo0iI",
2022-03-21 19:38:35 +08:00
"outputId": "337a3213-322d-409c-d65a-a17843d59e9d"
2021-08-25 16:41:07 +08:00
}
2021-05-18 11:13:07 +08:00
},
{
"cell_type": "markdown",
"source": [
"## Perform Training on a Toy Dataset with MMOCR Recognizer\n",
"We now demonstrate how to perform training with an MMOCR recognizer. Since training a full academic dataset is time consuming (usually takes about several hours), we will train on the toy dataset for the SAR text recognition model and visualize the predictions. Text detection and other downstream tasks such as KIE follow similar procedures.\n",
"\n",
"Training a dataset usually consists of the following steps:\n",
"1. Convert the dataset into a format supported by MMOCR (e.g. COCO for text detection). The annotation file can be in either .txt or .lmdb format, depending on the size of the dataset. This step is usually applicable to customized datasets, since the datasets and annotation files we provide are already in supported formats. \n",
"2. Modify the config for training. \n",
"3. Train the model. \n",
"\n",
2021-08-25 11:45:47 +08:00
"The toy dataset consisits of ten images as well as annotation files in both txt and lmdb format, which can be found in [ocr_toy_dataset](https://github.com/open-mmlab/mmocr/tree/main/tests/data/toy_dataset). "
2021-08-25 16:41:07 +08:00
],
"metadata": {
"id": "nYon41X7RTOT"
}
2021-05-18 11:13:07 +08:00
},
{
2021-08-25 11:45:47 +08:00
"cell_type": "markdown",
2021-05-18 11:13:07 +08:00
"source": [
"### Visualize the Toy Dataset\n",
"\n",
"We first get a sense of what the toy dataset looks like by visualizing one of the images and labels. "
2021-08-25 16:41:07 +08:00
],
"metadata": {
"id": "FElJSp1vpEUz"
}
2021-05-18 11:13:07 +08:00
},
{
"cell_type": "code",
2022-03-21 19:38:35 +08:00
"execution_count": 17,
2021-05-18 11:13:07 +08:00
"source": [
"import mmcv\n",
"import matplotlib.pyplot as plt \n",
"\n",
"img = mmcv.imread('./tests/data/ocr_toy_dataset/imgs/1036169.jpg')\n",
"plt.imshow(mmcv.bgr2rgb(img))\n",
"plt.show()"
],
"outputs": [
{
"output_type": "display_data",
"data": {
2021-08-25 11:45:47 +08:00
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
2021-08-25 16:41:07 +08:00
],
2022-03-21 19:38:35 +08:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAABoCAYAAADo66t9AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nOy92ZJlyXWm9y1338OZT4w5VmZlAQVWFQASDXBsmdr6Rma60HAr6QH6Sg+gZ+kLXesJ2kwXlNrUMpEtdJMECYCYasyaMmM6EWfYg0+6cN8nIosE2Ea0QINZuuWxjOGcvX37sNa//vUvD4kx8rq9bq/b6/a6/fY19U/dgdftdXvdXrfX7R/XXhvw1+11e91et9/S9tqAv26v2+v2uv2WttcG/HV73V631+23tL024K/b6/a6vW6/pe21AX/dXrfX7XX7LW2/lgEXkf9aRH4qIr8Qkf/lP1enXrfX7XV73V63f7jJP1YHLiIa+BnwXwGfAt8H/scY44//83XvdXvdXrfX7XX7Zc38Gp/9Q+AXMcYPAETkfwP+e+CXGvC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TQob8ScAHB+h9tDfA3rsI/CuDlt4yjKlS+3Xy1WcbnksNizNGYlR3op+M0gcOWQmibudrf6mQx0ZijkS/Mo/5u/0I5PlPVFm6yDA/g4EPISS0KoCoNC5EYpR9/4bHv32g/EwkZKxEZ6cW95HJsEckPw+Efc7q7h6O2ailPoXbe95BxfubkpyLz847DPtWhIIiPb8olDZ53NW+Lwz9gTuR/B0k/tXbcTc6HEb5NlLcByJRyEOV526Yt
2021-05-18 11:13:07 +08:00
},
"metadata": {
"needs_background": "light"
}
}
2021-08-25 16:41:07 +08:00
],
2021-05-18 11:13:07 +08:00
"metadata": {
"colab": {
2021-08-25 16:41:07 +08:00
"base_uri": "https://localhost:8080/",
"height": 121
2021-05-18 11:13:07 +08:00
},
2021-08-25 16:41:07 +08:00
"id": "hZfd2pnqN5-Q",
2022-03-21 19:38:35 +08:00
"outputId": "8884944a-093f-4aed-c1c7-58d5e045ad31"
2021-08-25 16:41:07 +08:00
}
},
{
"cell_type": "code",
2022-03-21 19:38:35 +08:00
"execution_count": 18,
2021-05-18 11:13:07 +08:00
"source": [
"# Inspect the labels of the annootation file\n",
"!cat tests/data/ocr_toy_dataset/label.txt"
],
"outputs": [
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stdout",
2021-05-18 11:13:07 +08:00
"text": [
2021-08-25 11:45:47 +08:00
"1223731.jpg GRAND\n",
"1223733.jpg HOTEL\n",
"1223732.jpg HOTEL\n",
"1223729.jpg PACIFIC\n",
"1036169.jpg 03/09/2009\n",
"1190237.jpg ANING\n",
"1058891.jpg Virgin\n",
"1058892.jpg america\n",
"1240078.jpg ATTACK\n",
"1210236.jpg DAVIDSON\n"
2021-08-25 16:41:07 +08:00
]
2021-05-18 11:13:07 +08:00
}
2021-08-25 16:41:07 +08:00
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "F5M_FVVRN6Fw",
2022-03-21 19:38:35 +08:00
"outputId": "35ef086b-1612-4126-a977-9d7891dd6839"
2021-08-25 16:41:07 +08:00
}
2021-05-18 11:13:07 +08:00
},
{
"cell_type": "markdown",
"source": [
"### Modify the Configuration File\n",
"\n",
"In order to perform inference for SAR on colab, we need to modify the config file to accommodate some of the settings of colab such as the number of GPU available. "
2021-08-25 16:41:07 +08:00
],
"metadata": {
"id": "i-GrV0xSkAc3"
}
2021-05-18 11:13:07 +08:00
},
{
"cell_type": "code",
2022-03-21 19:38:35 +08:00
"execution_count": 19,
2021-05-18 11:13:07 +08:00
"source": [
"from mmcv import Config\n",
"cfg = Config.fromfile('./configs/textrecog/sar/sar_r31_parallel_decoder_toy_dataset.py')"
],
2021-08-25 16:41:07 +08:00
"outputs": [],
"metadata": {
"id": "uFFH3yUgPEFj"
}
2021-05-18 11:13:07 +08:00
},
{
"cell_type": "code",
2022-03-21 19:38:35 +08:00
"execution_count": 20,
2021-05-18 11:13:07 +08:00
"source": [
"from mmdet.apis import set_random_seed\n",
"\n",
"# Set up working dir to save files and logs.\n",
"cfg.work_dir = './demo/tutorial_exps'\n",
"\n",
"# The original learning rate (LR) is set for 8-GPU training.\n",
"# We divide it by 8 since we only use one GPU.\n",
"cfg.optimizer.lr = 0.001 / 8\n",
"cfg.lr_config.warmup = None\n",
"# Choose to log training results every 40 images to reduce the size of log file. \n",
"cfg.log_config.interval = 40\n",
"\n",
"# Set seed thus the results are more reproducible\n",
"cfg.seed = 0\n",
"set_random_seed(0, deterministic=False)\n",
"cfg.gpu_ids = range(1)\n",
"\n",
"# We can initialize the logger for training and have a look\n",
"# at the final config used for training\n",
"print(f'Config:\\n{cfg.pretty_text}')"
],
"outputs": [
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stdout",
2021-05-18 11:13:07 +08:00
"text": [
2021-08-25 11:45:47 +08:00
"Config:\n",
"checkpoint_config = dict(interval=1)\n",
"log_config = dict(interval=40, hooks=[dict(type='TextLoggerHook')])\n",
"dist_params = dict(backend='nccl')\n",
"log_level = 'INFO'\n",
"load_from = None\n",
"resume_from = None\n",
"workflow = [('train', 1)]\n",
2022-03-21 19:38:35 +08:00
"opencv_num_threads = 0\n",
"mp_start_method = 'fork'\n",
2021-08-25 11:45:47 +08:00
"label_convertor = dict(\n",
" type='AttnConvertor', dict_type='DICT90', with_unknown=True)\n",
"model = dict(\n",
" type='SARNet',\n",
" backbone=dict(type='ResNet31OCR'),\n",
" encoder=dict(\n",
" type='SAREncoder', enc_bi_rnn=False, enc_do_rnn=0.1, enc_gru=False),\n",
" decoder=dict(\n",
" type='ParallelSARDecoder',\n",
" enc_bi_rnn=False,\n",
" dec_bi_rnn=False,\n",
" dec_do_rnn=0,\n",
" dec_gru=False,\n",
" pred_dropout=0.1,\n",
" d_k=512,\n",
" pred_concat=True),\n",
" loss=dict(type='SARLoss'),\n",
" label_convertor=dict(\n",
" type='AttnConvertor', dict_type='DICT90', with_unknown=True),\n",
" max_seq_len=30)\n",
"optimizer = dict(type='Adam', lr=0.000125)\n",
"optimizer_config = dict(grad_clip=None)\n",
"lr_config = dict(policy='step', step=[3, 4], warmup=None)\n",
"total_epochs = 5\n",
"img_norm_cfg = dict(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5])\n",
"train_pipeline = [\n",
" dict(type='LoadImageFromFile'),\n",
" dict(\n",
" type='ResizeOCR',\n",
" height=48,\n",
" min_width=48,\n",
" max_width=160,\n",
2022-03-21 19:38:35 +08:00
" keep_aspect_ratio=True,\n",
" width_downsample_ratio=0.25),\n",
2021-08-25 11:45:47 +08:00
" dict(type='ToTensorOCR'),\n",
" dict(type='NormalizeOCR', mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5]),\n",
" dict(\n",
" type='Collect',\n",
" keys=['img'],\n",
" meta_keys=[\n",
" 'filename', 'ori_shape', 'resize_shape', 'text', 'valid_ratio'\n",
" ])\n",
"]\n",
"test_pipeline = [\n",
" dict(type='LoadImageFromFile'),\n",
" dict(\n",
2022-03-21 19:38:35 +08:00
" type='MultiRotateAugOCR',\n",
" rotate_degrees=[0, 90, 270],\n",
" transforms=[\n",
" dict(\n",
" type='ResizeOCR',\n",
" height=48,\n",
" min_width=48,\n",
" max_width=160,\n",
" keep_aspect_ratio=True,\n",
" width_downsample_ratio=0.25),\n",
" dict(type='ToTensorOCR'),\n",
" dict(\n",
" type='NormalizeOCR', mean=[0.5, 0.5, 0.5], std=[0.5, 0.5,\n",
" 0.5]),\n",
" dict(\n",
" type='Collect',\n",
" keys=['img'],\n",
" meta_keys=[\n",
" 'filename', 'ori_shape', 'resize_shape', 'valid_ratio',\n",
" 'img_norm_cfg', 'ori_filename', 'img_shape'\n",
" ])\n",
2021-08-25 11:45:47 +08:00
" ])\n",
"]\n",
"dataset_type = 'OCRDataset'\n",
2022-03-21 19:38:35 +08:00
"root = 'tests/data/ocr_toy_dataset'\n",
2021-08-25 11:45:47 +08:00
"img_prefix = 'tests/data/ocr_toy_dataset/imgs'\n",
"train_anno_file1 = 'tests/data/ocr_toy_dataset/label.txt'\n",
"train1 = dict(\n",
" type='OCRDataset',\n",
" img_prefix='tests/data/ocr_toy_dataset/imgs',\n",
" ann_file='tests/data/ocr_toy_dataset/label.txt',\n",
" loader=dict(\n",
" type='HardDiskLoader',\n",
" repeat=100,\n",
" parser=dict(\n",
" type='LineStrParser',\n",
" keys=['filename', 'text'],\n",
" keys_idx=[0, 1],\n",
" separator=' ')),\n",
" pipeline=None,\n",
" test_mode=False)\n",
"train_anno_file2 = 'tests/data/ocr_toy_dataset/label.lmdb'\n",
"train2 = dict(\n",
" type='OCRDataset',\n",
" img_prefix='tests/data/ocr_toy_dataset/imgs',\n",
" ann_file='tests/data/ocr_toy_dataset/label.lmdb',\n",
" loader=dict(\n",
" type='LmdbLoader',\n",
" repeat=100,\n",
" parser=dict(\n",
" type='LineStrParser',\n",
" keys=['filename', 'text'],\n",
" keys_idx=[0, 1],\n",
" separator=' ')),\n",
" pipeline=None,\n",
" test_mode=False)\n",
"test_anno_file1 = 'tests/data/ocr_toy_dataset/label.lmdb'\n",
"test = dict(\n",
" type='OCRDataset',\n",
" img_prefix='tests/data/ocr_toy_dataset/imgs',\n",
" ann_file='tests/data/ocr_toy_dataset/label.lmdb',\n",
" loader=dict(\n",
" type='LmdbLoader',\n",
2022-03-21 19:38:35 +08:00
" repeat=1,\n",
2021-08-25 11:45:47 +08:00
" parser=dict(\n",
" type='LineStrParser',\n",
" keys=['filename', 'text'],\n",
" keys_idx=[0, 1],\n",
" separator=' ')),\n",
" pipeline=None,\n",
" test_mode=True)\n",
2022-03-21 19:38:35 +08:00
"train_list = [\n",
" dict(\n",
" type='OCRDataset',\n",
" img_prefix='tests/data/ocr_toy_dataset/imgs',\n",
" ann_file='tests/data/ocr_toy_dataset/label.txt',\n",
" loader=dict(\n",
" type='HardDiskLoader',\n",
" repeat=100,\n",
" parser=dict(\n",
" type='LineStrParser',\n",
" keys=['filename', 'text'],\n",
" keys_idx=[0, 1],\n",
" separator=' ')),\n",
" pipeline=None,\n",
" test_mode=False),\n",
" dict(\n",
" type='OCRDataset',\n",
" img_prefix='tests/data/ocr_toy_dataset/imgs',\n",
" ann_file='tests/data/ocr_toy_dataset/label.lmdb',\n",
" loader=dict(\n",
" type='LmdbLoader',\n",
" repeat=100,\n",
" parser=dict(\n",
" type='LineStrParser',\n",
" keys=['filename', 'text'],\n",
" keys_idx=[0, 1],\n",
" separator=' ')),\n",
" pipeline=None,\n",
" test_mode=False)\n",
"]\n",
"test_list = [\n",
" dict(\n",
" type='OCRDataset',\n",
" img_prefix='tests/data/ocr_toy_dataset/imgs',\n",
" ann_file='tests/data/ocr_toy_dataset/label.lmdb',\n",
" loader=dict(\n",
" type='LmdbLoader',\n",
" repeat=1,\n",
" parser=dict(\n",
" type='LineStrParser',\n",
" keys=['filename', 'text'],\n",
" keys_idx=[0, 1],\n",
" separator=' ')),\n",
" pipeline=None,\n",
" test_mode=True)\n",
"]\n",
2021-08-25 11:45:47 +08:00
"data = dict(\n",
" workers_per_gpu=2,\n",
" samples_per_gpu=8,\n",
" train=dict(\n",
" type='UniformConcatDataset',\n",
" datasets=[\n",
" dict(\n",
" type='OCRDataset',\n",
" img_prefix='tests/data/ocr_toy_dataset/imgs',\n",
" ann_file='tests/data/ocr_toy_dataset/label.txt',\n",
" loader=dict(\n",
" type='HardDiskLoader',\n",
" repeat=100,\n",
" parser=dict(\n",
" type='LineStrParser',\n",
" keys=['filename', 'text'],\n",
" keys_idx=[0, 1],\n",
" separator=' ')),\n",
" pipeline=None,\n",
" test_mode=False),\n",
" dict(\n",
" type='OCRDataset',\n",
" img_prefix='tests/data/ocr_toy_dataset/imgs',\n",
" ann_file='tests/data/ocr_toy_dataset/label.lmdb',\n",
" loader=dict(\n",
" type='LmdbLoader',\n",
" repeat=100,\n",
" parser=dict(\n",
" type='LineStrParser',\n",
" keys=['filename', 'text'],\n",
" keys_idx=[0, 1],\n",
" separator=' ')),\n",
" pipeline=None,\n",
" test_mode=False)\n",
" ],\n",
" pipeline=[\n",
" dict(type='LoadImageFromFile'),\n",
" dict(\n",
" type='ResizeOCR',\n",
" height=48,\n",
" min_width=48,\n",
" max_width=160,\n",
2022-03-21 19:38:35 +08:00
" keep_aspect_ratio=True,\n",
" width_downsample_ratio=0.25),\n",
2021-08-25 11:45:47 +08:00
" dict(type='ToTensorOCR'),\n",
" dict(\n",
" type='NormalizeOCR', mean=[0.5, 0.5, 0.5], std=[0.5, 0.5,\n",
" 0.5]),\n",
" dict(\n",
" type='Collect',\n",
" keys=['img'],\n",
" meta_keys=[\n",
" 'filename', 'ori_shape', 'resize_shape', 'text',\n",
" 'valid_ratio'\n",
" ])\n",
" ]),\n",
" val=dict(\n",
" type='UniformConcatDataset',\n",
" datasets=[\n",
" dict(\n",
" type='OCRDataset',\n",
" img_prefix='tests/data/ocr_toy_dataset/imgs',\n",
" ann_file='tests/data/ocr_toy_dataset/label.lmdb',\n",
" loader=dict(\n",
" type='LmdbLoader',\n",
2022-03-21 19:38:35 +08:00
" repeat=1,\n",
2021-08-25 11:45:47 +08:00
" parser=dict(\n",
" type='LineStrParser',\n",
" keys=['filename', 'text'],\n",
" keys_idx=[0, 1],\n",
" separator=' ')),\n",
" pipeline=None,\n",
" test_mode=True)\n",
" ],\n",
" pipeline=[\n",
" dict(type='LoadImageFromFile'),\n",
" dict(\n",
2022-03-21 19:38:35 +08:00
" type='MultiRotateAugOCR',\n",
" rotate_degrees=[0, 90, 270],\n",
" transforms=[\n",
" dict(\n",
" type='ResizeOCR',\n",
" height=48,\n",
" min_width=48,\n",
" max_width=160,\n",
" keep_aspect_ratio=True,\n",
" width_downsample_ratio=0.25),\n",
" dict(type='ToTensorOCR'),\n",
" dict(\n",
" type='NormalizeOCR',\n",
" mean=[0.5, 0.5, 0.5],\n",
" std=[0.5, 0.5, 0.5]),\n",
" dict(\n",
" type='Collect',\n",
" keys=['img'],\n",
" meta_keys=[\n",
" 'filename', 'ori_shape', 'resize_shape',\n",
" 'valid_ratio', 'img_norm_cfg', 'ori_filename',\n",
" 'img_shape'\n",
" ])\n",
2021-08-25 11:45:47 +08:00
" ])\n",
" ]),\n",
" test=dict(\n",
" type='UniformConcatDataset',\n",
" datasets=[\n",
" dict(\n",
" type='OCRDataset',\n",
" img_prefix='tests/data/ocr_toy_dataset/imgs',\n",
" ann_file='tests/data/ocr_toy_dataset/label.lmdb',\n",
" loader=dict(\n",
" type='LmdbLoader',\n",
2022-03-21 19:38:35 +08:00
" repeat=1,\n",
2021-08-25 11:45:47 +08:00
" parser=dict(\n",
" type='LineStrParser',\n",
" keys=['filename', 'text'],\n",
" keys_idx=[0, 1],\n",
" separator=' ')),\n",
" pipeline=None,\n",
" test_mode=True)\n",
" ],\n",
" pipeline=[\n",
" dict(type='LoadImageFromFile'),\n",
" dict(\n",
2022-03-21 19:38:35 +08:00
" type='MultiRotateAugOCR',\n",
" rotate_degrees=[0, 90, 270],\n",
" transforms=[\n",
" dict(\n",
" type='ResizeOCR',\n",
" height=48,\n",
" min_width=48,\n",
" max_width=160,\n",
" keep_aspect_ratio=True,\n",
" width_downsample_ratio=0.25),\n",
" dict(type='ToTensorOCR'),\n",
" dict(\n",
" type='NormalizeOCR',\n",
" mean=[0.5, 0.5, 0.5],\n",
" std=[0.5, 0.5, 0.5]),\n",
" dict(\n",
" type='Collect',\n",
" keys=['img'],\n",
" meta_keys=[\n",
" 'filename', 'ori_shape', 'resize_shape',\n",
" 'valid_ratio', 'img_norm_cfg', 'ori_filename',\n",
" 'img_shape'\n",
" ])\n",
2021-08-25 11:45:47 +08:00
" ])\n",
" ]))\n",
"evaluation = dict(interval=1, metric='acc')\n",
"work_dir = './demo/tutorial_exps'\n",
"seed = 0\n",
"gpu_ids = range(0, 1)\n",
"\n"
2021-08-25 16:41:07 +08:00
]
2021-05-18 11:13:07 +08:00
}
2021-08-25 16:41:07 +08:00
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "67OJ6oAvN6NA",
2022-03-21 19:38:35 +08:00
"outputId": "ae49a1d2-3a28-478b-aabd-2bdd354663e7"
2021-08-25 16:41:07 +08:00
}
2021-05-18 11:13:07 +08:00
},
{
"cell_type": "markdown",
"source": [
"### Train the SAR Text Recognizer \n",
"Finally, we train the SAR text recognizer on the toy dataset for five epochs. "
2021-08-25 16:41:07 +08:00
],
"metadata": {
"id": "TZj5vyqEmulE"
}
2021-05-18 11:13:07 +08:00
},
{
"cell_type": "code",
2022-03-21 19:38:35 +08:00
"execution_count": 21,
2021-05-18 11:13:07 +08:00
"source": [
"from mmocr.datasets import build_dataset\n",
"from mmocr.models import build_detector\n",
"from mmocr.apis import train_detector\n",
"import os.path as osp\n",
"\n",
"# Build dataset\n",
"datasets = [build_dataset(cfg.data.train)]\n",
"\n",
"# Build the detector\n",
"model = build_detector(\n",
" cfg.model, train_cfg=cfg.get('train_cfg'), test_cfg=cfg.get('test_cfg'))\n",
"# Add an attribute for visualization convenience\n",
"model.CLASSES = datasets[0].CLASSES\n",
"\n",
"# Create work_dir\n",
"mmcv.mkdir_or_exist(osp.abspath(cfg.work_dir))\n",
"train_detector(model, datasets, cfg, distributed=False, validate=True)"
2021-08-25 11:45:47 +08:00
],
"outputs": [
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stderr",
2021-08-25 11:45:47 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"/mmocr/mmocr/datasets/utils/loader.py:86: UserWarning: HardDiskLoader is deprecated, please use AnnFileLoader instead.\n",
" 'AnnFileLoader instead.', UserWarning)\n",
"/mmocr/mmocr/datasets/utils/loader.py:102: UserWarning: LmdbLoader is deprecated, please use AnnFileLoader instead.\n",
" 'AnnFileLoader instead.', UserWarning)\n",
"/mmocr/mmocr/apis/train.py:86: UserWarning: config is now expected to have a `runner` section, please set `runner` in your config.\n",
2021-08-25 11:45:47 +08:00
" 'please set `runner` in your config.', UserWarning)\n",
2022-03-21 19:38:35 +08:00
"/mmocr/mmocr/apis/utils.py:53: UserWarning: Remove \"MultiRotateAugOCR\" to support batch inference since samples_per_gpu > 1.\n",
" warnings.warn(warning_msg)\n",
"/mmocr/mmocr/datasets/utils/loader.py:102: UserWarning: LmdbLoader is deprecated, please use AnnFileLoader instead.\n",
" 'AnnFileLoader instead.', UserWarning)\n",
"2022-03-18 07:04:53,221 - mmocr - INFO - Start running, host: root@366f3a61a508, work_dir: /mmocr/demo/tutorial_exps\n",
"2022-03-18 07:04:53,223 - mmocr - INFO - Hooks will be executed in the following order:\n",
2021-08-25 11:45:47 +08:00
"before_run:\n",
"(VERY_HIGH ) StepLrUpdaterHook \n",
"(NORMAL ) CheckpointHook \n",
"(NORMAL ) EvalHook \n",
"(VERY_LOW ) TextLoggerHook \n",
" -------------------- \n",
"before_train_epoch:\n",
"(VERY_HIGH ) StepLrUpdaterHook \n",
"(NORMAL ) EvalHook \n",
"(LOW ) IterTimerHook \n",
"(VERY_LOW ) TextLoggerHook \n",
" -------------------- \n",
"before_train_iter:\n",
"(VERY_HIGH ) StepLrUpdaterHook \n",
"(NORMAL ) EvalHook \n",
"(LOW ) IterTimerHook \n",
" -------------------- \n",
"after_train_iter:\n",
"(ABOVE_NORMAL) OptimizerHook \n",
"(NORMAL ) CheckpointHook \n",
"(NORMAL ) EvalHook \n",
"(LOW ) IterTimerHook \n",
"(VERY_LOW ) TextLoggerHook \n",
" -------------------- \n",
"after_train_epoch:\n",
"(NORMAL ) CheckpointHook \n",
"(NORMAL ) EvalHook \n",
"(VERY_LOW ) TextLoggerHook \n",
" -------------------- \n",
"before_val_epoch:\n",
"(LOW ) IterTimerHook \n",
"(VERY_LOW ) TextLoggerHook \n",
" -------------------- \n",
"before_val_iter:\n",
"(LOW ) IterTimerHook \n",
" -------------------- \n",
"after_val_iter:\n",
"(LOW ) IterTimerHook \n",
" -------------------- \n",
"after_val_epoch:\n",
"(VERY_LOW ) TextLoggerHook \n",
" -------------------- \n",
2022-03-21 19:38:35 +08:00
"after_run:\n",
"(VERY_LOW ) TextLoggerHook \n",
" -------------------- \n",
"2022-03-18 07:04:53,226 - mmocr - INFO - workflow: [('train', 1)], max: 5 epochs\n",
"2022-03-18 07:04:53,231 - mmocr - INFO - Checkpoints will be saved to /mmocr/demo/tutorial_exps by HardDiskBackend.\n",
"2022-03-18 07:05:20,446 - mmocr - INFO - Epoch [1][40/250]\tlr: 1.250e-04, eta: 0:13:41, time: 0.679, data_time: 0.055, memory: 2142, loss_ce: 3.0851, loss: 3.0851\n",
"2022-03-18 07:05:45,627 - mmocr - INFO - Epoch [1][80/250]\tlr: 1.250e-04, eta: 0:12:45, time: 0.630, data_time: 0.004, memory: 2142, loss_ce: 1.8488, loss: 1.8488\n",
"2022-03-18 07:06:10,826 - mmocr - INFO - Epoch [1][120/250]\tlr: 1.250e-04, eta: 0:12:10, time: 0.630, data_time: 0.004, memory: 2142, loss_ce: 1.1972, loss: 1.1972\n",
"2022-03-18 07:06:35,823 - mmocr - INFO - Epoch [1][160/250]\tlr: 1.250e-04, eta: 0:11:38, time: 0.625, data_time: 0.004, memory: 2142, loss_ce: 0.8279, loss: 0.8279\n",
"2022-03-18 07:07:00,726 - mmocr - INFO - Epoch [1][200/250]\tlr: 1.250e-04, eta: 0:11:08, time: 0.623, data_time: 0.006, memory: 2142, loss_ce: 0.6695, loss: 0.6695\n",
"2022-03-18 07:07:25,537 - mmocr - INFO - Epoch [1][240/250]\tlr: 1.250e-04, eta: 0:10:40, time: 0.620, data_time: 0.004, memory: 2142, loss_ce: 0.5306, loss: 0.5306\n",
"2022-03-18 07:07:31,700 - mmocr - INFO - Saving checkpoint at 1 epochs\n"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
},
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stdout",
2021-08-25 11:45:47 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 10/10, 4.5 task/s, elapsed: 2s, ETA: 0s"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
},
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stderr",
2021-08-25 11:45:47 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"2022-03-18 07:07:38,433 - mmocr - INFO - \n",
"Evaluateing tests/data/ocr_toy_dataset/label.lmdb with 10 images now\n",
"2022-03-18 07:07:38,442 - mmocr - INFO - Epoch(val) [1][2]\t0_word_acc: 0.8000, 0_word_acc_ignore_case: 0.8000, 0_word_acc_ignore_case_symbol: 0.8000, 0_char_recall: 0.8065, 0_char_precision: 0.8333, 0_1-N.E.D: 0.8000\n",
"2022-03-18 07:08:05,298 - mmocr - INFO - Epoch [2][40/250]\tlr: 1.250e-04, eta: 0:09:52, time: 0.670, data_time: 0.055, memory: 2142, loss_ce: 0.4700, loss: 0.4700\n",
"2022-03-18 07:08:30,055 - mmocr - INFO - Epoch [2][80/250]\tlr: 1.250e-04, eta: 0:09:28, time: 0.619, data_time: 0.004, memory: 2142, loss_ce: 0.3754, loss: 0.3754\n",
"2022-03-18 07:08:54,819 - mmocr - INFO - Epoch [2][120/250]\tlr: 1.250e-04, eta: 0:09:03, time: 0.619, data_time: 0.004, memory: 2142, loss_ce: 0.3414, loss: 0.3414\n",
"2022-03-18 07:09:19,594 - mmocr - INFO - Epoch [2][160/250]\tlr: 1.250e-04, eta: 0:08:38, time: 0.619, data_time: 0.004, memory: 2142, loss_ce: 0.2869, loss: 0.2869\n",
"2022-03-18 07:09:44,404 - mmocr - INFO - Epoch [2][200/250]\tlr: 1.250e-04, eta: 0:08:14, time: 0.620, data_time: 0.004, memory: 2142, loss_ce: 0.2737, loss: 0.2737\n",
"2022-03-18 07:10:09,451 - mmocr - INFO - Epoch [2][240/250]\tlr: 1.250e-04, eta: 0:07:50, time: 0.626, data_time: 0.004, memory: 2142, loss_ce: 0.2853, loss: 0.2853\n",
"2022-03-18 07:10:15,717 - mmocr - INFO - Saving checkpoint at 2 epochs\n"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
},
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stdout",
2021-08-25 11:45:47 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 10/10, 4.5 task/s, elapsed: 2s, ETA: 0s"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
},
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stderr",
2021-08-25 11:45:47 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"2022-03-18 07:10:22,071 - mmocr - INFO - \n",
"Evaluateing tests/data/ocr_toy_dataset/label.lmdb with 10 images now\n",
"2022-03-18 07:10:22,075 - mmocr - INFO - Epoch(val) [2][2]\t0_word_acc: 1.0000, 0_word_acc_ignore_case: 1.0000, 0_word_acc_ignore_case_symbol: 1.0000, 0_char_recall: 1.0000, 0_char_precision: 1.0000, 0_1-N.E.D: 1.0000\n",
"2022-03-18 07:10:49,081 - mmocr - INFO - Epoch [3][40/250]\tlr: 1.250e-04, eta: 0:07:14, time: 0.673, data_time: 0.055, memory: 2142, loss_ce: 0.2701, loss: 0.2701\n",
"2022-03-18 07:11:13,908 - mmocr - INFO - Epoch [3][80/250]\tlr: 1.250e-04, eta: 0:06:50, time: 0.621, data_time: 0.004, memory: 2142, loss_ce: 0.2601, loss: 0.2601\n",
"2022-03-18 07:11:38,740 - mmocr - INFO - Epoch [3][120/250]\tlr: 1.250e-04, eta: 0:06:25, time: 0.621, data_time: 0.004, memory: 2142, loss_ce: 0.2371, loss: 0.2371\n",
"2022-03-18 07:12:03,599 - mmocr - INFO - Epoch [3][160/250]\tlr: 1.250e-04, eta: 0:06:01, time: 0.621, data_time: 0.004, memory: 2142, loss_ce: 0.2534, loss: 0.2534\n",
"2022-03-18 07:12:28,426 - mmocr - INFO - Epoch [3][200/250]\tlr: 1.250e-04, eta: 0:05:37, time: 0.621, data_time: 0.004, memory: 2142, loss_ce: 0.2663, loss: 0.2663\n",
"2022-03-18 07:12:53,298 - mmocr - INFO - Epoch [3][240/250]\tlr: 1.250e-04, eta: 0:05:13, time: 0.622, data_time: 0.004, memory: 2142, loss_ce: 0.2332, loss: 0.2332\n",
"2022-03-18 07:12:59,521 - mmocr - INFO - Saving checkpoint at 3 epochs\n"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
},
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stdout",
2021-08-25 11:45:47 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 10/10, 4.4 task/s, elapsed: 2s, ETA: 0s"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
},
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stderr",
2021-08-25 11:45:47 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"2022-03-18 07:13:05,910 - mmocr - INFO - \n",
"Evaluateing tests/data/ocr_toy_dataset/label.lmdb with 10 images now\n",
"2022-03-18 07:13:05,916 - mmocr - INFO - Epoch(val) [3][2]\t0_word_acc: 1.0000, 0_word_acc_ignore_case: 1.0000, 0_word_acc_ignore_case_symbol: 1.0000, 0_char_recall: 1.0000, 0_char_precision: 1.0000, 0_1-N.E.D: 1.0000\n",
"2022-03-18 07:13:32,892 - mmocr - INFO - Epoch [4][40/250]\tlr: 1.250e-05, eta: 0:04:40, time: 0.673, data_time: 0.055, memory: 2142, loss_ce: 0.2443, loss: 0.2443\n",
"2022-03-18 07:13:57,706 - mmocr - INFO - Epoch [4][80/250]\tlr: 1.250e-05, eta: 0:04:16, time: 0.620, data_time: 0.003, memory: 2142, loss_ce: 0.2277, loss: 0.2277\n",
"2022-03-18 07:14:22,555 - mmocr - INFO - Epoch [4][120/250]\tlr: 1.250e-05, eta: 0:03:51, time: 0.621, data_time: 0.004, memory: 2142, loss_ce: 0.2369, loss: 0.2369\n",
"2022-03-18 07:14:47,388 - mmocr - INFO - Epoch [4][160/250]\tlr: 1.250e-05, eta: 0:03:27, time: 0.621, data_time: 0.004, memory: 2142, loss_ce: 0.2539, loss: 0.2539\n",
"2022-03-18 07:15:12,233 - mmocr - INFO - Epoch [4][200/250]\tlr: 1.250e-05, eta: 0:03:03, time: 0.621, data_time: 0.004, memory: 2142, loss_ce: 0.2252, loss: 0.2252\n",
"2022-03-18 07:15:37,058 - mmocr - INFO - Epoch [4][240/250]\tlr: 1.250e-05, eta: 0:02:38, time: 0.621, data_time: 0.004, memory: 2142, loss_ce: 0.2379, loss: 0.2379\n",
"2022-03-18 07:15:43,277 - mmocr - INFO - Saving checkpoint at 4 epochs\n"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
},
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stdout",
2021-08-25 11:45:47 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 10/10, 4.5 task/s, elapsed: 2s, ETA: 0s"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
},
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stderr",
2021-08-25 11:45:47 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"2022-03-18 07:15:49,687 - mmocr - INFO - \n",
"Evaluateing tests/data/ocr_toy_dataset/label.lmdb with 10 images now\n",
"2022-03-18 07:15:49,689 - mmocr - INFO - Epoch(val) [4][2]\t0_word_acc: 1.0000, 0_word_acc_ignore_case: 1.0000, 0_word_acc_ignore_case_symbol: 1.0000, 0_char_recall: 1.0000, 0_char_precision: 1.0000, 0_1-N.E.D: 1.0000\n",
"2022-03-18 07:16:16,654 - mmocr - INFO - Epoch [5][40/250]\tlr: 1.250e-06, eta: 0:02:07, time: 0.672, data_time: 0.055, memory: 2142, loss_ce: 0.2473, loss: 0.2473\n",
"2022-03-18 07:16:41,500 - mmocr - INFO - Epoch [5][80/250]\tlr: 1.250e-06, eta: 0:01:43, time: 0.621, data_time: 0.004, memory: 2142, loss_ce: 0.2186, loss: 0.2186\n",
"2022-03-18 07:17:06,303 - mmocr - INFO - Epoch [5][120/250]\tlr: 1.250e-06, eta: 0:01:19, time: 0.620, data_time: 0.004, memory: 2142, loss_ce: 0.2392, loss: 0.2392\n",
"2022-03-18 07:17:31,166 - mmocr - INFO - Epoch [5][160/250]\tlr: 1.250e-06, eta: 0:00:54, time: 0.622, data_time: 0.004, memory: 2142, loss_ce: 0.2261, loss: 0.2261\n",
"2022-03-18 07:17:56,010 - mmocr - INFO - Epoch [5][200/250]\tlr: 1.250e-06, eta: 0:00:30, time: 0.621, data_time: 0.004, memory: 2142, loss_ce: 0.2393, loss: 0.2393\n",
"2022-03-18 07:18:20,905 - mmocr - INFO - Epoch [5][240/250]\tlr: 1.250e-06, eta: 0:00:06, time: 0.622, data_time: 0.004, memory: 2142, loss_ce: 0.2376, loss: 0.2376\n",
"2022-03-18 07:18:27,106 - mmocr - INFO - Saving checkpoint at 5 epochs\n"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
},
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stdout",
2021-08-25 11:45:47 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 10/10, 4.5 task/s, elapsed: 2s, ETA: 0s"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
},
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stderr",
2021-08-25 11:45:47 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"2022-03-18 07:18:33,784 - mmocr - INFO - \n",
"Evaluateing tests/data/ocr_toy_dataset/label.lmdb with 10 images now\n",
"2022-03-18 07:18:33,787 - mmocr - INFO - Epoch(val) [5][2]\t0_word_acc: 1.0000, 0_word_acc_ignore_case: 1.0000, 0_word_acc_ignore_case_symbol: 1.0000, 0_char_recall: 1.0000, 0_char_precision: 1.0000, 0_1-N.E.D: 1.0000\n"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
}
2021-08-25 16:41:07 +08:00
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "mDVkK6yjpEU1",
2022-03-21 19:38:35 +08:00
"outputId": "122c38d1-cb9d-4c67-804d-89c2aa6e8021"
2021-08-25 16:41:07 +08:00
}
2021-05-18 11:13:07 +08:00
},
{
"cell_type": "markdown",
"source": [
"### Test and Visualize the Predictions\n",
"\n",
"For completeness, we also perform testing on the latest checkpoint and evaluate the results with hmean-iou metrics. The predictions are saved in the ./outputs file. "
2021-08-25 16:41:07 +08:00
],
"metadata": {
"id": "sklydRNXnfJk"
}
2021-05-18 11:13:07 +08:00
},
{
"cell_type": "code",
2022-03-21 19:38:35 +08:00
"execution_count": 22,
2021-05-18 11:13:07 +08:00
"source": [
2021-08-25 11:45:47 +08:00
"from mmocr.apis import init_detector, model_inference\n",
2021-05-18 11:13:07 +08:00
"\n",
"img = './tests/data/ocr_toy_dataset/imgs/1036169.jpg'\n",
"checkpoint = \"./demo/tutorial_exps/epoch_5.pth\"\n",
"out_file = 'outputs/1036169.jpg'\n",
"\n",
"model = init_detector(cfg, checkpoint, device=\"cuda:0\")\n",
"if model.cfg.data.test['type'] == 'ConcatDataset':\n",
" model.cfg.data.test.pipeline = model.cfg.data.test['datasets'][0].pipeline\n",
"\n",
"\n",
"result = model_inference(model, img)\n",
"print(f'result: {result}')\n",
"\n",
"img = model.show_result(\n",
" img, result, out_file=out_file, show=False)\n",
"\n",
"mmcv.imwrite(img, out_file)"
2021-08-25 11:45:47 +08:00
],
"outputs": [
{
"output_type": "stream",
2021-08-25 16:41:07 +08:00
"name": "stdout",
2021-08-25 11:45:47 +08:00
"text": [
2022-03-21 19:38:35 +08:00
"load checkpoint from local path: ./demo/tutorial_exps/epoch_5.pth\n",
"result: {'text': '03/09/2009', 'score': 0.9990636646747589}\n"
2021-08-25 16:41:07 +08:00
]
2021-08-25 11:45:47 +08:00
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"True"
]
},
"metadata": {},
2022-03-21 19:38:35 +08:00
"execution_count": 22
2021-08-25 11:45:47 +08:00
}
2021-08-25 16:41:07 +08:00
],
2021-05-18 11:13:07 +08:00
"metadata": {
"colab": {
2021-08-25 16:41:07 +08:00
"base_uri": "https://localhost:8080/"
2021-05-18 11:13:07 +08:00
},
2021-08-25 16:41:07 +08:00
"id": "-HbXY7uUpEU1",
2022-03-21 19:38:35 +08:00
"outputId": "02012c83-6825-4171-aa35-fd048d939274"
2021-08-25 16:41:07 +08:00
}
},
{
"cell_type": "code",
2022-03-21 19:38:35 +08:00
"execution_count": 23,
2021-05-18 11:13:07 +08:00
"source": [
"# Visualize the results\n",
"predicted_img = mmcv.imread('./outputs/1036169.jpg')\n",
"plt.figure(figsize=(4, 4))\n",
"plt.imshow(mmcv.bgr2rgb(predicted_img))\n",
"plt.show()"
],
"outputs": [
{
"output_type": "display_data",
"data": {
2021-08-25 11:45:47 +08:00
"text/plain": [
"<Figure size 288x288 with 1 Axes>"
2021-08-25 16:41:07 +08:00
],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Q119G77qdct2sXp73nPaizGO8pd+/hxhf+JSOXXEKIhuKIo9B1E9T37sV9+kJ2f+sS8naLlX/w+2ijgUhOILmPlwaMhvhvhlY+g0P57773va/GEDXEqKWqhqja+9ktevnKZbp9pKY/XXuU7rrgAxq3bNe4eatufs1rdeP4mF61fEyvffu/aOy0NfqoWniN7XmNM3s17tmpcdcOjTt3abx1s+75qxfojpG6/uTItRpu26naDxpj1BhLjdFrjOn6IXr1vkjbQtRi46268Y/+UDeOjepPH/cYjft3aeyXGoug8cCMXnm/++mm8THdcs5DdOPfvULjlq0aN2/Rm5/yZN00NqpbRkb1W0/6E9XZOdVuV7d+8tP6gxWrdHe9rtefcYbeeN5ztbj6et33yQv11mc+Ta86YrlePT2lM1/4ksZeX9X7qp268E9D1OC9Ru81Fj2N+/fq9vNfpVctX6E3/P7vaziwU2MsNJaltq+/UW967BN0W6Op1515ms5d9DmNO3Zq3LZNd7z+9XrjipW6tTmit77ilRoPHFAteupn9uh1L3uJXrNsSn+09gjd/Y63adx2m8adO3XmU5/Ua04/RXc2GnrL7z1Juzdt1tjvqrbndMvHPqo/XL1cfzI9rZue+RyNt23TuHOf9n90jd7wsIfptmZdbz71ZD1w2WUaez2NrTm96rWv0Z8uX6Zbmg396SMfocVPrtZ421bd8fa3642rV+v2Zl2/d+QKLbfdVj2joGUM6jVo1CHuLu573/uq/hpj9rBwjqY5PkUcjCriPabfYbLfZzarM/2qV7LiT/8YXbkMVkwx8duPpXvyqbiojLTmwBeVhxVivUkYnSROLSNOTyETY5AZ5
2021-05-18 11:13:07 +08:00
},
"metadata": {
"needs_background": "light"
}
}
2021-08-25 16:41:07 +08:00
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 146
},
"id": "k3s27QIGQCnT",
2022-03-21 19:38:35 +08:00
"outputId": "ccf798dc-2934-468f-e346-a051bbf97612"
2021-08-25 16:41:07 +08:00
}
2021-05-18 11:13:07 +08:00
}
]
}