hourglasstensorflow
hourglasstensorflow copied to clipboard
test on single image
hi, Very interesting work!
I just modified your PredictProcessor().mpeWebcam() to test your model on single image. I only replace the inputs form video to single image, and nothing else. It appears to me that the YOLO works well and can find where the person is, but the skeletons can not be detected, or all with very low confidence (<0.1). Do you have a similar issue or can you update a script for testing on single image?
Thanks
Hi,
Are you using the pretrained model? I manage skeleton detection with a joint threshold (j_thresh) around 0.4 for very likely body parts and 0.25-0.3 for less common pose. I can make a method for multi person detection on single images. Give me a day or two
I've tried hpe with your last hourglass_bn_100 but seems that doesn't work. I've used on or two image from the dataset.
Yes, I used the hourglass_bn_100 model
I‘ve just fixed this problem. I give exactly the same inputs as in the training phase, and I got reasonable results. Thanks
@daodaofr I encountered the same problem, and my image size is 720*1280,and the yolo also works bad,how do you solve this problem? thanks
@felixfuu
I didn't use large images, nor did I use yolo.
I just test the model on LSP dataset, where the persons are well cropped. The model seems working fine.
I've encountered the same problem with hourglass_bn_100 and got a strange result with low confidences
What can be the problem?
@daodaofr Could you please share your prediction code with us? I just use the hg_refined_200 model and inference.py but skeletons can not be detected.
@qqsh0214 Could you please share your prediction code with us? thx
@luohuan2uestc To test on single image, you can change hpeWebcam function in predictClass.py as follow: `rootdir = './images_lip/' images = os.listdir(rootdir) count = 0 for image in images: count += 1 t = time() img = cv2.imread(rootdir + str(image)) sp = img.shape img_hg = cv2.resize(img, (256,256)) img_res = cv2.resize(img, (256,256)) img_hg = cv2.cvtColor(img_hg, cv2.COLOR_BGR2RGB) hg = self.HG.Session.run(self.HG.pred_sigmoid, feed_dict = {self.HG.img: np.expand_dims(img_hg/255, axis = 0)}) j = np.ones(shape = (self.params['num_joints'],2)) * -1 if plt_hm: hm = np.sum(hg[0], axis = 2) hm = np.repeat(np.expand_dims(hm, axis = 2), 3, axis = 2) hm = cv2.resize(hm, (sp[0],sp[1])) img_res = img_res / 255 + hm for i in range(len(j)): idx = np.unravel_index( hg[0,:,:,i].argmax(), (64,64)) j[i] = np.asarray(idx) * 256 / 64 cv2.circle(img_res, center = tuple(j[i].astype(np.int))[::-1], radius= 5, color= self.color[i][::-1], thickness= -1) if plt_l: for i in range(len(self.links)): l = self.links[i]['link'] good_link = True for p in l: if np.array_equal(j[p], [-1,-1]): good_link = False if good_link: pos = self.givePixel(l, j) cv2.line(img_res, tuple(pos[0])[::-1], tuple(pos[1])[::-1], self.links[i]['color'][::-1], thickness = 5) fps = 1/(time()-t) if debug: framerate.append(fps) cv2.putText(img_res, 'FPS: ' + str(fps)[:4], (60, 40), 2, 2, (0,0,0), thickness = 2) cv2.imwrite('./result/' + str(count) + '.jpg', img_res) if count == 100: break
`
I was able to test the model on a single image but the results I am getting are inaccurate. Can you please help me with this?
Your help will be highly appreciated.
@luohuan2uestc To test on single image, you can change hpeWebcam function in predictClass.py as follow:
rootdir = './images_lip/' images = os.listdir(rootdir) count = 0 for image in images: count += 1 t = time() img = cv2.imread(rootdir + str(image)) sp = img.shape img_hg = cv2.resize(img, (256,256)) img_res = cv2.resize(img, (256,256)) img_hg = cv2.cvtColor(img_hg, cv2.COLOR_BGR2RGB) hg = self.HG.Session.run(self.HG.pred_sigmoid, feed_dict = {self.HG.img: np.expand_dims(img_hg/255, axis = 0)}) j = np.ones(shape = (self.params['num_joints'],2)) * -1 if plt_hm: hm = np.sum(hg[0], axis = 2) hm = np.repeat(np.expand_dims(hm, axis = 2), 3, axis = 2) hm = cv2.resize(hm, (sp[0],sp[1])) img_res = img_res / 255 + hm for i in range(len(j)): idx = np.unravel_index( hg[0,:,:,i].argmax(), (64,64)) j[i] = np.asarray(idx) * 256 / 64 cv2.circle(img_res, center = tuple(j[i].astype(np.int))[::-1], radius= 5, color= self.color[i][::-1], thickness= -1) if plt_l: for i in range(len(self.links)): l = self.links[i]['link'] good_link = True for p in l: if np.array_equal(j[p], [-1,-1]): good_link = False if good_link: pos = self.givePixel(l, j) cv2.line(img_res, tuple(pos[0])[::-1], tuple(pos[1])[::-1], self.links[i]['color'][::-1], thickness = 5) fps = 1/(time()-t) if debug: framerate.append(fps) cv2.putText(img_res, 'FPS: ' + str(fps)[:4], (60, 40), 2, 2, (0,0,0), thickness = 2) cv2.imwrite('./result/' + str(count) + '.jpg', img_res) if count == 100: break
sorry.Do you remember how the problem was solved?