132 lines
3.9 KiB
Plaintext
132 lines
3.9 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Training CoarseNet\n",
|
|
"Code for FineNet in paper \"Robust Minutiae Extractor: Integrating Deep Networks and Fingerprint Domain Knowledge\" at ICB 2018: https://arxiv.org/pdf/1712.09401.pdf\n",
|
|
"\n",
|
|
"If you use whole or partial function in this code, please cite paper:\n",
|
|
"\n",
|
|
" @inproceedings{Nguyen_MinutiaeNet,\n",
|
|
"\tauthor = {Dinh-Luan Nguyen and Kai Cao and Anil K. Jain},\n",
|
|
"\ttitle = {Robust Minutiae Extractor: Integrating Deep Networks and Fingerprint Domain Knowledge},\n",
|
|
"\tbooktitle = {The 11th International Conference on Biometrics, 2018},\n",
|
|
"\tyear = {2018},\n",
|
|
"\t}"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"To run this script, you need to prepare dataset as follows:\n",
|
|
"`path/to/dataset/`:\n",
|
|
"```Shell\n",
|
|
" - img_files/*.bmp\n",
|
|
" - mnt_files/*.mnt\n",
|
|
" - seg_files/*.jpg\n",
|
|
"```\n",
|
|
"See example at `Dataset/CoarseNet_train/` (these images are example from NIST SD27)\n",
|
|
" \n",
|
|
"## CoarseNet can run with any image size\n",
|
|
"See [CoarseNet_train.py](https://github.com/luannd/MinutiaeNet/blob/master/CoarseNet/CoarseNet_train.py) if running from command line.\n",
|
|
"\n",
|
|
"Log files, tensorboard, minutiae models can be seen from `output_CoarseNet` folder"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from __future__ import absolute_import\n",
|
|
"from __future__ import division\n",
|
|
"\n",
|
|
"import sys, os\n",
|
|
"sys.path.append(os.path.realpath('../CoarseNet'))\n",
|
|
"\n",
|
|
"os.environ['KERAS_BACKEND'] = 'tensorflow'\n",
|
|
"\n",
|
|
"from datetime import datetime\n",
|
|
"from MinutiaeNet_utils import *\n",
|
|
"\n",
|
|
"from keras import backend as K\n",
|
|
"from keras.optimizers import SGD, Adam\n",
|
|
"\n",
|
|
"from CoarseNet_utils import *\n",
|
|
"from CoarseNet_model import *\n",
|
|
"\n",
|
|
"lr = 0.005\n",
|
|
"\n",
|
|
"os.environ[\"CUDA_VISIBLE_DEVICES\"] = '0'\n",
|
|
"\n",
|
|
"config = K.tf.ConfigProto(gpu_options=K.tf.GPUOptions(allow_growth=True))\n",
|
|
"sess = K.tf.Session(config=config)\n",
|
|
"K.set_session(sess)\n",
|
|
"\n",
|
|
"batch_size = 2\n",
|
|
"use_multiprocessing = False\n",
|
|
"input_size = 400\n",
|
|
"\n",
|
|
"# Can use multiple folders for training\n",
|
|
"train_set = ['../Dataset/CoarseNet_train/',]\n",
|
|
"validate_set = ['../path/to/your/data/',]\n",
|
|
"\n",
|
|
"pretrain_dir = '../Models/CoarseNet.h5'\n",
|
|
"output_dir = '../output_CoarseNet/'+datetime.now().strftime('%Y%m%d-%H%M%S')\n",
|
|
"FineNet_dir = '../Models/FineNet.h5'\n",
|
|
"\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"\n",
|
|
"output_dir = '../output_CoarseNet/trainResults/' + datetime.now().strftime('%Y%m%d-%H%M%S')\n",
|
|
"logging = init_log(output_dir)\n",
|
|
"logging.info(\"Learning rate = %s\", lr)\n",
|
|
"logging.info(\"Pretrain dir = %s\", pretrain_dir)\n",
|
|
"\n",
|
|
"train(input_shape=(input_size, input_size), train_set=train_set, output_dir=output_dir,\n",
|
|
" pretrain_dir=pretrain_dir, batch_size=batch_size, test_set=validate_set,\n",
|
|
" learning_config=Adam(lr=float(lr), beta_1=0.9, beta_2=0.999, epsilon=1e-08, clipnorm=0.9),\n",
|
|
" logging=logging)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 2",
|
|
"language": "python",
|
|
"name": "python2"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 2
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython2",
|
|
"version": "2.7.15"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|