Created
May 3, 2016 17:51
-
-
Save jabooth/ba49a7adb86239ff1b24620070f3b564 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"import menpo.io as mio" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Lets say you have this file structure on disk:\n", | |
"```\n", | |
"image01.jpg\n", | |
"image01.01.ljson\n", | |
"image02.jpg\n", | |
"image02.01.ljson\n", | |
"image02.02.ljson\n", | |
"```" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"def import_multiple_landmarks(path):\n", | |
" # path will be e.g. .foo/bar/image01.jpg\n", | |
" # as a pathlib.Path object\n", | |
" # \n", | |
" # Find all LJSON paths for this image following\n", | |
" # our pattern above\n", | |
" lm_paths = path.parent.glob(path.stem + '.*.ljson')\n", | |
" # return a mapping from numbers to paths\n", | |
" return {p.name.split('.')[1]:p for p in lm_paths}" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"images = mio.import_images('./my/dir', landmark_resolver=import_multiple_landmarks)" | |
] | |
} | |
], | |
"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.11" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment