@@ -89,16 +89,18 @@ def predictface():
8989
9090 else :
9191 return jsonify ({'similarity_percentage' : 'Could not detect faces in both images.' })
92-
93- @app .route ('/face_recognize_from_Urls' ,methods = ['POST' ])
92+
93+
94+ @app .route ('/face_recognize_from_Urls' , methods = ['POST' ])
9495def predictface ():
95- data = request .json
96- url1 = data ['url1' ]
97- # get URL of first image from form data
96+ data = request .json
97+ url1 = data ['url1' ]
98+ # get URL of first image from form data
9899 url2 = data ['url2' ]
99100
100101 # Read the first image from URL using requests library
101- img1 = cv2 .imdecode (np .frombuffer (requests .get (url1 ).content , np .uint8 ), cv2 .IMREAD_COLOR )
102+ img1 = cv2 .imdecode (np .frombuffer (requests .get (
103+ url1 ).content , np .uint8 ), cv2 .IMREAD_COLOR )
102104
103105 # Download the second image from the URL
104106 with urllib .request .urlopen (url2 ) as url :
@@ -110,8 +112,10 @@ def predictface():
110112 gray_img2 = cv2 .cvtColor (img2 , cv2 .COLOR_BGR2GRAY )
111113
112114 # Detect faces in the images
113- faces1 = face_cascade .detectMultiScale (gray_img1 , scaleFactor = 1.1 , minNeighbors = 5 )
114- faces2 = face_cascade .detectMultiScale (gray_img2 , scaleFactor = 1.1 , minNeighbors = 5 )
115+ faces1 = face_cascade .detectMultiScale (
116+ gray_img1 , scaleFactor = 1.1 , minNeighbors = 5 )
117+ faces2 = face_cascade .detectMultiScale (
118+ gray_img2 , scaleFactor = 1.1 , minNeighbors = 5 )
115119
116120 # Compare only the first detected face in each image
117121 if len (faces1 ) > 0 and len (faces2 ) > 0 :
@@ -135,7 +139,7 @@ def predictface():
135139 return jsonify ({'similarity_percentage' : similarity_percentage })
136140
137141 else :
138- return jsonify ({'similarity_percentage' : 'Could not detect faces in both images.' })
142+ return jsonify ({'similarity_percentage' : 'Could not detect faces in both images.' })
139143
140144
141145if __name__ == '__main__' :
0 commit comments