Skip to content
\n

Then I used the following script to fine-tune the given layout detection model:

\n
import os\nimport deepdoctection as dd\n\n_NAME = \"dataset\"\n_DESCRIPTION = \"Labeled images\"\n_SPLITS = {\"train\": \"/train\"}\n_CATEGORIES = [\"figure\", \"list\", \"table\", \"text\", \"title\"]\n_LOCATION = \"dataset\"\n_ANNOTATION_FILES = {\"train\": \"train.json\"}\n\n\nclass CustomDataFlowBuilder(dd.DataFlowBaseBuilder):\n    def build(self, **kwargs):\n        path = self.get_workdir() / _ANNOTATION_FILES[\"train\"]\n        df = dd.SerializerCoco.load(path)\n        coco_mapper = dd.coco_to_image(\n            self.categories.get_categories(init=True), load_image=True,\n            filter_empty_image=True, fake_score=False)\n        df = dd.MapData(df, coco_mapper)\n        return df\n\n\nclass CustomDataset(dd.DatasetBase):\n    @classmethod\n    def _info(cls):\n        return dd.DatasetInfo(name=_NAME, description=_DESCRIPTION, splits=_SPLITS)\n\n    def _categories(self):\n        return dd.DatasetCategories(init_categories=_CATEGORIES)\n\n    def _builder(self):\n        return CustomDataFlowBuilder(location=_LOCATION, annotation_files=_ANNOTATION_FILES)\n\n\ncfg = dd.set_config_by_yaml(\"path/to/conf_dd_one.yaml\")\n\ndataset = CustomDataset()\n\nconfig_yaml_path = dd.ModelCatalog.get_full_path_configs(cfg.CONFIG.D2LAYOUT)\nweights_path = dd.ModelCatalog.get_full_path_weights(cfg.WEIGHTS.D2LAYOUT)\ncategories = dd.ModelCatalog.get_profile(cfg.WEIGHTS.D2LAYOUT).categories\nlayout_detector = dd.D2FrcnnDetector(config_yaml_path, weights_path, categories, device=cfg.DEVICE)\nlayout_service = dd.ImageLayoutService(layout_detector)\n\ncoco_metric = dd.get_metric(\"coco\")\n\nconfig_overwrite=[\"SOLVER.MAX_ITER=100000\",\n                  \"TEST.EVAL_PERIOD=20000\",\n                  \"SOLVER.CHECKPOINT_PERIOD=20000\",\n                  \"MODEL.BACKBONE.FREEZE_AT=0\",\n                  \"SOLVER.BASE_LR=1e-3\"]\n\nbuild_train_config = [\"max_datapoints=86000\"]\n\ndd.train_d2_faster_rcnn(\n    path_config_yaml=config_yaml_path,\n    dataset_train=dataset,\n    path_weights=weights_path,\n    config_overwrite=config_overwrite,\n    log_dir=\"train_log\",\n    build_train_config=build_train_config,\n    dataset_val=dataset,\n    build_val_config=None,\n    metric=coco_metric,\n    pipeline_component_name=\"ImageLayoutService\")
\n

Here is my conf_dd_one.yaml:

\n
CONFIG:\n  D2LAYOUT: dd/d2/layout/CASCADE_RCNN_R_50_FPN_GN.yaml\n  D2CELL: dd/d2/cell/CASCADE_RCNN_R_50_FPN_GN.yaml\n  D2ITEM: dd/d2/item/CASCADE_RCNN_R_50_FPN_GN.yaml\nWEIGHTS:\n  D2LAYOUT: layout/d2_model_0829999_layout_inf_only.pt\n  D2CELL: cell/d2_model_1849999_cell_inf_only.pt\n  D2ITEM: item/d2_model_1639999_item_inf_only.pt\nLAYOUT_NMS_PAIRS:\n  COMBINATIONS:\n    - - text\n      - table\n    - - title\n      - table\n    - - text\n      - list\n    - - title\n      - list\n    - - text\n      - title\n    - - list\n      - table\n  THRESHOLDS:\n    - 0.005\n    - 0.005\n    - 0.542\n    - 0.1\n    - 0.699\n    - 0.01\nSEGMENTATION:\n  ASSIGNMENT_RULE: ioa\n  IOA_THRESHOLD_ROWS: 0.4\n  IOA_THRESHOLD_COLS: 0.4\n  IOU_THRESHOLD_ROWS: 0.01\n  IOU_THRESHOLD_COLS: 0.001\n  REMOVE_IOU_THRESHOLD_ROWS: 0.001\n  REMOVE_IOU_THRESHOLD_COLS: 0.001\n  FULL_TABLE_TILING: True\n  STRETCH_RULE: left\n  USE_REFINEMENT: False\nWORD_MATCHING:\n  PARENTAL_CATEGORIES:\n    - text\n    - title\n    - cell\n    - list\n    - figure\n  CHILD_CATEGORIES:\n    - word\n  RULE: ioa\n  IOA_THRESHOLD: 0.6\n  IOU_THRESHOLD: 0.001\n  MAX_PARENT_ONLY: False\nTEXT_ORDERING:\n  TEXT_CONTAINER: word\n  FLOATING_TEXT_BLOCK:\n    - title\n    - text\n    - list\n    - figure\n  TEXT_BLOCK:\n    - title\n    - text\n    - list\n    - cell\n    - figure\n    - header\n    - body\n  TEXT_CONTAINER_TO_TEXT_BLOCK: True\nDEVICE: cuda
\n

However, when I run the script, it kind of freezes at Starting training from iteration 0. I have 2 Nvidia Quadros. watch -n 1 nvidia-smi shows that the GPUs are not utilized. Though top shows that CPU usage is at 100%. Is this performance normal?

","upvoteCount":1,"answerCount":2,"acceptedAnswer":{"@type":"Answer","text":"

Check #162 for CUDA OOM

","upvoteCount":0,"url":"https://github.com/deepdoctection/deepdoctection/discussions/160#discussioncomment-6239210"}}}

Training speed with dd.train_d2_faster_rcnn() #160

Answered by JaMe76
yflam1 asked this question in Q&A
Discussion options

You must be logged in to vote

Check #162 for CUDA OOM

Replies: 2 comments 10 replies

Comment options

You must be logged in to vote
7 replies
@yflam1
Comment options

@JaMe76
Comment options

@yflam1
Comment options

@JaMe76
Comment options

Answer selected by yflam1
Comment options

You must be logged in to vote
3 replies
@JaMe76
Comment options

@ShivaGurrala94
Comment options

@JaMe76
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants