{"action":"closed","issue":{"url":"https://api.github.com/repos/endernewton/tf-faster-rcnn/issues/123","repository_url":"https://api.github.com/repos/endernewton/tf-faster-rcnn","labels_url":"https://api.github.com/repos/endernewton/tf-faster-rcnn/issues/123/labels{/name}","comments_url":"https://api.github.com/repos/endernewton/tf-faster-rcnn/issues/123/comments","events_url":"https://api.github.com/repos/endernewton/tf-faster-rcnn/issues/123/events","html_url":"https://github.com/endernewton/tf-faster-rcnn/issues/123","id":234485647,"number":123,"title":"How to add conditions to Faster RCNN region proposal function?","user":{"login":"hadi-ghnd","id":24352869,"avatar_url":"https://avatars0.githubusercontent.com/u/24352869?v=3","gravatar_id":"","url":"https://api.github.com/users/hadi-ghnd","html_url":"https://github.com/hadi-ghnd","followers_url":"https://api.github.com/users/hadi-ghnd/followers","following_url":"https://api.github.com/users/hadi-ghnd/following{/other_user}","gists_url":"https://api.github.com/users/hadi-ghnd/gists{/gist_id}","starred_url":"https://api.github.com/users/hadi-ghnd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hadi-ghnd/subscriptions","organizations_url":"https://api.github.com/users/hadi-ghnd/orgs","repos_url":"https://api.github.com/users/hadi-ghnd/repos","events_url":"https://api.github.com/users/hadi-ghnd/events{/privacy}","received_events_url":"https://api.github.com/users/hadi-ghnd/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-06-08T10:44:35Z","updated_at":"2017-06-09T04:02:16Z","closed_at":"2017-06-09T04:02:16Z","body":"I'm trying to add 2 or 3 simple conditions (**if statement**) to the faster_RCNN network structure so it would produce less regions based on these conditions. I don't know how the entire code works exactly and I just wanted to know where (**which file**) exactly am I supposed to add the conditions.\r\n\r\nThere is  **prepare_roidb** function in **tf-faster-rcnn/lib/roidb.py** file, where the sizes of rois are defined:\r\n```\r\ndef prepare_roidb(imdb):\r\n  \"\"\"Enrich the imdb's roidb by adding some derived quantities that\r\n  are useful for training. This function precomputes the maximum\r\n  overlap, taken over ground-truth boxes, between each ROI and\r\n  each ground-truth box. The class with maximum overlap is also\r\n  recorded.\r\n  \"\"\"\r\n  roidb = imdb.roidb\r\n  if not (imdb.name.startswith('coco')):\r\n    sizes = [PIL.Image.open(imdb.image_path_at(i)).size\r\n         for i in range(imdb.num_images)]\r\n  for i in range(len(imdb.image_index)):\r\n    roidb[i]['image'] = imdb.image_path_at(i)\r\n    if not (imdb.name.startswith('coco')):\r\n      roidb[i]['width'] = sizes[i][0]\r\n      roidb[i]['height'] = sizes[i][1]\r\n      ...\r\n```\r\n\r\nAlso there is the **filter_roidb** function in **tf-faster-rcnn/lib/model/train_val.py** file which is like this:\r\n\r\n```\r\ndef filter_roidb(roidb):\r\n  \"\"\"Remove roidb entries that have no usable RoIs.\"\"\"\r\n\r\n  def is_valid(entry):\r\n    %# Valid images have:\r\n    %#   (1) At least one foreground RoI OR\r\n    %#   (2) At least one background RoI\r\n    overlaps = entry['max_overlaps']\r\n    %# find boxes with sufficient overlap\r\n    fg_inds = np.where(overlaps >= cfg.TRAIN.FG_THRESH)[0]\r\n    %# Select background RoIs as those within [BG_THRESH_LO, BG_THRESH_HI)\r\n    bg_inds = np.where((overlaps < cfg.TRAIN.BG_THRESH_HI) &\r\n                       (overlaps >= cfg.TRAIN.BG_THRESH_LO))[0]\r\n    %# image is only valid if such boxes exist\r\n    valid = len(fg_inds) > 0 or len(bg_inds) > 0\r\n    return valid\r\n\r\n  num = len(roidb)\r\n  filtered_roidb = [entry for entry in roidb if is_valid(entry)]\r\n  num_after = len(filtered_roidb)\r\n  print('Filtered {} roidb entries: {} -> {}'.format(num - num_after,\r\n                                                     num, num_after))\r\n  return filtered_roidb\r\n```\r\nI want to define some conditions so that it won't produce any regions with width or height more than a value like **max_length**. I don't know where exactly I should add these conditions.\r\n\r\n\r\n"}}
{"actor":{"display_login":"endernewton"}}