def run(self, paths = []):
		for item in SideBarSelection(paths).getSelectedDirectoriesOrDirnames():
			object = Object()
			object.item = item
			object.command = ['git', 'init']
			object.to_status_bar = True
			SideBarGit().run(object)
	def run(self, paths = []):
		for item in SideBarSelection(paths).getSelectedItems():
			object = Object()
			object.item = item
			object.command = ['git', 'status', '--untracked-files=all', '--ignored', '--', item.forCwdSystemName()]
			object.title = 'Status: '+item.name()
			SideBarGit().run(object)
	def run(self, paths = [], input = False, content = ''):
		if input == False:
			SideBarGit().prompt('Enter a commit message: ', '', self.run, paths)
		elif content != '':
			import sys
			content = (content[0].upper() + content[1:]).encode(sys.getfilesystemencoding())
			for repo in SideBarGit().getSelectedRepos(SideBarSelection(paths).getSelectedItems()):
				commitCommandAdd = ['git', 'add', '--']
				commitCommandCommit = ['git', 'commit', '-m', content, '--']
				for item in repo.items:
					commitCommandAdd.append(item.forCwdSystemPathRelativeFromRecursive(repo.repository.path()))
					commitCommandCommit.append(item.forCwdSystemPathRelativeFrom(repo.repository.path()))
				object = Object()
				object.item = repo.repository
				object.command = commitCommandAdd
				SideBarGit().run(object)
				object = Object()
				object.item = repo.repository
				object.to_status_bar = True
				object.command = commitCommandCommit
				SideBarGit().run(object)
				object = Object()
				object.item = repo.repository
				object.command = ['git','push']
				SideBarGit().run(object, True)
	def run(self, paths = []):
			for repo in SideBarGit().getSelectedRepos(SideBarSelection(paths).getSelectedItems()):
				object = Object()
				object.item = repo.repository
				object.command = ['git', 'checkout', 'master']
				object.to_status_bar = True
				SideBarGit().run(object)
	def run(self, paths = []):
		for item in SideBarGit().getSelectedRepos(SideBarSelection(paths).getSelectedItems()):
			object = Object()
			object.item = item.repository
			object.command = ['git','push','--tags']
			object.to_status_bar = True
			SideBarGit().run(object, True)
	def run(self, paths = []):
		for item in SideBarSelection(paths).getSelectedItems():
			object = Object()
			object.item = item
			object.command = ['git', 'reflog', '--no-color', '--', item.forCwdSystemName()]
			object.title = 'Reflog: '+item.name()
			SideBarGit().run(object)
	def run(self, paths = []):
		for item in SideBarSelection(paths).getSelectedItems():
			object = Object()
			object.item = item
			object.command = ['git', 'log', '--stat', '--graph', '--decorate', '--no-color', '--', item.forCwdSystemName()]
			object.title = 'Log: '+item.name()
			object.no_results = 'No log to show'
			SideBarGit().run(object)
	def run(self, paths = []):
		for item in SideBarSelection(paths).getSelectedItems():
			object = Object()
			object.item = item
			object.command = ['git', 'reflog', '--no-color', '--', item.forCwdSystemName()]
			object.title = 'Reflog: '+item.name()
			object.syntax_file = 'Packages/Git/Git Graph.tmLanguage'
			SideBarGit().run(object)
	def run(self, paths = []):
		for item in SideBarSelection(paths).getSelectedItems():
			object = Object()
			object.item = item
			object.command = ['git', 'blame', '--no-color', '--', item.forCwdSystemName()]
			object.title = 'Blame: '+item.name()
			object.word_wrap = False
			SideBarGit().run(object)
	def run(self, paths = []):
		for repo in SideBarGit().getSelectedRepos(SideBarSelection(paths).getSelectedItems()):
			object = Object()
			object.item = repo.repository
			object.command = ['git', 'branch', '-v']
			object.silent = True
			SideBarGit().run(object)
			SideBarGit().quickPanel(self.on_done, repo.repository, (SideBarGit.last_stdout.decode('utf-8')).split('\n'))
	def run(self, paths = [], confirm = False, drop_me = ''):
		if confirm == False:
			SideBarGit().confirm('Undo Commit? ', self.run, paths)
		else:
			for item in SideBarGit().getSelectedRepos(SideBarSelection(paths).getSelectedItems()):
				object = Object()
				object.item = item.repository
				object.command = ['git', 'reset', '--soft', 'HEAD^']
				SideBarGit().run(object)
	def run(self, paths = [], confirm = False, drop_me = ''):
		if confirm == False:
			SideBarGit().confirm('Fetch from default? ', self.run, paths)
		else:
			for item in SideBarGit().getSelectedRepos(SideBarSelection(paths).getSelectedItems()):
				object = Object()
				object.item = item.repository
				object.command = ['git','fetch']
				SideBarGit().run(object, True)
	def run(self, paths = []):
		for repo in SideBarGit().getSelectedRepos(SideBarSelection(paths).getSelectedItems()):
			command = ['git', 'add', '--']
			for item in repo.items:
				command.append(item.forCwdSystemPathRelativeFromRecursive(repo.repository.path()))
			object = Object()
			object.item = repo.repository
			object.command = command
			SideBarGit().run(object)
	def run(self, paths = []):
		import sys
		for item in SideBarSelection(paths).getSelectedItems():
			object = Object()
			object.item = item
			object.command = ['git', 'log', '-n', '50', '--pretty=format:%h %s'.encode(sys.getfilesystemencoding()), '--no-color', '--', item.forCwdSystemName()]
			object.title = 'Log: '+item.name()
			object.no_results = 'No log to show'
			SideBarGit().run(object)
	def run(self, paths = [], input = False, content = ''):
		if input == False:
			SideBarGit().prompt('Fetch with options: ', "git fetch aRemoteName aRemoteBranch:aLocalBranch", self.run, paths)
		elif content != '':
			import sys
			for item in SideBarGit().getSelectedRepos(SideBarSelection(paths).getSelectedItems()):
				object = Object()
				object.item = item.repository
				object.command = content.encode(sys.getfilesystemencoding()).split(' ')
				SideBarGit().run(object, True)
	def run(self, paths = []):
		for repo in SideBarGit().getSelectedRepos(SideBarSelection(paths).getSelectedItems()):
			commitCommand = ['git', 'commit', '--amend', '-C', 'HEAD', '--']
			for item in repo.items:
				commitCommand.append(item.forCwdSystemPathRelativeFrom(repo.repository.path()))
			object = Object()
			object.item = repo.repository
			object.to_status_bar = True
			object.command = commitCommand
			SideBarGit().run(object)
Пример #17
0
    def GetFeature(self, dataset):
        if os.path.exists(self.SESSION_SAVE_PATH + '.meta'):
            with tf.Session(config=self._config) as sess:
                self.InitVariables()
                self._saver = tf.train.Saver()
                self._saver.restore(sess, self.SESSION_SAVE_PATH)
                PrintWithTime("Restored model from " + self.SESSION_SAVE_PATH)
                database = Object()

                dim = self.NetPQ.X.get_shape().as_list()[1]

                Nb = dataset.DataNum
                database_feature = np.zeros([Nb, dim], dtype=np.float32)
                database.label = np.zeros([Nb, self._classNum], dtype=np.int16)

                codes = np.zeros([Nb, self._stackLevel], np.int32)

                total_db = (Nb // self._batchSize) + 1
                with trange(total_db, ncols=50) as t:
                    for i in t:
                        idx = np.arange(start=i * self._batchSize,
                                        stop=np.minimum(
                                            Nb, (i + 1) * self._batchSize),
                                        step=1)
                        inp, label = dataset.Get(idx)
                        num = inp.shape[0]
                        database.label[i *
                                       self._batchSize:(i * self._batchSize +
                                                        num)] = label
                        if inp.shape[0] != self._batchSize:
                            placeholder = np.zeros([
                                self._batchSize - inp.shape[0], inp.shape[1],
                                inp.shape[2], inp.shape[3]
                            ])
                            inp = np.concatenate((inp, placeholder))

                        out, hardCode = sess.run(
                            [self.NetPQ.X, self.NetPQ.HardCode],
                            {self.Input: inp})
                        hardCode = sess.run(self.NetPQ.HardCode,
                                            {self.Input: inp})
                        codes[i * self._batchSize:(i * self._batchSize) +
                              num] = np.array(hardCode, np.int32).T[:num]
                        database_feature[i *
                                         self._batchSize:(i *
                                                          self._batchSize) +
                                         num] = out[:num]
                database.output = database_feature

                # [N, M]
                database.codes = codes
                codebook = sess.run(self.NetPQ.Codebook)
                scale = sess.run(self.NetPQ.CodebookScale)
            return database, codebook, scale
	def run(self, paths = [], input = False, content = ''):
		if input == False:
			SideBarGit().prompt('Enter a commit message: ', '', self.run, paths)
		elif content != '':
			import sys
			content = (content[0].upper() + content[1:]).encode(sys.getfilesystemencoding())
			for item in SideBarGit().getSelectedRepos(SideBarSelection(paths).getSelectedItems()):
				object = Object()
				object.item = item.repository
				object.to_status_bar = True
				object.command = ['git', 'commit', '-a', '-m', content]
				SideBarGit().run(object)
	def on_done(self, extra, data, result):
			result = data[result].strip()
			if result.startswith("*"):
				return
			else:
				import sys
				branch = result.split(' ')[0]
				object = Object()
				object.item = extra
				object.command = ['git', 'branch', '-d', branch.encode(sys.getfilesystemencoding())]
				object.to_status_bar = True
				SideBarGit().run(object)
	def run(self, paths = [], input = False, content = ''):
		if input == False:
			SideBarGit().prompt('New branch: ', "", self.run, paths)
		elif content != '':
			import sys
			content = content.encode(sys.getfilesystemencoding())
			for repo in SideBarGit().getSelectedRepos(SideBarSelection(paths).getSelectedItems()):
				object = Object()
				object.item = repo.repository
				object.command = ['git', 'checkout', '-b', content]
				object.to_status_bar = True
				SideBarGit().run(object)
	def run(self, paths = [], input = False, content = ''):
		if input == False:
			SideBarGit().prompt('Remote add: ', "git remote add aRemoteName "+sublime.get_clipboard(), self.run, paths)
		elif content != '':
			import sys
			content = content.encode(sys.getfilesystemencoding())
			for repo in SideBarGit().getSelectedRepos(SideBarSelection(paths).getSelectedItems()):
				object = Object()
				object.item = repo.repository
				object.command = content.split(' ')
				object.to_status_bar = True
				SideBarGit().run(object)
	def run(self, paths = [], confirm = False, drop_me = ''):
		if confirm == False:
			SideBarGit().confirm('Remove from repository, and remove local copies? ', self.run, paths)
		else:
			for repo in SideBarGit().getSelectedRepos(SideBarSelection(paths).getSelectedItems()):
				command = ['git', 'rm', '-r', '-f', '--']
				for item in repo.items:
					command.append(item.forCwdSystemPathRelativeFrom(repo.repository.path()))
				object = Object()
				object.item = repo.repository
				object.command = command
				SideBarGit().run(object)
	def run(self, paths = [], confirm = False, drop_me = ''):
		failed = False
		if confirm == False:
			SideBarGit().confirm('Unstage selected items? ', self.run, paths)
		else:
			for item in SideBarSelection(paths).getSelectedItems():
				object = Object()
				object.item = item
				object.command = ['git', 'reset', 'HEAD', '--', item.forCwdSystemName()]
				if not SideBarGit().run(object):
					failed = True
			if not failed:
				SideBarGit().status('Unstage selected items')
	def run(self, paths = [], input = False, content = ''):
		failed = False
		if input == False:
			SideBarGit().prompt('Checkout repository to object: ', '', self.run, paths)
		elif content != '':
			import sys
			for item in SideBarGit().getSelectedRepos(SideBarSelection(paths).getSelectedItems()):
				object = Object()
				object.item = item.repository
				object.command = ['git', 'checkout', content.encode(sys.getfilesystemencoding())]
				if not SideBarGit().run(object):
					failed = True
			if not failed:
				SideBarGit().status('Checkout repository to "'+content+'"')
	def run(self, paths = [], input = False, content = ''):
		failed = False
		if input == False:
			SideBarGit().prompt('Enter URL to clone: ', sublime.get_clipboard(), self.run, paths)
		elif content != '':
			import sys
			for item in SideBarSelection(paths).getSelectedDirectoriesOrDirnames():
				object = Object()
				object.item = item
				object.command = ['git', 'clone', '--recursive', content.encode(sys.getfilesystemencoding())]
				object.to_status_bar = True
				if not SideBarGit().run(object, True):
					failed = True
			if not failed:
				SideBarGit().status('Cloned URL "'+content+'"')
Пример #26
0
    def _move_moveView(self, window, view, location, active_view):
        if active_view == view:
            is_active_view = True
        else:
            is_active_view = False

        options = Object()

        options.scroll = view.viewport_position()

        options.selections = []
        for sel in view.sel():
            line_s, col_s = view.rowcol(sel.a)
            line_e, col_e = view.rowcol(sel.b)
            options.selections.append([view.text_point(line_s, col_s), view.text_point(line_e, col_e)])

        options.marks = []
        for sel in view.get_regions("mark"):
            line_s, col_s = view.rowcol(sel.a)
            line_e, col_e = view.rowcol(sel.b)
            options.marks.append([view.text_point(line_s, col_s), view.text_point(line_e, col_e)])

        options.bookmarks = []
        for sel in view.get_regions("bookmarks"):
            line_s, col_s = view.rowcol(sel.a)
            line_e, col_e = view.rowcol(sel.b)
            options.bookmarks.append([view.text_point(line_s, col_s), view.text_point(line_e, col_e)])

        options.folds = []
        if int(sublime.version()) >= 2167:
            for sel in view.folded_regions():
                line_s, col_s = view.rowcol(sel.a)
                line_e, col_e = view.rowcol(sel.b)
                options.folds.append([view.text_point(line_s, col_s), view.text_point(line_e, col_e)])
        else:
            for sel in view.unfold(sublime.Region(0, view.size())):
                line_s, col_s = view.rowcol(sel.a)
                line_e, col_e = view.rowcol(sel.b)
                options.folds.append([view.text_point(line_s, col_s), view.text_point(line_e, col_e)])

        window.focus_view(view)
        if view.is_dirty():
            options.content = view.substr(sublime.Region(0, view.size()))
            view.window().run_command("revert")
        else:
            options.content = False
        window.run_command("close")

        view = window.open_file(location)
        sublime.set_timeout(lambda: self._move_restoreView(view, options), 200)

        if is_active_view:
            window.focus_view(view)
            return view
        else:
            window.focus_view(active_view)
            return active_view
	def run(self, paths = []):
		for item in SideBarSelection(paths).getSelectedItems():
			object = Object()
			object.item = item
			object.command = ['git', 'diff', '--no-color', 'origin/master..', '--', item.forCwdSystemName()]
			object.title = 'Diff: '+item.name()+'.diff'
			object.no_results = 'No differences to show'
			object.syntax_file = 'Packages/Diff/Diff.tmLanguage'
			object.word_wrap = False
			SideBarGit().run(object)
	def run(self, paths = []):
		for item in SideBarSelection(paths).getSelectedItems():
			object = Object()
			object.item = item
			object.command = ['git', 'log', '-p', '--decorate', '--no-color', '--', item.forCwdSystemName()]
			object.title = 'Log: '+item.name()
			object.no_results = 'No log to show'
			object.syntax_file = 'Packages/Diff/Diff.tmLanguage'
			object.word_wrap = False
			SideBarGit().run(object)
	def run(self, paths = []):
		for item in SideBarSelection(paths).getSelectedItems():
			object = Object()
			object.item = item
			object.command = ['git', 'log', '-n', '30', '--pretty=short', '--decorate', '--graph', '--no-color', '--', item.forCwdSystemName()]
			object.title = 'Log: '+item.name()
			object.no_results = 'No log to show'
			object.syntax_file = 'Packages/Git/Git Graph.tmLanguage'
			SideBarGit().run(object)
	def run(self, paths = [], confirm = False, drop_me = ''):
		failed = False
		if confirm == False:
			SideBarGit().confirm('Discard changes to tracked, unstage and clean untracked on selected items? ', self.run, paths)
		else:
			for item in SideBarSelection(paths).getSelectedItems():
				object = Object()
				object.item = item
				object.command = ['git', 'checkout', 'HEAD', '--', item.forCwdSystemName()]
				if not SideBarGit().run(object):
					failed = True
				object = Object()
				object.item = item
				object.command = ['git', 'reset', 'HEAD', '--', item.forCwdSystemName()]
				if not SideBarGit().run(object):
					failed = True
				object = Object()
				object.item = item
				object.command = ['git', 'clean', '-f', '-d', '--', item.forCwdSystemName()]
				if not SideBarGit().run(object):
					failed = True
			if not failed:
				SideBarGit().status('Discarded changes to tracked, unstage and cleaned untracked on selected items')
	def run(self, paths = [], input = False, content = ''):
		if input == False:
			SideBarGit().prompt('[SideBarGit@SublimeText ./]:', 'git ', self.run, paths)
		elif content != '':
			import sys
			for item in SideBarSelection(paths).getSelectedDirectoriesOrDirnames():
				object = Object()
				object.item = item
				object.command = content.encode(sys.getfilesystemencoding()).split(' ')
				object.title = content
				object.no_results = 'No output'
				object.syntax_file = 'Packages/Diff/Diff.tmLanguage'
				SideBarGit().run(object)
Пример #32
0
    def GetFeature(self, queryX, queryY, dataset):
        if os.path.exists(self.SESSION_SAVE_PATH + '.meta'):
            with tf.Session(config=self._config) as sess:
                self.InitVariables()
                self._saver = tf.train.Saver()
                self._saver.restore(sess, self.SESSION_SAVE_PATH)
                PrintWithTime("Restored model from " + self.SESSION_SAVE_PATH)

                query = Object()
                database = Object()
                query.label = queryY

                Nq = queryX.shape[0]

                dim = self.NetPQ.X.get_shape().as_list()[1]

                query_feature = np.zeros([Nq, dim], np.float32)
                for i in range((Nq // self._batchSize) + 1):
                    inp = queryX[i * self._batchSize:(i + 1) * self._batchSize]
                    num = inp.shape[0]
                    if inp.shape[0] != self._batchSize:
                        placeholder = np.zeros([
                            self._batchSize - inp.shape[0], inp.shape[1],
                            inp.shape[2], inp.shape[3]
                        ])
                        inp = np.concatenate((inp, placeholder))

                    out = sess.run(self.NetPQ.X, {self.Input: inp})
                    query_feature[i * self._batchSize:(i * self._batchSize) +
                                  num] = out[:num]
                query.output = query_feature

                Nb = dataset.DataNum
                database_feature = np.zeros([Nb, dim], dtype=np.float32)
                database.label = np.zeros([Nb, self._classNum], dtype=np.int16)

                codes = np.zeros([Nb, self._stackLevel], np.int32)

                start = time.time()
                print('Encoding database')
                total_db = (Nb // self._batchSize) + 1
                with trange(total_db, ncols=50) as t:
                    for i in t:
                        idx = np.arange(start=i * self._batchSize,
                                        stop=np.minimum(
                                            Nb, (i + 1) * self._batchSize),
                                        step=1)
                        inp, label = dataset.Get(idx)
                        num = inp.shape[0]
                        database.label[i *
                                       self._batchSize:(i * self._batchSize +
                                                        num)] = label
                        if inp.shape[0] != self._batchSize:
                            placeholder = np.zeros([
                                self._batchSize - inp.shape[0], inp.shape[1],
                                inp.shape[2], inp.shape[3]
                            ])
                            inp = np.concatenate((inp, placeholder))

                        out, hardCode = sess.run(
                            [self.NetPQ.X, self.NetPQ.HardCode],
                            {self.Input: inp})
                        hardCode = sess.run(self.NetPQ.HardCode,
                                            {self.Input: inp})
                        codes[i * self._batchSize:(i * self._batchSize) +
                              num] = np.array(hardCode, np.int32).T[:num]
                        database_feature[i *
                                         self._batchSize:(i *
                                                          self._batchSize) +
                                         num] = out[:num]

                end = time.time()
                print('Encoding Complete')
                print('Time:', end - start)
                print('Average time for single sample:')
                print((end - start) / Nb)
                database.output = database_feature
                scale = sess.run(self.NetPQ.CodebookScale)
                # [N, M]
                database.codes = codes
                return query, database, scale
Пример #33
0
    def Evaluate(self, queryX, queryY, dataset):
        print(self._recallatR if self._recallatR > 0 else 'all')
        if os.path.exists(SESSION_SAVE_PATH + '.meta'):
            with tf.Session(config=self._config) as sess:
                self.InitVariables()
                self._saver = tf.train.Saver()
                self._saver.restore(sess, SESSION_SAVE_PATH)
                PrintWithTime("Restored model from " + SESSION_SAVE_PATH)

                query = Object()
                database = Object()
                query.label = queryY

                Nq = queryX.shape[0]

                dim = self.NetPQ.X.get_shape().as_list()[1]

                query.output = np.zeros([Nq, dim], np.float16)
                for i in range((Nq // self._batchSize) + 1):
                    inp = queryX[i * self._batchSize:(i + 1) * self._batchSize]
                    num = inp.shape[0]
                    if inp.shape[0] != self._batchSize:
                        placeholder = np.zeros([
                            self._batchSize - inp.shape[0], inp.shape[1],
                            inp.shape[2], inp.shape[3]
                        ])
                        inp = np.concatenate((inp, placeholder))

                    out = sess.run(self.NetPQ.X, {self.Input: inp})
                    query.output[i * self._batchSize:(i * self._batchSize) +
                                 num] = out[:num]

                Nb = dataset.DataNum
                database_feature = np.zeros([Nb, dim], dtype=np.float16)
                database.label = np.zeros([Nb, self._classNum], dtype=np.int16)

                database.codes = np.zeros([Nb, self._stackLevel], np.int32)

                start = time.time()
                print('Encoding database')
                total_db = (Nb // self._batchSize) + 1
                for i in range(total_db):
                    idx = np.arange(start=i * self._batchSize,
                                    stop=np.minimum(Nb,
                                                    (i + 1) * self._batchSize),
                                    step=1)
                    inp, label = dataset.Get(idx)
                    print(inp.shape, label.shape)
                    num = inp.shape[0]
                    database.label[i * self._batchSize:(i * self._batchSize +
                                                        num)] = label
                    if inp.shape[0] != self._batchSize:
                        placeholder = np.zeros([
                            self._batchSize - inp.shape[0], inp.shape[1],
                            inp.shape[2], inp.shape[3]
                        ])
                        inp = np.concatenate((inp, placeholder))

                    hardCode = sess.run(self.NetPQ.HardCode, {self.Input: inp})
                    database.codes[i * self._batchSize:(i * self._batchSize) +
                                   num] = np.array(hardCode, np.int32).T[:num]
                    database_feature[i *
                                     self._batchSize:(i * self._batchSize) +
                                     num] = out[:num]
                    ProgressBar((i + 1) / total_db)

                end = time.time()
                print('Encoding Complete')
                print('Time:', end - start)
                print('Average time for single sample:')
                print((end - start) / Nb)
                database.output = database_feature

                del dataset

                codebook = sess.run(self.NetPQ.Codebook)

                res = mAP(
                    codebook, self._recallatR if self._recallatR > 0 else
                    database.codes.shape[0], database)

                return res.AQD_mAP(query)
Пример #34
0
    def GetRetrievalMat(self, queryX, queryY, dataset):
        self.R = self._recallatR if self._recallatR > 0 else dataset.DataNum
        if os.path.exists(SESSION_SAVE_PATH + '.meta'):
            with tf.Session(config=self._config) as sess:
                self.InitVariables()
                self._saver = tf.train.Saver()
                self._saver.restore(sess, SESSION_SAVE_PATH)
                PrintWithTime("Restored model from " + SESSION_SAVE_PATH)

                query = Object()
                database = Object()
                query.label = queryY

                Nq = queryX.shape[0]

                dim = self.NetPQ.X.get_shape().as_list()[1]

                query_feature = np.zeros([Nq, dim], np.float16)
                for i in range((Nq // self._batchSize) + 1):
                    inp = queryX[i * self._batchSize:(i + 1) * self._batchSize]
                    num = inp.shape[0]
                    if inp.shape[0] != self._batchSize:
                        placeholder = np.zeros([
                            self._batchSize - inp.shape[0], inp.shape[1],
                            inp.shape[2], inp.shape[3]
                        ])
                        inp = np.concatenate((inp, placeholder))

                    out = sess.run(self.NetPQ.X, {self.Input: inp})
                    query_feature[i * self._batchSize:(i * self._batchSize) +
                                  num] = out[:num]
                query.output = query_feature

                Nb = dataset.DataNum
                database.label = np.zeros([Nb, self._classNum], dtype=np.int16)

                codes = np.zeros([Nb, self._stackLevel], np.int32)

                total_db = (Nb // self._batchSize) + 1
                for i in range(total_db):
                    idx = np.arange(start=i * self._batchSize,
                                    stop=np.minimum(Nb,
                                                    (i + 1) * self._batchSize),
                                    step=1)
                    inp, label = dataset.Get(idx)
                    print(inp.shape, label.shape)
                    num = inp.shape[0]
                    database.label[i * self._batchSize:(i * self._batchSize +
                                                        num)] = label
                    if inp.shape[0] != self._batchSize:
                        placeholder = np.zeros([
                            self._batchSize - inp.shape[0], inp.shape[1],
                            inp.shape[2], inp.shape[3]
                        ])
                        inp = np.concatenate((inp, placeholder))

                    hardCode = sess.run(self.NetPQ.HardCode, {self.Input: inp})
                    codes[i * self._batchSize:(i * self._batchSize) +
                          num] = np.array(hardCode, np.int32).T[:num]
                    ProgressBar((i + 1) / total_db)

                # [N, M]
                database.codes = codes
                codebook = sess.run(self.NetPQ.Codebook)
                # np.save('database_codes_DSQ', codes)
            db = mAP.Quantize_AQ(database.codes, codebook, 4).T

            del dataset
            id_all = np.zeros([query.output.shape[0], self.R], np.int)
            retrieval_mat = np.zeros([query.output.shape[0], self.R], np.bool)
            for j in range(query.output.shape[0] // 50 + 1):
                q = query.output[j * 50:(j + 1) * 50]
                d = -np.dot(q, db)
                ids = np.argsort(d, 1)
                for i in range(d.shape[0]):
                    label = query.label[j * 50 + i, :]
                    label[label == 0] = -1
                    idx = ids[i, :]
                    imatch = np.sum(database.label[idx[0:self.R], :] == label,
                                    1) > 0
                    id_all[j * 50 + i] = idx[:self.R]
                    retrieval_mat[j * 50 + i] = imatch[:self.R]
            np.save('retrievalMat_' + self.DatasetName, retrieval_mat)
            np.save('ids', id_all)
            return retrieval_mat, id_all