mirror of
https://github.com/Kagami/go-face.git
synced 2025-10-28 01:41:38 +08:00
Fix testdata directory structure
This commit is contained in:
12
README.md
12
README.md
@@ -57,16 +57,12 @@ process.
|
||||
|
||||
Currently `shape_predictor_5_face_landmarks.dat`, `mmod_human_face_detector.dat` and
|
||||
`dlib_face_recognition_resnet_model_v1.dat` are required. You may download them
|
||||
from [dlib-models](https://github.com/davisking/dlib-models) repo:
|
||||
from [go-face-testdata](https://github.com/Kagami/go-face-testdata) repo:
|
||||
|
||||
```bash
|
||||
mkdir models && cd models
|
||||
wget https://github.com/davisking/dlib-models/raw/master/shape_predictor_5_face_landmarks.dat.bz2
|
||||
bunzip2 shape_predictor_5_face_landmarks.dat.bz2
|
||||
wget https://github.com/davisking/dlib-models/raw/master/dlib_face_recognition_resnet_model_v1.dat.bz2
|
||||
bunzip2 dlib_face_recognition_resnet_model_v1.dat.bz2
|
||||
wget https://github.com/davisking/dlib-models/raw/master/mmod_human_face_detector.dat.bz2
|
||||
bunzip2 mmod_human_face_detector.dat.bz2
|
||||
wget https://github.com/Kagami/go-face-testdata/raw/master/models/shape_predictor_5_face_landmarks.dat
|
||||
wget https://github.com/Kagami/go-face-testdata/raw/master/models/dlib_face_recognition_resnet_model_v1.dat
|
||||
wget https://github.com/Kagami/go-face-testdata/raw/master/models/mmod_human_face_detector.dat
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -16,7 +16,7 @@ const dataDir = "testdata"
|
||||
// recognizer, recognize faces, classify them using few known ones.
|
||||
func Example_basic() {
|
||||
// Init the recognizer.
|
||||
rec, err := face.NewRecognizer(dataDir)
|
||||
rec, err := face.NewRecognizer(filepath.Join(dataDir, "models"))
|
||||
if err != nil {
|
||||
log.Fatalf("Can't init face recognizer: %v", err)
|
||||
}
|
||||
@@ -24,7 +24,7 @@ func Example_basic() {
|
||||
defer rec.Close()
|
||||
|
||||
// Test image with 10 faces.
|
||||
testImagePristin := filepath.Join(dataDir, "pristin.jpg")
|
||||
testImagePristin := filepath.Join(dataDir, "images", "pristin.jpg")
|
||||
// Recognize faces on that image.
|
||||
faces, err := rec.RecognizeFile(testImagePristin)
|
||||
if err != nil {
|
||||
@@ -53,7 +53,7 @@ func Example_basic() {
|
||||
rec.SetSamples(samples, cats)
|
||||
|
||||
// Now let's try to classify some not yet known image.
|
||||
testImageNayoung := filepath.Join(dataDir, "nayoung.jpg")
|
||||
testImageNayoung := filepath.Join(dataDir, "images", "nayoung.jpg")
|
||||
nayoungFace, err := rec.RecognizeSingleFile(testImageNayoung)
|
||||
if err != nil {
|
||||
log.Fatalf("Can't recognize: %v", err)
|
||||
|
||||
@@ -58,11 +58,11 @@ type TrainData struct {
|
||||
}
|
||||
|
||||
func getTPath(fname string) string {
|
||||
return filepath.Join("testdata", fname)
|
||||
return filepath.Join("testdata", "images", fname)
|
||||
}
|
||||
|
||||
func getIdolData() (idata *IdolData, err error) {
|
||||
data, err := ioutil.ReadFile(getTPath("idols.json"))
|
||||
data, err := ioutil.ReadFile(filepath.Join("testdata", "idols.json"))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -141,7 +141,7 @@ func TestSerializationError(t *testing.T) {
|
||||
|
||||
func TestInit(t *testing.T) {
|
||||
var err error
|
||||
rec, err = face.NewRecognizer("testdata")
|
||||
rec, err = face.NewRecognizer(filepath.Join("testdata", "models"))
|
||||
if err != nil {
|
||||
t.Fatalf("Can't init face recognizer: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user