Fix testdata directory structure

This commit is contained in:
Kagami Hiiragi
2020-05-13 20:31:38 +03:00
parent 4c3eb8d32c
commit d4af7c8eab
3 changed files with 10 additions and 14 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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)
}