-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
49 lines (40 loc) · 1.06 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"fmt"
"log"
"net/http"
"os"
"path/filepath"
"time"
"github.com/sirupsen/logrus"
"github.com/gorilla/mux"
"github.com/minhaj10p/facedetect/encoder"
"github.com/minhaj10p/facedetect/routes"
)
const dataDir = "./models"
const port = 8080
const excluder = "Ignoring file"
func main() {
ep, err := filepath.Abs("encodings.pickle")
if err != nil {
log.Fatal(err)
}
datasetPath, err := filepath.Abs("known")
if err != nil {
log.Fatal(err)
}
//if encodings don't exist.
if _, err := os.Stat(ep); err != nil {
t := time.Now()
if err := encoder.Encode(datasetPath, ep); err != nil {
log.Fatalf("could not encode dataset. err: %s", err)
}
logrus.Infof("encoding takes %f seconds", time.Since(t).Seconds())
}
r := mux.NewRouter()
r.HandleFunc("/v1/recognition", routes.Recognize()).Methods("POST")
r.HandleFunc("/v2/recognition", routes.RecogV2()).Methods("POST")
r.HandleFunc("/v1/face", routes.AddFace()).Methods("POST")
logrus.Infof("listening on port %d", port)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), r))
}