Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bbox_vote funtion problem #17

Closed
Spiralpill opened this issue Apr 8, 2019 · 4 comments
Closed

bbox_vote funtion problem #17

Spiralpill opened this issue Apr 8, 2019 · 4 comments

Comments

@Spiralpill
Copy link

你好
我在運行demo.py時,出現了錯誤:

Traceback (most recent call last):
  File "demo.py", line 252, in <module>
    test_oneimage()
  File "demo.py", line 245, in test_oneimage
    det = bbox_vote(det)
  File "demo.py", line 73, in bbox_vote
    det_accu_sum[:, 0:4] = np.sum(det_accu[:, 0:4], axis=0) / np.sum(det_accu[:, -1:])
  File "/usr/local/lib/python3.6/dist-packages/torch/tensor.py", line 367, in __rdiv__
    return self.reciprocal() * other
TypeError: mul(): argument 'other' (position 1) must be Tensor, not numpy.ndarray

我於前一行查看了det_accu:

print(det_accu)
[[884.7191162109375 687.6126098632812 996.62158203125 823.8545532226562
  0.9999959468841553]
 [884.49133 687.3231 996.8358 823.6817 tensor(1.0000)]
 [884.73834 686.1709 996.74756 822.86896 tensor(1.0000)]]

錯誤是否與det_accu[0]有關?
如果有關,這錯誤怎麼產生?
我該如何處理這問題?

@Spiralpill
Copy link
Author

查看det_accu結果修正為:

print(det_accu)
[[884.7155303418695 687.6098228897172 996.6175426085247 823.8512140447128
  0.9999959468841553]
 [tensor(884.4860) tensor(687.3190) tensor(996.8298) tensor(823.6767)
  tensor(1.0000)]
 [tensor(884.7256) tensor(686.1610) tensor(996.7332) tensor(822.8571)
  tensor(1.0000)]]

@oyerst
Copy link

oyerst commented Apr 8, 2019

add 'score = score.cpu().numpy' after score definition.

@Spiralpill
Copy link
Author

Thank oyerst, You solved my problem.
Answer:

while detections[0, i, j, 0] >= thresh:
                score = detections[0, i, j, 0]
                score = score.cpu().numpy()  #Plus here
                pt = (detections[0, i, j, 1:]*scale).cpu().numpy()
                coords = (pt[0], pt[1], pt[2], pt[3]) 
                det.append([pt[0], pt[1], pt[2], pt[3], score])
                j += 1

@Spiralpill
Copy link
Author

Spiralpill commented Apr 22, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants