def reset(self, options): #for imagefolder in self._imagefolders: for directory, _subdirs, files in os.walk(options.IMAGE_FOLDER): for f in files: imagefile = os.path.join(directory,f) base = os.path.basename(f) rawwordbag = normal_wordbag(base) if rawwordbag & self._imageexts != []: wordbag = rawwordbag - self._imageexts # print wordbag, imagefile self._db [wordbag] = imagefile
def find(self, input): # print self # print "Find: ", input input = normal_wordbag(input) # print "query: ", input if input in self._db: try: outstr = self._db[input] except: logging.error( "Cannot find %s in image database\n", input) return outstr # TODO: partial find return None
def tagwords(*tagnames): out = set() for tagname in tagnames: out = out or normal_wordbag(tags[tagname]) return out