Edvards commited on
Commit
46bc602
1 Parent(s): 2d1b534

added custom handler

Browse files
Files changed (7) hide show
  1. .gitattributes +2 -0
  2. .gitignore +3 -0
  3. angelina.jpg +0 -0
  4. handler.py +12 -0
  5. pixi.lock +0 -0
  6. pixi.toml +16 -0
  7. test.py +23 -0
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ # GitHub syntax highlighting
37
+ pixi.lock linguist-language=YAML linguist-generated=true
.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # pixi environments
2
+ .pixi
3
+ *.egg-info
angelina.jpg ADDED
handler.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Dict, List, Any
2
+ from retinaface import RetinaFace
3
+ import numpy as np
4
+ from PIL import Image
5
+
6
+ class EndpointHandler():
7
+ def __init__(self, path=""):
8
+ return
9
+
10
+ def __call__(self, data: np.ndarray) -> List[Dict[str, Any]]:
11
+ res = RetinaFace.detect_faces(data)
12
+ return [res]
pixi.lock ADDED
The diff for this file is too large to render. See raw diff
 
pixi.toml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "retinaface"
3
+ version = "0.1.0"
4
+ description = "Add a short description here"
5
+ authors = ["EdvardsZ <edvards1999@gmail.com>"]
6
+ channels = ["conda-forge"]
7
+ platforms = ["linux-64"]
8
+
9
+ [tasks]
10
+
11
+ [dependencies]
12
+ python = "3.11.*"
13
+ transformers = ">=4.41.2,<4.42"
14
+ retina-face = ">=0.0.17,<0.1"
15
+ tf-keras = ">=2.16.0,<2.17"
16
+ matplotlib = ">=3.8.4,<3.9"
test.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from handler import EndpointHandler
2
+ from PIL import Image
3
+ import numpy as np
4
+ import matplotlib.pyplot as plt
5
+
6
+ # init handler
7
+ my_handler = EndpointHandler(path=".")
8
+
9
+ # load image
10
+ img = Image.open("angelina.jpg")
11
+
12
+ img_np = np.array(img)
13
+
14
+ # call handler
15
+ result = my_handler(img_np)
16
+
17
+ print(result)
18
+
19
+
20
+
21
+
22
+
23
+