def ElaborateImagesAndMakePredition(self, inp_img): # crop a good percentage of the image in order to gain performances. found a good tradeoff with those values start_time = time.time() img_data_pipelined = FaceExtractionPipeline.SingletonPipeline( ).FaceExtractionPipelineImage( inp_img, math.ceil(np.shape(inp_img)[0] * 20 / 100), math.ceil(np.shape(inp_img)[0] * 40 / 100)) if img_data_pipelined is not None: # plt.imshow(img_data_pipelined, 'gray') # plt.show() inp = LoadData.MergeImages(self.ref_img, img_data_pipelined) inp = np.expand_dims(inp, axis=0) #with self.graph.as_default(): predicted_label = self.model.predict(inp) print(('same' if predicted_label[0, 1] > 0.975 else 'wrong') + str(predicted_label)) return True, predicted_label[0, 1] else: return False, 0 print("--- %s seconds for a frame---" % (time.time() - start_time))