-
Csaba Botos authored
* Remove Detectron dependency I have looked into the boxes.py to swap [these lines](https://github.com/facebookresearch/Detectron/blob/8170b25b425967f8f1c7d715bea3c5b8d9536cd8/detectron/utils/boxes.py#L51L52): ``` import detectron.utils.cython_bbox as cython_bbox import detectron.utils.cython_nms as cython_nms ``` ``` from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou from maskrcnn_benchmark.structures.boxlist_ops import boxlist_nms ``` However some functions are missing from the `boxlist_ops` like the [`soft_nms`](https://github.com/facebookresearch/Detectron/blob/master/detectron/utils/cython_nms.pyx#L98L203) . So I just tried to modify the `maskrcnn-benchmark/tools/cityscapes/convert_cityscapes_to_coco.py` script. Here we have `polys_to_boxes` function from `segms.py` and I could not find its analogous in the maskrcnn_benchmark lib. It seems to me that the original function in `segms.py` is using pure lists so I just wrote two auxiliary functions reusing the boxList's convert method( https://github.com/facebookresearch/maskrcnn-benchmark/blob/master/maskrcnn_benchmark/structures/bounding_box.py#L67L70 ) and Detectron's polys_to_boxes ( https://github.com/facebookresearch/Detectron/blob/b5dcc0fe1d091cb70f9243939258215dd63e3dfa/detectron/utils/segms.py#L135L140 ): ``` def poly_to_box(poly): """Convert a polygon into a tight bounding box.""" x0 = min(min(p[::2]) for p in poly) x1 = max(max(p[::2]) for p in poly) y0 = min(min(p[1::2]) for p in poly) y1 = max(max(p[1::2]) for p in poly) box_from_poly = [x0, y0, x1, y1] return box_from_poly def xyxy_to_xywh(xyxy_box): xmin, ymin, xmax, ymax = xyxy_box TO_REMOVE = 1 xywh_box = (xmin, ymin, xmax - xmin + TO_REMOVE, ymax - ymin + TO_REMOVE) return xywh_box ``` * removed leftovers * Update convert_cityscapes_to_coco.py
0f9476bd
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
convert_cityscapes_to_coco.py | ||
instances2dict_with_polygons.py |