tjiiv-cprg / EPro-PnP

[CVPR 2022 Oral, Best Student Paper] EPro-PnP: Generalized End-to-End Probabilistic Perspective-n-Points for Monocular Object Pose Estimation

Home Page:https://www.youtube.com/watch?v=TonBodQ6EUU

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

xywh_to_xyxy() crashes if 'xywh' is a numpy array: 'NameError: name 'xyxy' is not defined' (proposed fix included)

petrock99 opened this issue · comments

xywh_to_xyxy() crashes if 'xywh' is a numpy array: 'NameError: name 'xyxy' is not defined' (proposed fix included)

Python 3.6.13 with same packages as in the EPro-PnP-6PoF README.md

If I pass a numpy array to xywh_to_xyxy() it will crash with an 'NameError: name 'xyxy' is not defined' exception:

  File ".../EPro-PnP/EPro-PnP-6DoF/tools/../lib/utils/img.py", line 103, in xywh_to_xyxy
    if len(xyxy.shape) == 1:
NameError: name 'xyxy' is not defined

I tried to create a PR, but GitHub wouldn't let me. Here is a proposed fix:

diff --git a/EPro-PnP-6DoF/lib/utils/img.py b/EPro-PnP-6DoF/lib/utils/img.py
index 3921598..9396b53 100644
--- a/EPro-PnP-6DoF/lib/utils/img.py
+++ b/EPro-PnP-6DoF/lib/utils/img.py
@@ -100,13 +100,13 @@ def xywh_to_xyxy(xywh):
         y2 = xywh[3] + y1
         return (x1, y1, x2, y2)
     elif isinstance(xywh, np.ndarray):
-        if len(xyxy.shape) == 1:
+        if len(xywh.shape) == 1:
             assert len(xywh) == 4
             x1, y1 = xywh[0], xywh[1]
             x2 = xywh[2] + x1
             y2 = xywh[3] + y1
             return (x1, y1, x2, y2)
-        elif len(xyxy.shape) == 2:
+        elif len(xywh.shape) == 2:
             return np.hstack((xywh[:, 0:2], xywh[:, 2:4] + xywh[:, 0:2]))
         else:
             raise

Thank you for your contribution. I'm not sure why PR is not working. I may look into the your proposed fix later, although I do not expect to revise the code of the CDPN network.

Btw, we do not recommend using the CDPN network directly for other applications, as we have not fully optimized the architecture and hyper parameters for EPro-PnP (since it's mostly used for comparison with the baseline in the paper). In fact we recently noted a design fault related to the global weight scale. An improved version with extended paper and code will be released in a few weeks.