KevanSoon commited on
Commit
ecaf129
·
1 Parent(s): cdcee06

added endpoint thats works with springboot

Browse files
Files changed (3) hide show
  1. __pycache__/app.cpython-310.pyc +0 -0
  2. app.py +14 -6
  3. test.py +9 -0
__pycache__/app.cpython-310.pyc ADDED
Binary file (1.11 kB). View file
 
app.py CHANGED
@@ -1,18 +1,26 @@
1
  from fastapi import FastAPI
2
  from pydantic import BaseModel
3
- from gradio_client import Client
4
 
5
  app = FastAPI()
6
 
7
- client = Client("https://kby-ai-facerecognition.hf.space/--replicas/ij0t7/")
8
 
9
  @app.get("/face-recognition")
10
  async def face_recognition_get():
11
  image1 = "https://qvnhhditkzzeudppuezf.supabase.co/storage/v1/object/public/post-images/post-images/1752289670997-kevan.jpg"
12
  image2 = "https://qvnhhditkzzeudppuezf.supabase.co/storage/v1/object/public/post-images/post-images/1752289670997-kevan.jpg"
13
  result = client.predict(
14
- image1,
15
- image2,
16
- fn_index=2
17
  )
18
- return {"result": result}
 
 
 
 
 
 
 
 
 
1
  from fastapi import FastAPI
2
  from pydantic import BaseModel
3
+ from gradio_client import Client, handle_file
4
 
5
  app = FastAPI()
6
 
7
+ client = Client("MiniAiLive/FaceRecognition-LivenessDetection-Demo")
8
 
9
  @app.get("/face-recognition")
10
  async def face_recognition_get():
11
  image1 = "https://qvnhhditkzzeudppuezf.supabase.co/storage/v1/object/public/post-images/post-images/1752289670997-kevan.jpg"
12
  image2 = "https://qvnhhditkzzeudppuezf.supabase.co/storage/v1/object/public/post-images/post-images/1752289670997-kevan.jpg"
13
  result = client.predict(
14
+ frame1=handle_file(image1),
15
+ frame2=handle_file(image2),
16
+ api_name="/face_compare"
17
  )
18
+
19
+ str_ = result # Access first element in array
20
+ start_index = str_.find("Similarity") # Find start index of "Similarity", -1 if not found
21
+ sliced_str = str_[start_index:] if start_index != -1 else ""
22
+ import re
23
+ decimal_match = re.search(r"<td>(0?\.\d+)<\/td>", sliced_str)
24
+ decimal_number = float(decimal_match.group(1)) if decimal_match else None
25
+ print("Similarity decimal:", decimal_number)
26
+ return {"result": "Confidence level: " + str(decimal_number)}
test.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ from gradio_client import Client, handle_file
2
+
3
+ client = Client("MiniAiLive/FaceRecognition-LivenessDetection-Demo")
4
+ result = client.predict(
5
+ frame1=handle_file('https://qvnhhditkzzeudppuezf.supabase.co/storage/v1/object/public/post-images/post-images/1752289670997-kevan.jpg'),
6
+ frame2=handle_file('https://qvnhhditkzzeudppuezf.supabase.co/storage/v1/object/public/post-images/post-images/1752289670997-kevan.jpg'),
7
+ api_name="/face_compare"
8
+ )
9
+ print(result)