diff options
| author | adamhrv <adam@ahprojects.com> | 2018-12-16 01:03:14 +0100 |
|---|---|---|
| committer | adamhrv <adam@ahprojects.com> | 2018-12-16 01:03:14 +0100 |
| commit | 10f467b64e3be528ac246d5cf664d675aca3e7f3 (patch) | |
| tree | 02face1862f185796c3ddd08a274940626e31ff9 /faiss/util.py | |
| parent | a52dc6f8edc4e5d00e7c05e34c6c6fe6252ec2bd (diff) | |
| parent | f91c6d8e870bd3b2c69a130e4b1ed8f6be250b92 (diff) | |
Merge branch 'master' of github.com:adamhrv/megapixels_dev
Diffstat (limited to 'faiss/util.py')
| -rw-r--r-- | faiss/util.py | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/faiss/util.py b/faiss/util.py deleted file mode 100644 index 97afbc22..00000000 --- a/faiss/util.py +++ /dev/null @@ -1,29 +0,0 @@ -import time -import simplejson as json -import pickle -from os import path -from collections import namedtuple - -# Converts JSON el['key'] to Pythonic object-style el.key -def _json_object_hook(d): - return namedtuple('X', d.keys())(*d.values()) - -# Load a JSON recipe -def load_recipe(path): - with open(path) as fh: - return json.load(fh, object_hook=_json_object_hook) - -# Load a pickle file -def load_pickle(data_dir, pkl_fn): - load_start = time.time() - with open(path.join(str(data_dir), str(pkl_fn)), 'rb') as fh: - raw = fh.read() - data = pickle.loads(raw) - load_end = time.time() - load_time = load_end - load_start - print("Pickle load time: {:.1f}s".format(load_time)) - return data - -def read_json(fn): - with open(fn, 'r') as json_file: - return json.load(json_file) |
