You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.
defiou(box, clusters):
""" Calculates the Intersection over Union (IoU) between a box and k clusters. :param box: tuple or array, shifted to the origin (i. e. width and height) :param clusters: numpy array of shape (k, 2) where k is the number of clusters :return: numpy array of shape (k, 0) where k is the number of clusters """x=np.minimum(clusters[:, 0], box[0])
y=np.minimum(clusters[:, 1], box[1])
ifnp.count_nonzero(x==0) >0ornp.count_nonzero(y==0) >0:
raiseValueError("Box has no area")
intersection=x*ybox_area=box[0] *box[1]
cluster_area=clusters[:, 0] *clusters[:, 1]
iou_=intersection/ (box_area+cluster_area-intersection)
returniou_
Hi~ I think when u use '/' to calculate iou_ may have a bug.
For example, box = np.array([250, 200]),
clusters = np.array([[200, 200], [100, 200], [200, 100], [150, 200], [200, 150]]),
the output is [0, 0, 0, 0, 0]. Actually, it should be [0.8, 0.4, 0.4, 0.6, 0.6].
I think there are two methods to solve this bug.
One is setting boxes' & clusters' data type.
defiou(box, clusters):
""" Calculates the Intersection over Union (IoU) between a box and k clusters. :param box: tuple or array, shifted to the origin (i. e. width and height) :param clusters: numpy array of shape (k, 2) where k is the number of clusters :return: numpy array of shape (k, 0) where k is the number of clusters """x=np.minimum(clusters[:, 0], box[0])
y=np.minimum(clusters[:, 1], box[1])
ifnp.count_nonzero(x==0) >0ornp.count_nonzero(y==0) >0:
raiseValueError("Box has no area")
intersection=x*ybox_area=box[0] *box[1]
cluster_area=clusters[:, 0] *clusters[:, 1]
iou_=intersection/ (box_area+cluster_area-intersection)
returniou_
Hi~ I think when u use '/' to calculate iou_ may have a bug.
For example, box = np.array([250, 200]),
clusters = np.array([[200, 200], [100, 200], [200, 100], [150, 200], [200, 150]]),
the output is [0, 0, 0, 0, 0]. Actually, it should be [0.8, 0.4, 0.4, 0.6, 0.6].
I think there are two methods to solve this bug.
One is setting boxes' & clusters' data type.
Do u think so?
it may cause this error:
numpy.core._exceptions.UFuncTypeError: ufunc 'minimum' did not contain a loop with signature matching types (dtype('<U21'), dtype('<U21')) -> dtype('<U21')
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi~ I think when u use '/' to calculate iou_ may have a bug.
For example, box = np.array([250, 200]),
clusters = np.array([[200, 200], [100, 200], [200, 100], [150, 200], [200, 150]]),
the output is [0, 0, 0, 0, 0]. Actually, it should be [0.8, 0.4, 0.4, 0.6, 0.6].
I think there are two methods to solve this bug.
One is setting boxes' & clusters' data type.
The other is using np.true_divide() to calculate iou_.
Do u think so?
The text was updated successfully, but these errors were encountered: