Spaces:
Runtime error
Runtime error
Samuel Schmidt
commited on
Commit
·
49a4ce1
1
Parent(s):
f9494ca
Deleted old files
Browse files- src/haarcascade_frontalface_default.xml +0 -0
- src/index.py +0 -32
- src/search.py +0 -31
- src/searcher.py +0 -47
src/haarcascade_frontalface_default.xml
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
src/index.py
DELETED
|
@@ -1,32 +0,0 @@
|
|
| 1 |
-
# # import the necessary packages
|
| 2 |
-
# from colordescriptor import ColorDescriptor
|
| 3 |
-
# import glob
|
| 4 |
-
# import cv2
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
# class Indexer:
|
| 8 |
-
# def __init__(self, indexPath):
|
| 9 |
-
# # store our index path
|
| 10 |
-
# self.indexPath = indexPath
|
| 11 |
-
|
| 12 |
-
# def index(self):
|
| 13 |
-
# # initialize the color descriptor
|
| 14 |
-
# cd = ColorDescriptor((8, 12, 3))
|
| 15 |
-
|
| 16 |
-
# # open the output index file for writing
|
| 17 |
-
# output = open(self.indexPath, "w")
|
| 18 |
-
|
| 19 |
-
# # use glob to grab the image paths and loop over them
|
| 20 |
-
# for imagePath in glob.glob("../static/images/" + "/*.png"):
|
| 21 |
-
# # extract the image ID (i.e. the unique filename) from the image
|
| 22 |
-
# # path and load the image itself
|
| 23 |
-
# imageID = imagePath[imagePath.rfind("/") + 1:]
|
| 24 |
-
# image = cv2.imread(imagePath)
|
| 25 |
-
# # describe the image
|
| 26 |
-
# features = cd.describe(image)
|
| 27 |
-
# # write the features to file
|
| 28 |
-
# features = [str(f) for f in features]
|
| 29 |
-
# output.write("%s,%s\n" % (imageID, ",".join(features)))
|
| 30 |
-
|
| 31 |
-
# # close the index file
|
| 32 |
-
# output.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/search.py
DELETED
|
@@ -1,31 +0,0 @@
|
|
| 1 |
-
# from colordescriptor import ColorDescriptor
|
| 2 |
-
# from searcher import Searcher
|
| 3 |
-
# import argparse
|
| 4 |
-
# import cv2
|
| 5 |
-
|
| 6 |
-
# # construct the argument parser and parse the arguments
|
| 7 |
-
# ap = argparse.ArgumentParser()
|
| 8 |
-
# ap.add_argument("-i", "--index", required = True,
|
| 9 |
-
# help = "Path to where the computed index will be stored")
|
| 10 |
-
# ap.add_argument("-q", "--query", required = True,
|
| 11 |
-
# help = "Path to the query image")
|
| 12 |
-
# ap.add_argument("-r", "--result-path", required = True,
|
| 13 |
-
# help = "Path to the result path")
|
| 14 |
-
# args = vars(ap.parse_args())
|
| 15 |
-
|
| 16 |
-
# # initialize the image descriptor
|
| 17 |
-
# cd = ColorDescriptor((8, 12, 3))
|
| 18 |
-
# # load the query image and describe it
|
| 19 |
-
# query = cv2.imread(args["query"])
|
| 20 |
-
# features = cd.describe(query)
|
| 21 |
-
# # perform the search
|
| 22 |
-
# searcher = Searcher(args["index"])
|
| 23 |
-
# results = searcher.search(features)
|
| 24 |
-
# # display the query
|
| 25 |
-
# cv2.imshow("Query", query)
|
| 26 |
-
# # loop over the results
|
| 27 |
-
# for (score, resultID) in results:
|
| 28 |
-
# # load the result image and display it
|
| 29 |
-
# result = cv2.imread(args["result_path"] + "/" + resultID)
|
| 30 |
-
# cv2.imshow("Result", result)
|
| 31 |
-
# cv2.waitKey(0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/searcher.py
DELETED
|
@@ -1,47 +0,0 @@
|
|
| 1 |
-
# import numpy as np
|
| 2 |
-
# import csv
|
| 3 |
-
|
| 4 |
-
# class Searcher:
|
| 5 |
-
# def __init__(self, indexPath):
|
| 6 |
-
# # store our index path
|
| 7 |
-
# self.indexPath = indexPath
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
# def chi2_distance(self, histA, histB, eps = 1e-10):
|
| 11 |
-
# # compute the chi-squared distance
|
| 12 |
-
# d = 0.5 * np.sum([((a - b) ** 2) / (a + b + eps)
|
| 13 |
-
# for (a, b) in zip(histA, histB)])
|
| 14 |
-
# # return the chi-squared distance
|
| 15 |
-
# return d
|
| 16 |
-
|
| 17 |
-
# def search(self, queryFeatures, limit = 3):
|
| 18 |
-
# # initialize our dictionary of results
|
| 19 |
-
# results = {}
|
| 20 |
-
# # open the index file for reading
|
| 21 |
-
# with open(self.indexPath) as f:
|
| 22 |
-
# # initialize the CSV reader
|
| 23 |
-
# reader = csv.reader(f)
|
| 24 |
-
# # loop over the rows in the index
|
| 25 |
-
# for row in reader:
|
| 26 |
-
# # parse out the image ID and features, then compute the
|
| 27 |
-
# # chi-squared distance between the features in our index
|
| 28 |
-
# # and our query features
|
| 29 |
-
# features = [float(x) for x in row[1:]]
|
| 30 |
-
# d = self.chi2_distance(features, queryFeatures)
|
| 31 |
-
# # now that we have the distance between the two feature
|
| 32 |
-
# # vectors, we can udpate the results dictionary -- the
|
| 33 |
-
# # key is the current image ID in the index and the
|
| 34 |
-
# # value is the distance we just computed, representing
|
| 35 |
-
# # how 'similar' the image in the index is to our query
|
| 36 |
-
# results[row[0]] = d
|
| 37 |
-
|
| 38 |
-
# # close the reader
|
| 39 |
-
# f.close()
|
| 40 |
-
|
| 41 |
-
# # sort our results, so that the smaller distances (i.e. the
|
| 42 |
-
# # more relevant images are at the front of the list)
|
| 43 |
-
# path = "home/user/app/static/images/"
|
| 44 |
-
# results = sorted([(v, f"{path}{k}") for (k, v) in results.items()])
|
| 45 |
-
|
| 46 |
-
# # return our (limited) results
|
| 47 |
-
# return results[:limit]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|