In [187]: ids=np.array([3,2,0,1])
In [188]: ious=np.array([0. , 0.65972222, 0.65972222])
In [189]: thresh=0.5
Тестирование where
:
In [190]: np.where(ious>thresh)
Out[190]: (array([1, 2]),)
In [191]: np.where(ious>thresh)[0]
Out[191]: array([1, 2])
In [192]: np.where(ious>[thresh])[0]
Out[192]: array([1, 2])
теперь concatenate
:
In [193]: np.concatenate([ids[-1]], np.where(ious > thresh)[0])
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-193-c71c05bfaf15> in <module>
----> 1 np.concatenate([ids[-1]], np.where(ious > thresh)[0])
TypeError: only integer scalar arrays can be converted to a scalar index
In [194]: np.concatenate([ids[-1], np.where(ious > thresh)[0]])
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-194-91ed414d6d7c> in <module>
----> 1 np.concatenate([ids[-1], np.where(ious > thresh)[0]])
ValueError: zero-dimensional arrays cannot be concatenated
In [195]: np.concatenate([[ids[-1]], np.where(ious > thresh)[0]])
Out[195]: array([1, 1, 2])
теперь delete
:
In [196]: np.delete(ids,np.concatenate([[ids[-1]], np.where(ious > thresh)[0]]))
Out[196]: array([3, 1])