Closed MuhammadAsadJaved closed 3 years ago
Hi, Can you please adjust the code for running demo on video inputs?
Thanks
hello, you can change the function test_MBNet()
in MBNetModel.py
a little to show the video demo:
def test_MBNet(self,opt, data_path,val_data, weight_path):
self.model_all.load_weights(weight_path, by_name=True)
print ('load weights from {}'.format(weight_path))
val_data.sort(reverse =False)
for f in range(len(val_data)):
img_name = os.path.join(data_path,val_data[f])
if not img_name.lower().endswith(('.jpg', '.png')):
continue
print(img_name)
img = cv2.imread(img_name)
img_name_lwir = os.path.join(data_path[:-7]+'lwir', val_data[f][:-11]+'lwir.png')
print(img_name_lwir)
img_lwir = cv2.imread(img_name_lwir)
start_time = time.time()
x_in = bbox_process.format_img(img, opt)
x_in_lwir = bbox_process.format_img(img_lwir, opt)
Y = self.model_all.predict([x_in,x_in_lwir])
proposals = bbox_process.pred_pp_1st(self.anchors, Y[0], Y[1], opt)
bbx, scores = bbox_process.pred_det(proposals, Y[2], Y[3], opt, step=2)
print ('Test time: %.4f s' % (time.time() - start_time))
for ind in range(len(bbx)):
if scores[ind][0] < 0.5:
continue
(x1, y1, x2, y2) = bbx[ind, :]
cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2)
# cv2.putText(img, str(scores[ind][0]), (x1, y1), cv2.FONT_HERSHEY_COMPLEX, 0.3, (0, 0, 255), 1)
cv2.rectangle(img_lwir, (x1, y1), (x2, y2), (0, 255, 0), 2)
# cv2.putText(img_lwir, str(scores[ind][0]), (x1, y1), cv2.FONT_HERSHEY_COMPLEX, 0.3, (0, 0, 255), 1)
img_concat = np.concatenate([img, img_lwir], axis=1)
cv2.imshow("img_concat",img_concat)
cv2.waitKey(10)
then python test.py
and the video demo will be shown.
@CalayZhou Hi dear, I think your suggested program is still for the images as your input is image sequences. I have changed the script for the video demo and also added demo_video.py accordingly. I have sent you a pull request, please review it and approve if it's useful.
@MuhammadAsadJaved I think demo_video.py
is reasonable and helpful, i have merged it with the MBNet-master
, Thanks for your contribution.
Hi, Can you please adjust the code for running demo on video inputs?
Thanks