title: Custom object segmentation training with detectron2
body: <p>I have used the detectron2 to train a custom model using the polygon segmentation code. The code reads as -</p>
  <pre><code>for anno in annos:
    px = [a[0] for a in anno['points']] # x coord
    py = [a[1] for a in anno['points']] # y-coord
    poly = [(x, y) for x, y in zip(px, py)] # poly for segmentation
    poly = [p for x in poly for p in x]
  </code></pre>
  <p>I need to change this to circle. I have annonated the images using labelme and i get 4 values in the JSON file, first and second are center of circle and third and fourth are a random point on the circle.</p>
  <pre><code>&quot;points&quot;: [
          [
            819.3766233766233,  // x1
            302.5064935064935,   // y1 
            662.2337662337662, //x2
            123.2857142857143  //y2
          ]
        ],
  </code></pre>
  <p>This is what i coded</p>
  <pre><code>for anno in annos:
            px1 = [a[0] for a in anno['points']] # x1 coord
            py1 = [a[1] for a in anno['points']] # y1-coord
            px2 = [a[2] for a in anno['points']] # x2 coord
            py2 = [a[3] for a in anno['points']] # y2-coord
            
            # calculate the distance between the two points as radius
            radius = np.sqrt((px2 - px1)**2 + (py2 - py1)**2)
  
            # center of the circle is px1,py1 and radius is radius
            circle = plt.Circle((px1,py1), radius)
  
            obj = {
              &quot;bbox&quot;: [np.min(px1), np.min(py1), np.max(px2), np.max(py2)],
              &quot;bbox_mode&quot;: BoxMode.XYXY_ABS,
              &quot;segmentation&quot;: [circle],
              &quot;category_id&quot;: classes.index(anno['label']),
              &quot;iscrowd&quot;: 0
          }
  </code></pre>
  <p>The error i am getting is while training -</p>
  <pre><code>/usr/local/lib/python3.7/dist-packages/detectron2/data/build.py in get_detection_dataset_dicts(names, filter_empty, min_keypoints, proposal_files, check_consistency)
      240     dataset_dicts = [DatasetCatalog.get(dataset_name) for dataset_name in names]
      241     for dataset_name, dicts in zip(names, dataset_dicts):
  --&gt; 242         assert len(dicts), &quot;Dataset '{}' is empty!&quot;.format(dataset_name)
      243 
      244     if proposal_files is not None:
  
  AssertionError: Dataset 'category_train' is empty!
  </code></pre>
  <p>Can someone pls help.Thanks</p>