@@ -89,16 +89,18 @@ def predictface():
89
89
90
90
else :
91
91
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' ])
94
95
def 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
98
99
url2 = data ['url2' ]
99
100
100
101
# 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 )
102
104
103
105
# Download the second image from the URL
104
106
with urllib .request .urlopen (url2 ) as url :
@@ -110,8 +112,10 @@ def predictface():
110
112
gray_img2 = cv2 .cvtColor (img2 , cv2 .COLOR_BGR2GRAY )
111
113
112
114
# 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 )
115
119
116
120
# Compare only the first detected face in each image
117
121
if len (faces1 ) > 0 and len (faces2 ) > 0 :
@@ -135,7 +139,7 @@ def predictface():
135
139
return jsonify ({'similarity_percentage' : similarity_percentage })
136
140
137
141
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.' })
139
143
140
144
141
145
if __name__ == '__main__' :
0 commit comments