gfhe commited on
Commit ·
718895c
1
Parent(s): e78005d
add 10m data
Browse files- .gitattributes +1 -0
- base.10M.fbin +3 -0
- loading.py +23 -0
.gitattributes
CHANGED
|
@@ -53,3 +53,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 53 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 54 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 55 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 53 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 54 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 55 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
| 56 |
+
base.10M.fbin filter=lfs diff=lfs merge=lfs -text
|
base.10M.fbin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:290b341abc7ba570541e013fd20fd6d38c5873490ef395b512de5ed8dee18ce7
|
| 3 |
+
size 3840000008
|
loading.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
|
| 3 |
+
def read_fbin(filename, start_idx=0, chunk_size=None):
|
| 4 |
+
""" Read *.fbin file that contains float32 vectors
|
| 5 |
+
Args:
|
| 6 |
+
:param filename (str): path to *.fbin file
|
| 7 |
+
:param start_idx (int): start reading vectors from this index
|
| 8 |
+
:param chunk_size (int): number of vectors to read.
|
| 9 |
+
If None, read all vectors
|
| 10 |
+
Returns:
|
| 11 |
+
Array of float32 vectors (numpy.ndarray)
|
| 12 |
+
"""
|
| 13 |
+
with open(filename, "rb") as f:
|
| 14 |
+
nvecs, dim = np.fromfile(f, count=2, dtype=np.int32)
|
| 15 |
+
nvecs = (nvecs - start_idx) if chunk_size is None else chunk_size
|
| 16 |
+
arr = np.fromfile(f, count=nvecs * dim, dtype=np.float32,
|
| 17 |
+
offset=start_idx * 4 * dim)
|
| 18 |
+
return arr.reshape(nvecs, dim)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
# read data
|
| 22 |
+
# chunk_size = 50000
|
| 23 |
+
# dataset = read_fbin('deep1B/base.10M.fbin', chunk_size=chunk_size)
|