Spaces:
Running
Running
Update demo.py
Browse files
demo.py
CHANGED
|
@@ -30,19 +30,19 @@ def face_crop(image, face_rect):
|
|
| 30 |
return face_image
|
| 31 |
|
| 32 |
def compare_face(image1, image2):
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
|
| 47 |
# url = "http://127.0.0.1:8080/compare_face"
|
| 48 |
# files = {'file1': img_bytes1, 'file2': img_bytes2}
|
|
|
|
| 30 |
return face_image
|
| 31 |
|
| 32 |
def compare_face(image1, image2):
|
| 33 |
+
try:
|
| 34 |
+
img_bytes1 = io.BytesIO()
|
| 35 |
+
image1.save(img_bytes1, format="JPEG")
|
| 36 |
+
img_bytes1.seek(0)
|
| 37 |
+
except:
|
| 38 |
+
return "Failed to open image1"
|
| 39 |
+
|
| 40 |
+
try:
|
| 41 |
+
img_bytes2 = io.BytesIO()
|
| 42 |
+
image2.save(img_bytes2, format="JPEG")
|
| 43 |
+
img_bytes2.seek(0)
|
| 44 |
+
except:
|
| 45 |
+
return "Failed to open image2"
|
| 46 |
|
| 47 |
# url = "http://127.0.0.1:8080/compare_face"
|
| 48 |
# files = {'file1': img_bytes1, 'file2': img_bytes2}
|