Tweak classifier.py interface and show usage in the README.
This commit is contained in:
parent
23f0860e47
commit
71be06d81e
|
@ -230,6 +230,13 @@ the confidence score is usually lower.
|
||||||
| Carell | <img src='images/examples/carell.jpg' width='200px'></img> | SteveCarell | 0.78 |
|
| Carell | <img src='images/examples/carell.jpg' width='200px'></img> | SteveCarell | 0.78 |
|
||||||
| Adams | <img src='images/examples/adams.jpg' width='200px'></img> | AmyAdams | 0.87 |
|
| Adams | <img src='images/examples/adams.jpg' width='200px'></img> | AmyAdams | 0.87 |
|
||||||
|
|
||||||
|
|
||||||
|
Run this on new images with:
|
||||||
|
|
||||||
|
```
|
||||||
|
./demos/classifier.py ./models/openface/celeb-classifier.nn4.v1.pkl infer <image>
|
||||||
|
```
|
||||||
|
|
||||||
# Model Definitions
|
# Model Definitions
|
||||||
Model definitions should be kept in [models/openface](models/openface),
|
Model definitions should be kept in [models/openface](models/openface),
|
||||||
where we have provided definitions of the [nn1](models/openface/nn1.def.lua)
|
where we have provided definitions of the [nn1](models/openface/nn1.def.lua)
|
||||||
|
|
|
@ -96,7 +96,7 @@ def train(args):
|
||||||
pickle.dump((le, svm), f)
|
pickle.dump((le, svm), f)
|
||||||
|
|
||||||
def infer(args):
|
def infer(args):
|
||||||
with open("{}/classifier.pkl".format(args.workDir), 'r') as f:
|
with open(args.classifierModel, 'r') as f:
|
||||||
(le, svm) = pickle.load(f)
|
(le, svm) = pickle.load(f)
|
||||||
rep = getRep(args.img)
|
rep = getRep(args.img)
|
||||||
predictions = svm.predict_proba(rep)[0]
|
predictions = svm.predict_proba(rep)[0]
|
||||||
|
@ -108,8 +108,6 @@ def infer(args):
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
parser.add_argument('workDir', type=str,
|
|
||||||
help="The input work directory containing 'reps.csv' and 'labels.csv'. Obtained from aligning a directory with 'align-dlib' and getting the representations with 'batch-represent'.")
|
|
||||||
parser.add_argument('--dlibFaceMean', type=str,
|
parser.add_argument('--dlibFaceMean', type=str,
|
||||||
help="Path to dlib's face predictor.",
|
help="Path to dlib's face predictor.",
|
||||||
default=os.path.join(dlibModelDir, "mean.csv"))
|
default=os.path.join(dlibModelDir, "mean.csv"))
|
||||||
|
@ -131,8 +129,12 @@ if __name__ == '__main__':
|
||||||
subparsers = parser.add_subparsers(dest='mode', help="Mode")
|
subparsers = parser.add_subparsers(dest='mode', help="Mode")
|
||||||
trainParser = subparsers.add_parser('train',
|
trainParser = subparsers.add_parser('train',
|
||||||
help="Train a new classifier.")
|
help="Train a new classifier.")
|
||||||
|
trainParser.add_argument('workDir', type=str,
|
||||||
|
help="The input work directory containing 'reps.csv' and 'labels.csv'. Obtained from aligning a directory with 'align-dlib' and getting the representations with 'batch-represent'.")
|
||||||
|
|
||||||
inferParser = subparsers.add_parser('infer',
|
inferParser = subparsers.add_parser('infer',
|
||||||
help='Predict who an image contains from a trained classifier.')
|
help='Predict who an image contains from a trained classifier.')
|
||||||
|
inferParser.add_argument('classifierModel', type=str)
|
||||||
inferParser.add_argument('img', type=str,
|
inferParser.add_argument('img', type=str,
|
||||||
help="Input image.")
|
help="Input image.")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue