pytorch-openpose
pytorch-openpose copied to clipboard
run error for body.py
hi, when run the body.py ,meet follow error
body.py:121: RuntimeWarning: invalid value encountered in true_divide
vec = np.divide(vec, norm)
Traceback (most recent call last):
File "body.py", line 217, in
also when i use pyton2.7 pytorch 0.40
Traceback (most recent call last):
File "body.py", line 218, in
do you have any advice , thanks!
Try below in body.py:
vec = np.subtract(candB[j][:2], candA[i][:2])
norm = math.sqrt(vec[0] * vec[0] + vec[1] * vec[1])
#to solve the DIVISION BY ZERO, I did this trick, but not sure if is correct
if norm == 0:
norm = 0.1
vec = np.divide(vec, norm)
or add the search scale:
# scale_search = [0.5, 1.0, 1.5, 2.0]
scale_search = [0.5]
Anybody should run demo.py successfully using the demo.jpg.
I added this but nothing changed. Still getting same error
@ehartz01 plz give me a test image.
Thanks for your reply @Hzzone Below is the output to terminal:
ny idea what's happening?
SED-ML-0148% python demo1.py Traceback (most recent call last): File "demo1.py", line 17, in candidate, subset = body_estimation(oriImg) File "python/body.py", line 46, in call Mconv7_stage6_L1, Mconv7_stage6_L2 = self.model(data) File "/Users/ehartz01/Desktop/SignPhonologizer/nicey/lib/python2.7/site-packages/torch/nn/modules/module.py", line 489, in call result = self.forward(*input, **kwargs) File "python/model.py", line 108, in forward out1 = self.model0(x) File "/Users/ehartz01/Desktop/SignPhonologizer/nicey/lib/python2.7/site-packages/torch/nn/modules/module.py", line 489, in call result = self.forward(*input, **kwargs) File "/Users/ehartz01/Desktop/SignPhonologizer/nicey/lib/python2.7/site-packages/torch/nn/modules/container.py", line 92, in forward input = module(input) File "/Users/ehartz01/Desktop/SignPhonologizer/nicey/lib/python2.7/site-packages/torch/nn/modules/module.py", line 489, in call result = self.forward(*input, **kwargs) File "/Users/ehartz01/Desktop/SignPhonologizer/nicey/lib/python2.7/site-packages/torch/nn/modules/conv.py", line 320, in forward self.padding, self.dilation, self.groups) RuntimeError: Given groups=1, weight of size [256, 512, 3, 3], expected input[1, 3, 46, 32] to have 512 channels, but got 3 channels instead
@ehartz01 plz use python 3+.
Thank you! This fixed the error. From the demo.py file I'm able to get the hand keypoints, but I'm struggling to understand where to get the body keypoints from -- can you help me out?
@ehartz01
Read the code and comments of body.py:
# subset: n*20 array, 0-17 is the index in candidate, 18 is the total score, 19 is the total parts
# candidate: x, y, score, id
return candidate, subset
There are all body keypoints in candidate
while subset
indicates which part the single keypoint is. You may have a look at body.py and try to run it by yourself.
Hi @Hzzone! Thanks for easy to install openpose pytorch model. Regarding this issue, I also have ZeroDivisionError when I run with demo.py with ski.jpg and some other images that I tested with.
body.py:122: RuntimeWarning: invalid value encountered in true_divide vec = np.divide(vec, norm) Traceback (most recent call last): File "body.py", line 217, in <module> candidate, subset = body_estimation(oriImg) File "body.py", line 134, in __call__ 0.5 * oriImg.shape[0] / norm - 1, 0) ZeroDivisionError: float division by zero
Though, uncommenting scale_search = [0.5, 1.0, 1.5, 2.0] seems to work. Would you consider fixing this part?
Thank you!
hi, when running the body.py, meet follow error File
"body.py", line 134, in call
0.5 * oriImg.shape[0] / norm - 1, 0)
ZeroDivisionError: float division by zero
to slove the error ,i adopted your advice
vec = np.subtract(candB[j][:2], candA[i][:2])
norm = math.sqrt(vec[0] * vec[0] + vec[1] * vec[1])
if norm == 0:
norm = 0.1
vec = np.divide(vec, norm)
but the output canvas image is diffrent from your project's .why?Apart from the above changes, I have never modified the code again
same error
@Hzzone I used this trick to add norm = 1.1 if norm ==0, and it worked