{
  "id": 111402,
  "title": "YOLO v3 anchors selection",
  "url": "/competitions/kuzushiji-recognition/discussion/111402",
  "author_name": "Aravind Raju",
  "post_date": "2019-10-05T11:28:18.612000",
  "votes": 2,
  "comment_count": 0,
  "views": 0,
  "content": "<p>Hi,\nCan someone please confirm if the below method is the right way to select anchors in YOLO</p>\n\n<p>yolo_image_width = 544 # multiple of 32\nyolo_image_height = 544</p>\n\n<p>n = cv2.imread(img_path+train.image_id[i]+'.jpg')\ndf['width'] = df.width / n.shape[0] * yolo_image_width\ndf['height'] = df.height / n.shape[0] * yolo_image_height</p>\n\n<p>kmeans = KMeans(n_clusters=9, random_state=0).fit(df)\ncluster = pd.DataFrame(data=kmeans.cluster_centers_, columns=['width', 'height'])\ncluster = cluster.round()\ncluster['area'] =  cluster.width * cluster.height\ncluster.sort_values('area')\nwidth  height   area\n7.0     9.0   63.0\n8.0    15.0  120.0\n13.0    11.0  143.0\n7.0    22.0  154.0\n18.0    14.0  252.0\n14.0    18.0  252.0\n16.0    25.0  400.0\n21.0    20.0  420.0\n25.0    36.0  900.0</p>\n\n<p>Thanks</p>",
  "messages": [
    {
      "id": 641959,
      "postDate": "2019-10-05T11:28:18.613Z",
      "content": "<p>Hi,\nCan someone please confirm if the below method is the right way to select anchors in YOLO</p>\n\n<p>yolo_image_width = 544 # multiple of 32\nyolo_image_height = 544</p>\n\n<p>n = cv2.imread(img_path+train.image_id[i]+'.jpg')\ndf['width'] = df.width / n.shape[0] * yolo_image_width\ndf['height'] = df.height / n.shape[0] * yolo_image_height</p>\n\n<p>kmeans = KMeans(n_clusters=9, random_state=0).fit(df)\ncluster = pd.DataFrame(data=kmeans.cluster_centers_, columns=['width', 'height'])\ncluster = cluster.round()\ncluster['area'] =  cluster.width * cluster.height\ncluster.sort_values('area')\nwidth  height   area\n7.0     9.0   63.0\n8.0    15.0  120.0\n13.0    11.0  143.0\n7.0    22.0  154.0\n18.0    14.0  252.0\n14.0    18.0  252.0\n16.0    25.0  400.0\n21.0    20.0  420.0\n25.0    36.0  900.0</p>\n\n<p>Thanks</p>",
      "rawMarkdown": "Hi,\nCan someone please confirm if the below method is the right way to select anchors in YOLO\n\nyolo_image_width = 544 # multiple of 32\nyolo_image_height = 544\n\nn = cv2.imread(img_path+train.image_id[i]+'.jpg')\ndf['width'] = df.width / n.shape[0] * yolo_image_width\ndf['height'] = df.height / n.shape[0] * yolo_image_height\n\nkmeans = KMeans(n_clusters=9, random_state=0).fit(df)\ncluster = pd.DataFrame(data=kmeans.cluster_centers_, columns=['width', 'height'])\ncluster = cluster.round()\ncluster['area'] =  cluster.width * cluster.height\ncluster.sort_values('area')\nwidth  height   area\n7.0     9.0   63.0\n8.0    15.0  120.0\n13.0    11.0  143.0\n7.0    22.0  154.0\n18.0    14.0  252.0\n14.0    18.0  252.0\n16.0    25.0  400.0\n21.0    20.0  420.0\n25.0    36.0  900.0\n\nThanks",
      "votes": 2
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "641959": "Hi,\nCan someone please confirm if the below method is the right way to select anchors in YOLO\n\nyolo_image_width = 544 # multiple of 32\nyolo_image_height = 544\n\nn = cv2.imread(img_path+train.image_id[i]+'.jpg')\ndf['width'] = df.width / n.shape[0] * yolo_image_width\ndf['height'] = df.height / n.shape[0] * yolo_image_height\n\nkmeans = KMeans(n_clusters=9, random_state=0).fit(df)\ncluster = pd.DataFrame(data=kmeans.cluster_centers_, columns=['width', 'height'])\ncluster = cluster.round()\ncluster['area'] =  cluster.width * cluster.height\ncluster.sort_values('area')\nwidth  height   area\n7.0     9.0   63.0\n8.0    15.0  120.0\n13.0    11.0  143.0\n7.0    22.0  154.0\n18.0    14.0  252.0\n14.0    18.0  252.0\n16.0    25.0  400.0\n21.0    20.0  420.0\n25.0    36.0  900.0\n\nThanks"
  }
}