ABAO77 commited on
Commit
95c2d79
·
verified ·
1 Parent(s): 55cd92f

Upload 21 files

Browse files
images.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:ba21a3d4aa2f70fc5d1834325a60d9ae12f3d9362a01ff17479bcb5017752d9a
3
- size 651946218
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:91d47f3d7ab1beeaf5618e6dc1a8a6ce0047e468fed1ffdaa9995651e29b1a98
3
+ size 22677465
model/db_vit_b_16.index CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e6a435671e9e822062b51f2a1217472f2dac30bdc8443cb5d84001fe2d9c3ff9
3
- size 13268013
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4a689e3a0812adb264cc25d857a73292fd0d71ded0b73841117a730ee9c93a75
3
+ size 98349
src/.DS_Store CHANGED
Binary files a/src/.DS_Store and b/src/.DS_Store differ
 
src/build_vector_database.py CHANGED
@@ -22,21 +22,21 @@ import os
22
  from modules import FeatureExtractor
23
  from config import *
24
 
25
-
 
26
  def main(args=None):
27
  # initialize the feature extractor with the base model specified in the arguments
28
  feature_extractor = FeatureExtractor(base_model=args.feat_extractor)
29
  # initialize the vector database indexing
30
  index = faiss.IndexFlatIP(feature_extractor.feat_dims)
31
  # get the list of images in sorted order
32
- image_list = sorted(os.listdir(IMAGES_DIR))
33
 
34
  with torch.no_grad():
35
  # iterate over the images and add their extracted features to the index
36
  for img_filename in tqdm(image_list):
37
  # load image
38
- img = PIL.Image.open(os.path.join(IMAGES_DIR, img_filename)).convert("RGB")
39
- # extract features
40
  output = feature_extractor.extract_features(img)
41
  # keep only batch dimension
42
  output = output.view(output.size(0), -1)
@@ -47,7 +47,7 @@ def main(args=None):
47
  index.add(output.numpy())
48
 
49
  # save the index
50
- index_filepath = os.path.join(DATA_DIR, f"db_{args.feat_extractor}.index")
51
  faiss.write_index(index, index_filepath)
52
 
53
 
 
22
  from modules import FeatureExtractor
23
  from config import *
24
 
25
+ images_dir = "../webp_images/images"
26
+ data_dir = "../webp_images"
27
  def main(args=None):
28
  # initialize the feature extractor with the base model specified in the arguments
29
  feature_extractor = FeatureExtractor(base_model=args.feat_extractor)
30
  # initialize the vector database indexing
31
  index = faiss.IndexFlatIP(feature_extractor.feat_dims)
32
  # get the list of images in sorted order
33
+ image_list = sorted(os.listdir(images_dir))
34
 
35
  with torch.no_grad():
36
  # iterate over the images and add their extracted features to the index
37
  for img_filename in tqdm(image_list):
38
  # load image
39
+ img = PIL.Image.open(os.path.join(images_dir, img_filename)).convert("RGB")
 
40
  output = feature_extractor.extract_features(img)
41
  # keep only batch dimension
42
  output = output.view(output.size(0), -1)
 
47
  index.add(output.numpy())
48
 
49
  # save the index
50
+ index_filepath = os.path.join(data_dir, f"db_{args.feat_extractor}.index")
51
  faiss.write_index(index, index_filepath)
52
 
53
 
src/config/.DS_Store CHANGED
Binary files a/src/config/.DS_Store and b/src/config/.DS_Store differ
 
src/config/__pycache__/__init__.cpython-311.pyc CHANGED
Binary files a/src/config/__pycache__/__init__.cpython-311.pyc and b/src/config/__pycache__/__init__.cpython-311.pyc differ
 
src/config/__pycache__/settings.cpython-311.pyc CHANGED
Binary files a/src/config/__pycache__/settings.cpython-311.pyc and b/src/config/__pycache__/settings.cpython-311.pyc differ
 
src/modules/__pycache__/__init__.cpython-311.pyc CHANGED
Binary files a/src/modules/__pycache__/__init__.cpython-311.pyc and b/src/modules/__pycache__/__init__.cpython-311.pyc differ
 
src/modules/__pycache__/config_extractor.cpython-311.pyc CHANGED
Binary files a/src/modules/__pycache__/config_extractor.cpython-311.pyc and b/src/modules/__pycache__/config_extractor.cpython-311.pyc differ
 
src/modules/__pycache__/feature_extractor.cpython-311.pyc CHANGED
Binary files a/src/modules/__pycache__/feature_extractor.cpython-311.pyc and b/src/modules/__pycache__/feature_extractor.cpython-311.pyc differ