Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: PIlin/image-searcher
base: 94b1f634c2
...
head fork: PIlin/image-searcher
compare: ce50291e61
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
View
3  kurs/isifter/isifter.vcxproj
@@ -37,6 +37,7 @@
<Import Project="..\jpeg.props" />
<Import Project="..\vlfeat.props" />
<Import Project="..\out_dir_bin.props" />
+ <Import Project="..\sol_dir_include.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
@@ -45,6 +46,7 @@
<Import Project="..\jpeg.props" />
<Import Project="..\vlfeat.props" />
<Import Project="..\out_dir_bin.props" />
+ <Import Project="..\sol_dir_include.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@@ -83,6 +85,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
+ <AdditionalDependencies>Image.lib;Sift.lib;Util.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
View
10 kurs/ivf_creator/main.cpp
@@ -60,6 +60,7 @@ std::istream& operator>>(std::istream& is, ivFile::Weight& wt)
void prepare(int argc, char* argv[], std::string& ofname, std::string& tree_infile, str_vector& word_infiles, ivFile::Params& params)
{
std::string inlist_file;
+ std::string config;
bpo::options_description desc("");
desc.add_options()
@@ -68,6 +69,7 @@ void prepare(int argc, char* argv[], std::string& ofname, std::string& tree_infi
("tree,t", bpo::value(&tree_infile)->required(), "HIKM Tree file")
("list,l", bpo::value(&inlist_file), "File with the list of input sift files")
("input,i", bpo::value(&word_infiles), "Words input files")
+ ("config,c", bpo::value(&config), "Config file")
;
bpo::options_description optParams("IVF parameters");
@@ -78,6 +80,9 @@ void prepare(int argc, char* argv[], std::string& ofname, std::string& tree_infi
desc.add(optParams);
+ bpo::options_description config_file_options;
+ config_file_options.add(optParams);
+
bpo::positional_options_description p;
p.add("input", -1);
@@ -89,6 +94,11 @@ void prepare(int argc, char* argv[], std::string& ofname, std::string& tree_infi
exit(0);
}
+ if (vm.count("config"))
+ {
+ bpo::store(bpo::parse_config_file<char>(vm["config"].as<std::string>().c_str(), config_file_options), vm);
+ }
+
bpo::notify(vm);
conflicting_options(vm, "input", "list");
View
197 kurs/test_runner/test_runner.py
@@ -1,39 +1,121 @@
import os
import subprocess
+import pickle
+def check_output(*popenargs, **kwargs):
+ if 'stdout' in kwargs:
+ raise ValueError('stdout argument not allowed, it will be overridden.')
+ process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
+ output, unused_err = process.communicate()
+ retcode = process.poll()
+ if retcode:
+ cmd = kwargs.get("args")
+ if cmd is None:
+ cmd = popenargs[0]
+ raise subprocess.CalledProcessError(retcode, cmd, output=output)
+ return output
-folders = [r'../../images/50/orig/',
- r'../../images/50/rot33/',
- r'../../images/50/rot130/',
- r'../../images/50/scale1_2/',
- r'../../images/50/scale2/']
+class CalledProcessError(Exception):
+ def __init__(self, returncode, cmd, output=None):
+ self.returncode = returncode
+ self.cmd = cmd
+ self.output = output
+ def __str__(self):
+ return "Command '%s' returned non-zero exit status %d" % (
+ self.cmd, self.returncode)
+# overwrite CalledProcessError due to `output` keyword might be not available
+subprocess.CalledProcessError = CalledProcessError
-file_list = r'cache/file.list'
-tree_file = r'cache/hikm.tree'
-ivf_file = r'cache/ivf.file'
+
+
+
+###################################
+
+folders = [r'../../images/50/orig',
+ r'../../images/50/rot33',
+ r'../../images/50/rot130',
+ r'../../images/50/scale12',
+ r'../../images/50/scale2']
+
+res_dir = r'res'
+
+file_list = r'cache/file.list'
+tree_file = r'cache/hikm.tree'
+ivf_file = r'cache/ivf.file'
+
+ivf_config = r'ivf.config'
+tree_config = r'tree.config'
query_maker = r'../kurs/bin/query_maker.exe'
+ivf_w_params = [r'none', r'tfidf']
+ivf_n_params = [r'l1', r'l2']
+
+#ivf_w_params = [r'none', r'bin', r'tf', r'tfidf']
+#ivf_n_params = [r'none', r'l0', r'l1', r'l2']
+
+q_d_params = [r'l1', r'l2', r'cos']
+
+def getIvfCmdParams(w, n):
+ return r"IVF_CREATOR_OPTS='-W%(w)s -N%(n)s'" % \
+ {'w': ivf_w_params[w], 'n': ivf_n_params[n] }
+
+def writeIvfConfig(w, n):
+ f = open(ivf_config, 'wt')
+ f.write("weight = %(w)s\nnorm = %(n)s" % \
+ {'w': ivf_w_params[w], 'n': ivf_n_params[n] })
+ f.close()
+ return "IVF_CREATOR_OPTS=-c" + ivf_config
+
+
+#def writeTreeConfig(cl, lv):
+# f = open(tree_config, 'wt')
+# f.write("clustres = %(c)s\nleaves = %(l)s" % \
+# {'c': cl, 'l': lv })
+# f.close()
+# return "TREE_CREATOR_OPTS=-c" + tree_config
+
+def writeIvfConfigS(w, n):
+ f = open(ivf_config, 'wt')
+ f.write("weight = %(w)s\nnorm = %(n)s" % \
+ {'w': w, 'n': n })
+ f.close()
+ return "IVF_CREATOR_OPTS=-c" + ivf_config
+
+
+def writeTreeConfigS(cl, lv):
+ f = open(tree_config, 'wt')
+ f.write("clustres = %(c)s\nleaves = %(l)s" % \
+ {'c': cl, 'l': lv })
+ f.close()
+ return "TREE_CREATOR_OPTS=-c" + tree_config
+
####################################
-f = open(file_list, 'rt')
-fl = f.read().splitlines()
-f.close()
+fl = []
+try:
+ f = open(file_list, 'rt')
+ fl = f.read().splitlines()
+ f.close()
+except IOError as e:
+ print (e)
+ pass
+
def num2file(num):
return fl[int(num)]
####################################
-def make_query(query, tree, ivf):
- cmd = ' '.join([query_maker, '-i', query, '-t', tree, '-v', ivf, '-o --'])
+def make_query(query, tree, ivf, dist):
+ cmd = ' '.join([query_maker, '-i', query, '-t', tree, '-v', ivf, '-D', dist, '-o --'])
print(cmd)
- res = subprocess.check_output(cmd)
+ res = check_output(cmd)
return res.splitlines()
def fname(path):
return os.path.basename(path)
-def test(dir):
+def test(dir, dist):
files = os.listdir(dir)
res = {}
@@ -41,7 +123,7 @@ def test(dir):
good_count = 0
for f in files:
- qres = make_query(dir + f, tree_file, ivf_file)
+ qres = make_query(dir + r'/' + f, tree_file, ivf_file, dist)
fqres = [(num2file(b[0]),b[1]) for b in [a.split() for a in qres]]
res[f] = fqres
g = f == fname(fqres[0][0])
@@ -50,9 +132,86 @@ def test(dir):
good_count += 1
pass
- break
pass
return res, good, good_count
-a,b,c, = test(folders[4])
-print (a,b,c)
+#a,b,c, = test(folders[4])
+#print (a,b,c)
+
+
+def make_base(params = []):
+ prm = ['-j4']
+ prm.extend(params)
+ cmd = ['make', 'base']
+ cmd.extend(prm)
+ print (' '.join(cmd))
+ res = ''
+ try:
+ res = check_output(cmd, stderr = subprocess.STDOUT, shell=True)
+ except subprocess.CalledProcessError as e:
+ print(e)
+ print(e.output)
+ return False
+ print(res)
+ return True
+
+def make_testclean():
+ cmd = ['make', 'testclean']
+ try:
+ res = check_output(cmd, stderr = subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ print(e)
+ return False
+ print(res)
+ return True
+
+
+#make_base([writeIvfConfig(1,1), writeTreeConfig(3,200)])
+
+def run_test(f, d, w, n, cl, lv):
+ print({'f':fname(f), 'd':d, 'w':w, 'n':n, 'cl':cl, 'lv':lv})
+ res_file = "%(f)s__%(d)s__%(w)s__%(n)s__%(cl)d__%(lv)d.res" %\
+ {'f':fname(f), 'd':d, 'w':w, 'n':n, 'cl':cl, 'lv':lv}
+
+ rf = open(res_dir + r'/' + res_file, 'wb')
+
+ make_testclean()
+ make_base([writeIvfConfigS(w,n), writeTreeConfigS(cl, lv)])
+
+ a,b,c = test(f, d)
+ pickle.dump([ [f, d, w, n, cl, lv], [a,b,c] ], rf)
+
+ rf.close()
+ pass
+
+
+
+def run_folder(f):
+ for w in ivf_w_params:
+ for n in ivf_n_params:
+ for d in q_d_params:
+ for cl in [3,5,10]:
+ for lv in [20, 50, 100]:
+ run_test(f, d, w, n, cl, lv)
+ #return
+ pass
+ pass
+ pass
+ pass
+ pass
+ return
+
+
+def run_all():
+ for f in folders:
+ run_folder(f)
+ pass
+ return
+
+try:
+ run_all()
+except subprocess.CalledProcessError as e:
+ print(e)
+ print(e.output)
+
+os.system('pause')
View
10 kurs/tree_creator/main.cpp
@@ -35,6 +35,7 @@ void read_inlist_file(std::string const & file, str_vector & list)
void prepare(int argc, char* argv[], std::string& ofname, str_vector& sift_infiles, HIKMTree::Params& hikmParams)
{
std::string inlist_file;
+ std::string config;
bpo::options_description desc("");
desc.add_options()
@@ -42,6 +43,7 @@ void prepare(int argc, char* argv[], std::string& ofname, str_vector& sift_infil
("output,o", bpo::value(&ofname)->required(), "Output tree file")
("list,l", bpo::value(&inlist_file), "File with the list of input sift files")
("input,i", bpo::value(&sift_infiles), "Sift descriptors input files")
+ ("config,c", bpo::value(&config), "Config file")
;
bpo::options_description optParams("Tree parameters");
@@ -52,6 +54,9 @@ void prepare(int argc, char* argv[], std::string& ofname, str_vector& sift_infil
desc.add(optParams);
+ bpo::options_description config_file_options;
+ config_file_options.add(optParams);
+
bpo::positional_options_description p;
p.add("input", -1);
@@ -63,6 +68,11 @@ void prepare(int argc, char* argv[], std::string& ofname, str_vector& sift_infil
exit(0);
}
+ if (vm.count("config"))
+ {
+ bpo::store(bpo::parse_config_file<char>(vm["config"].as<std::string>().c_str(), config_file_options), vm);
+ }
+
bpo::notify(vm);
conflicting_options(vm, "input", "list");
View
4 kurs/tree_creator/tree_creator.vcxproj
@@ -76,11 +76,11 @@
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
- <SubSystem>Windows</SubSystem>
+ <SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
- <AdditionalDependencies>Image.lib;HIKMTree.lib;Util.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Image.lib;HIKMTree.lib;Sift.lib;Util.lib;libjpeg.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
View
14 scripts/Makefile
@@ -36,14 +36,14 @@ endef
$(foreach file,$(BASEFILES),$(eval $(call SIFT_FILE_template,$(file))))
$(TREE_FILE): $(ALL_SIFT_FILES) $(SIFTLIST_FILE) $(BASEFILES_LIST) | $(BASE_DIR)
- $(TREE_CREATOR) -o $@ -l $(SIFTLIST_FILE)
+ $(TREE_CREATOR) -o $@ -l $(SIFTLIST_FILE) $(TREE_CREATOR_OPTS)
%.word : $(TREE_FILE) %.sift | $(BASE_DIR)
$(IWORDS) $^ $@
$(IVF_FILE): $(TREE_FILE) $(ALL_WORD_FILES) $(WORDLIST_FILE) $(BASEFILES_LIST) | $(BASE_DIR)
- $(IVF_CREATOR) -o $@ -t $(TREE_FILE) -l $(WORDLIST_FILE)
+ $(IVF_CREATOR) -o $@ -t $(TREE_FILE) -l $(WORDLIST_FILE) $(IVF_CREATOR_OPTS)
$(FILELIST_FILE): $(BASEFILES_LIST) | $(BASE_DIR)
$(call write-to-file,$@,$(BASEFILES))
@@ -65,16 +65,16 @@ clean:
-rm -rf $(BASE_DIR)
testclean:
- -rm -f $(FILELIST_FILE)
- -rm -f $(SIFTLIST_FILE)
- -rm -f $(WORDLIST_FILE)
+ # -rm -f $(FILELIST_FILE)
+ # -rm -f $(SIFTLIST_FILE)
+ # -rm -f $(WORDLIST_FILE)
-rm -f $(TREE_FILE)
-rm -f $(IVF_FILE)
- -rm -f $(BASE_DIR)/*.word
+ rm -f $(BASE_DIR)/*.word
query: $(QUERY_IN_FILE)
$(QUERY_MAKER) -i $(shell cat $(QUERY_IN_FILE)) -t $(TREE_FILE) -v $(IVF_FILE) -o $(QUERY_OUT_FILE)
- query2html.py $(FILELIST_FILE) $(QUERY_IN_FILE) $(QUERY_OUT_FILE) $(RES_OUT_FILE)
+ python query2html.py $(FILELIST_FILE) $(QUERY_IN_FILE) $(QUERY_OUT_FILE) $(RES_OUT_FILE)
$(BASE_DIR):
mkdir -p $@
View
4 scripts/query2html.py
@@ -1,3 +1,4 @@
+import os
import sys
import urlparse
@@ -20,6 +21,9 @@
query = f.readline()
f.close()
+query = os.path.abspath(query).replace(r"cygdrive/d", r"D:")
+
+
f = open(query_out, 'rU')
ql = f.read().splitlines()
f.close()

No commit comments for this range

Something went wrong with that request. Please try again.