|
13 | 13 | "id": "9ece0f6e-518a-49b6-b06a-959d50bef991", |
14 | 14 | "metadata": {}, |
15 | 15 | "source": [ |
16 | | - "## Use case 1: compute feature vectors with fastdup and load then with numpy for further processing" |
| 16 | + "## Use case 1: compute feature vectors with fastdup and load them with numpy for further processing" |
17 | 17 | ] |
18 | 18 | }, |
19 | 19 | { |
|
97 | 97 | "source": [ |
98 | 98 | "import fastdup\n", |
99 | 99 | "import numpy as np\n", |
| 100 | + "\n", |
| 101 | + "#chnage to your image folder\n", |
| 102 | + "input_dir = '/Users/dannybickson/visual_database/cxx/unittests/two_images/'\n", |
| 103 | + "\n", |
100 | 104 | "# Run fastup on an input image folder to create embeddings\n", |
101 | | - "fd = fastdup.create(input_dir='/Users/dannybickson/visual_database/cxx/unittests/two_images/', work_dir='out')\n", |
| 105 | + "fd = fastdup.create(input_dir=input_dir, work_dir='out')\n", |
102 | 106 | "fd.run(overwrite=True, print_summary=False)\n", |
103 | 107 | "\n", |
104 | 108 | "# Read the embeddings to use them in python\n", |
|
162 | 166 | } |
163 | 167 | ], |
164 | 168 | "source": [ |
| 169 | + "import fastdup\n", |
| 170 | + "import numpy as np\n", |
| 171 | + "import os\n", |
| 172 | + "input_dir = '/Users/dannybickson/visual_database/cxx/unittests/two_images/'\n", |
| 173 | + "flist = os.listdir(input_dir)\n", |
| 174 | + "flist = [os.path.join(input_dir, f) for f in flist]\n", |
| 175 | + "\n", |
165 | 176 | "# replace the below code with computation of your own features\n", |
166 | 177 | "matrix = np.random.rand(2, 576).astype('float32')\n", |
167 | 178 | "\n", |
168 | 179 | "# save the embedding along the filenames into a working folder\n", |
169 | 180 | "!mkdir -p embedding_input\n", |
170 | 181 | "fastdup.save_binary_feature('embedding_input', flist, matrix)\n", |
171 | | - "\n", |
172 | | - "\n", |
173 | 182 | "fastdup.run('~/visual_database/cxx/unittests/two_images/', run_mode=2, work_dir='embedding_input')" |
174 | 183 | ] |
175 | 184 | }, |
|
208 | 217 | ], |
209 | 218 | "source": [ |
210 | 219 | "# Note: files should contain absolute path and not relative path\n", |
211 | | - "import pandas as pd\n", |
212 | | - "df = pd.DataFrame({'filename':flist})\n", |
213 | | - "fd2 = fastdup.create(input_dir='/Users/dannybickson/visual_database/cxx/unittests/two_images/', work_dir='out3')\n", |
214 | | - "fd2.run(annotations=df, embeddings=matrix, print_summary=False, overwrite=True)\n", |
215 | | - "\n" |
| 220 | + "import fastdup\n", |
| 221 | + "import numpy as np\n", |
| 222 | + "import os\n", |
| 223 | + "input_dir = '/Users/dannybickson/visual_database/cxx/unittests/two_images/'\n", |
| 224 | + "flist = os.listdir(input_dir)\n", |
| 225 | + "flist = [os.path.join(input_dir, f) for f in flist]\n", |
| 226 | + "\n", |
| 227 | + "# replace the below code with computation of your own features\n", |
| 228 | + "matrix = np.random.rand(2, 576).astype('float32')\n", |
| 229 | + "\n", |
| 230 | + "fd2 = fastdup.create(input_dir=input_dir, work_dir='output2')\n", |
| 231 | + "fd2.run(annotations=flist, embeddings=matrix, print_summary=False, overwrite=True)" |
216 | 232 | ] |
217 | 233 | }, |
218 | 234 | { |
|
0 commit comments