mirror of
https://github.com/20kaushik02/CSE515_MWDB_Project.git
synced 2025-12-06 09:34:07 +00:00
Merge pull request #6 from 20kaushik02/phase3_task3
Phase3 task 3 and 4
This commit is contained in:
commit
1b1dc90236
@ -1311,7 +1311,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.10.5"
|
"version": "3.11.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|||||||
@ -432,7 +432,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.10.5"
|
"version": "3.11.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|||||||
4661
Phase 3/task_3.ipynb
Normal file
4661
Phase 3/task_3.ipynb
Normal file
File diff suppressed because it is too large
Load Diff
233
Phase 3/task_4.ipynb
Normal file
233
Phase 3/task_4.ipynb
Normal file
File diff suppressed because one or more lines are too long
68
Phase 3/utils.py
Normal file
68
Phase 3/utils.py
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
# All imports
|
||||||
|
# Math
|
||||||
|
import math
|
||||||
|
import random
|
||||||
|
import cv2
|
||||||
|
import numpy as np
|
||||||
|
from scipy.stats import pearsonr
|
||||||
|
|
||||||
|
# from scipy.sparse.linalg import svds
|
||||||
|
# from sklearn.decomposition import NMF
|
||||||
|
from sklearn.decomposition import LatentDirichletAllocation
|
||||||
|
|
||||||
|
# from sklearn.cluster import KMeans
|
||||||
|
|
||||||
|
# Torch
|
||||||
|
import torch
|
||||||
|
import torchvision.transforms as transforms
|
||||||
|
from torchvision.datasets import Caltech101
|
||||||
|
from torchvision.models import resnet50, ResNet50_Weights
|
||||||
|
|
||||||
|
import tensorly as tl
|
||||||
|
|
||||||
|
# OS and env
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from os import getenv
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
import warnings
|
||||||
|
from joblib import dump, load
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
# MongoDB
|
||||||
|
from pymongo import MongoClient
|
||||||
|
|
||||||
|
# Visualizing
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
valid_classification_methods = {
|
||||||
|
"m-nn": 1,
|
||||||
|
"decision-tree": 2,
|
||||||
|
"ppr": 3,
|
||||||
|
}
|
||||||
|
|
||||||
|
def getCollection(db, collection):
|
||||||
|
"""Load feature descriptor collection from MongoDB"""
|
||||||
|
client = MongoClient("mongodb://localhost:27017")
|
||||||
|
return client[db][collection]
|
||||||
|
|
||||||
|
|
||||||
|
def euclidean_distance_measure(img_1_fd, img_2_fd):
|
||||||
|
img_1_fd_reshaped = img_1_fd.flatten()
|
||||||
|
img_2_fd_reshaped = img_2_fd.flatten()
|
||||||
|
|
||||||
|
# Calculate Euclidean distance
|
||||||
|
return math.dist(img_1_fd_reshaped, img_2_fd_reshaped)
|
||||||
|
|
||||||
|
|
||||||
|
valid_feature_models = {
|
||||||
|
"cm": "cm_fd",
|
||||||
|
"hog": "hog_fd",
|
||||||
|
"avgpool": "avgpool_fd",
|
||||||
|
"layer3": "layer3_fd",
|
||||||
|
"fc": "fc_fd",
|
||||||
|
"resnet": "resnet_fd",
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user