Instantaneous1 commited on
Commit
d357241
1 Parent(s): 3a4f968
Files changed (3) hide show
  1. README.md +3 -3
  2. app.py +3 -6
  3. requirements.txt +2 -1
README.md CHANGED
@@ -13,7 +13,7 @@ pinned: false
13
 
14
  ## Description
15
 
16
- ### A very fast reverse image search webapp in streamlit using NVIDIA's EfficientNet and Facebook's Faiss library. 70000 images (224x224), 4GB GTX1650: FAISS GPU in 10 secs vs 30 mins with Annoy CPU
17
 
18
  Upload a picture, and AI powered by deep learning will instantly show you visually related matches. Explore and discover connections through the magic of image recognition.
19
 
@@ -28,7 +28,7 @@ Experience the app in action right in your browser: https://huggingface.co/space
28
  - Upload a query image to find visually similar images in the dataset.
29
  - Explore retrieved images to discover related content.
30
  - Adjust the number of matches displayed for visual comparisons.
31
- - Utilizes a pre-trained image feature extractor model (EfficientNet-b0) for accurate image similarity.
32
  - Employs FAISS index for fast approximate nearest neighbor search.
33
  - Offers a user-friendly interface powered by Streamlit.
34
 
@@ -70,7 +70,7 @@ Streamlit: Framework for building and deploying web apps in Python.
70
  Torch: Powerful deep learning framework.
71
  OpenDatasets: Library for convenient dataset downloading.
72
  FAISS: Facebook's fast AI vector similarity search
73
- NVIDIA EfficientNet-b0: Pre-trained image classification model for feature extraction.
74
 
75
  ## Usage
76
 
 
13
 
14
  ## Description
15
 
16
+ ### Image Reverse Search with Google’s EfficientNet and Facebooks FAISS library optimizing search efficiency through fast image embeddings and approximate nearest neighbor algorithms | Training speed: 65k images efficientnet-b2: 4 mins vs Resnet-152: 10 mins
17
 
18
  Upload a picture, and AI powered by deep learning will instantly show you visually related matches. Explore and discover connections through the magic of image recognition.
19
 
 
28
  - Upload a query image to find visually similar images in the dataset.
29
  - Explore retrieved images to discover related content.
30
  - Adjust the number of matches displayed for visual comparisons.
31
+ - Utilizes a pre-trained image feature extractor model (EfficientNet-b2) for accurate image similarity.
32
  - Employs FAISS index for fast approximate nearest neighbor search.
33
  - Offers a user-friendly interface powered by Streamlit.
34
 
 
70
  Torch: Powerful deep learning framework.
71
  OpenDatasets: Library for convenient dataset downloading.
72
  FAISS: Facebook's fast AI vector similarity search
73
+ EfficientNet-b2: Pre-trained image classification model for feature extraction.
74
 
75
  ## Usage
76
 
app.py CHANGED
@@ -17,6 +17,7 @@ from torch.utils.data import Dataset, DataLoader
17
  import torchvision.transforms
18
  import numpy as np
19
  import faiss.contrib.torch_utils
 
20
 
21
  BATCH_SIZE = 200
22
  DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
@@ -24,7 +25,7 @@ ImageFile.LOAD_TRUNCATED_IMAGES = True
24
  FOLDER = "images/"
25
  NUM_TREES = 100
26
  FEATURES = 1000
27
- FILETYPES = [".png", ".jpg", ".jpeg", ".tiff", ".bmp"]
28
  LIBRARIES = [
29
  "https://www.kaggle.com/datasets/athota1/caltech101",
30
  "https://www.kaggle.com/datasets/gpiosenka/sports-classification",
@@ -82,11 +83,7 @@ def load_dataset():
82
  def load_model():
83
  """Loads a pre-trained image feature extractor model."""
84
  print("Loading pretrained model...")
85
- model = torch.hub.load(
86
- "NVIDIA/DeepLearningExamples:torchhub",
87
- "nvidia_efficientnet_b0",
88
- pretrained=True,
89
- )
90
  model.eval() # Set model to evaluation mode
91
  return model
92
 
 
17
  import torchvision.transforms
18
  import numpy as np
19
  import faiss.contrib.torch_utils
20
+ from efficientnet_pytorch import EfficientNet
21
 
22
  BATCH_SIZE = 200
23
  DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
 
25
  FOLDER = "images/"
26
  NUM_TREES = 100
27
  FEATURES = 1000
28
+ FILETYPES = [".png", ".jpg", ".jpeg", ".tiff", ".bmp", ".webp"]
29
  LIBRARIES = [
30
  "https://www.kaggle.com/datasets/athota1/caltech101",
31
  "https://www.kaggle.com/datasets/gpiosenka/sports-classification",
 
83
  def load_model():
84
  """Loads a pre-trained image feature extractor model."""
85
  print("Loading pretrained model...")
86
+ model = EfficientNet.from_pretrained('efficientnet-b2')
 
 
 
 
87
  model.eval() # Set model to evaluation mode
88
  return model
89
 
requirements.txt CHANGED
@@ -7,4 +7,5 @@ tqdm
7
  python-slugify
8
  opendatasets
9
  azure-storage-blob
10
- streamlit-cropper
 
 
7
  python-slugify
8
  opendatasets
9
  azure-storage-blob
10
+ streamlit-cropper
11
+ efficientnet_pytorch