detections.append(landmark32) detections.append(cls16) detections.append(bbox16) detections.append(landmark16) detections.append(cls8) detections.append(bbox8) detections.append(landmark8) return detections net = RetinaFace_MobileNet() net.cuda() from torchsummary import summary summary(net, input_size=(3, 640, 640)) import pdb pdb.set_trace() img_dim = 640 input_size = (1, 3, img_dim, img_dim) img = torch.FloatTensor(input_size[0], input_size[1], input_size[2], input_size[3]) net = add_flops_counting_methods(net) net.start_flops_count() feat = net(img) faceboxes_flops = net.compute_average_flops_cost() print('Net Flops: {}'.format(flops_to_string(faceboxes_flops))) print('Net Params: ' + get_model_parameters_number(net))
img_save_name = "1_Handshaking_Handshaking_1_579_result_epoch.jpg" use_cuda = True img_origin = np.float32(cv2.imread(img_name, cv2.IMREAD_COLOR)) net = CenterFace(phase='test', cfg=net_cfg) # flops and params estimation img_dim = 640 input_size = (1, 3, img_dim, img_dim) img = torch.FloatTensor(input_size[0], input_size[1], input_size[2], input_size[3]) net = add_flops_counting_methods(net) net.start_flops_count() feat = net(img) flops = net.compute_average_flops_cost() print('Net Flops: {}'.format(flops_to_string(flops))) print('Net Params: ' + get_model_parameters_number(net)) # load model net = load_model(net, trained_model) net.eval() print('Finished loading model!') # preprocess image resize = 1600 / img_origin.shape[0] img = cv2.resize(img_origin, None, None, fx=resize, fy=resize, interpolation=cv2.INTER_LINEAR) im_height, im_width, _ = img.shape scale = torch.Tensor([img.shape[1], img.shape[0], img.shape[1], img.shape[0]]) img -= (104, 117, 123) img = img.transpose(2, 0, 1) img = torch.from_numpy(img).unsqueeze(0) if use_cuda: img = img.cuda()