arnabg95 commited on
Commit
8388a59
·
1 Parent(s): 1e9cc94

minor chnage

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -1,6 +1,7 @@
1
  from fastapi import FastAPI
2
  from deepface import DeepFace
3
  from pydantic import BaseModel
 
4
 
5
 
6
  class Verify(BaseModel):
@@ -14,7 +15,7 @@ def greet_json():
14
  return {"Hello": "World!"}
15
 
16
  @app.post("/verify")
17
- def verify(v: Verify) -> bool:
18
  data = v.model_dump()
19
  selfie = data["image"]
20
  gallery = data["images"]
@@ -24,7 +25,6 @@ def verify(v: Verify) -> bool:
24
  with open("x.jpg", "wb") as out_file:
25
  out_file.write(res.content)
26
 
27
-
28
  true_count = 0
29
  for image in gallery:
30
  try:
@@ -32,7 +32,7 @@ def verify(v: Verify) -> bool:
32
  if result.get("verified", False):
33
  true_count += 1
34
  if true_count >= 2:
35
- return True, image
36
  except Exception as e:
37
  print(e)
38
- return False, None
 
1
  from fastapi import FastAPI
2
  from deepface import DeepFace
3
  from pydantic import BaseModel
4
+ from fastapi.responses import JSONResponse
5
 
6
 
7
  class Verify(BaseModel):
 
15
  return {"Hello": "World!"}
16
 
17
  @app.post("/verify")
18
+ def verify(v: Verify):
19
  data = v.model_dump()
20
  selfie = data["image"]
21
  gallery = data["images"]
 
25
  with open("x.jpg", "wb") as out_file:
26
  out_file.write(res.content)
27
 
 
28
  true_count = 0
29
  for image in gallery:
30
  try:
 
32
  if result.get("verified", False):
33
  true_count += 1
34
  if true_count >= 2:
35
+ return JSONResponse(content={"verified": True, "image": image})
36
  except Exception as e:
37
  print(e)
38
+ return JSONResponse(content={"verified": False, "image": None})