def __init__(self, filename): Config.__init__(self, filename) self.meta = META() self.constraints = CONSTRAINTS() self.mp3tags = MP3TAGS() self.m4atags = M4ATAGS() self.paths = PATHS() self.meta.version = self.Get(int, "meta", "version", 0) # 0 = inf self.constraints.pathlen = self.Get(int, "constraints", "pathlen", 0) # 0 = inf self.constraints.charset = self.Get(str, "constraints", "charset", "default") self.constraints.forcemp3 = self.Get(bool, "constraints", "forcemp3", False) self.mp3tags.optimize = self.Get(bool, "mp3tags", "optimize", False) self.paths.musicdir = self.Get(str, "paths", "musicdir", "/") # remove leading / because it is interpreted as "start at root" by join if self.paths.musicdir[0] == "/": self.paths.musicdir = self.paths.musicdir[1:] self.mp3tags.prescale = self.Get(str, "mp3tags", "prescale", "None") if self.mp3tags.prescale.lower() == "none": self.mp3tags.prescale = None elif self.mp3tags.prescale.lower() == "false": self.mp3tags.prescale = None self.mp3tags.noartwork = self.Get(bool, "mp3tags", "noartwork", "False") self.mp3tags.forceid3v230 = self.Get(bool, "mp3tags", "forceID3v230", "False") self.m4atags.optimize = self.Get(bool, "m4atags", "optimize", False)
def __init__(self, path, musicdb=None): Config.__init__(self, os.path.join(path, "state.ini")) self.musicdb = musicdb self.path = path self.meta = META self.meta.version = self.Get(int, "meta", "version", 0) # 0 = inf if self.meta.version < 2: logging.info("Updating mdbstate/state.ini to version 2") self.Set("meta", "version", 2)
def __init__(self, path): Config.__init__(self, path) version = self.Get(int, "meta", "version", 0) if version < 1: logging.info("Creating webui.ini") self.Set("meta", "version", 1) self.Set("WebUI", "videomode", "disabled") self.Set("WebUI", "lyrics", "enabled") self.Set("debug", "blurartwork", False)
def __init__(self, filename): Config.__init__(self, filename) self.fs = Filesystem("/") logging.info("Reading and checking WKServer Configuration") # [meta] self.meta = META() self.meta.version = self.Get(int, "meta", "version", 1) # [websocket] self.websocket = WEBSOCKET() self.websocket.address = self.Get(str, "websocket","address", "127.0.0.1") self.websocket.port = self.Get(int, "websocket","port", 9000) self.websocket.url = self.Get(str, "websocket","url", "wss://localhost:9000") self.websocket.apikey = self.Get(str, "websocket","apikey", None) if not self.websocket.apikey: logging.warning("Value of [websocket]->apikey is not set!") self.caldav = CALDAV() self.caldav.username = self.Get(str, "caldav","username", "user") self.caldav.password = self.Get(str, "caldav","password", "password") self.caldav.url = self.Get(str, "caldav","url", "https://localhost:443") # [TLS] self.tls = TLS() self.tls.cert = self.GetFile( "tls", "cert", "/dev/null") self.tls.key = self.GetFile( "tls", "key", "/dev/null") if self.tls.cert == "/dev/null" or self.tls.key == "/dev/null": logging.warning("You have to set a valid TLS certificate and key!") # [log] self.log = LOG() self.log.logfile = self.Get(str, "log", "logfile", "stderr") self.log.loglevel = self.Get(str, "log", "loglevel", "WARNING") if not self.log.loglevel in ["DEBUG", "INFO", "WARNING", "ERROR"]: logging.error("Invalid loglevel for [log]->loglevel. Loglevel must be one of the following: DEBUG, INFO, WARNING, ERROR") self.log.debugfile = self.Get(str, "log", "debugfile", None) if self.log.debugfile == "/dev/null": self.log.debugfile = None self.log.ignore = self.Get(str, "log", "ignore", None, islist=True) # [debug] self.debug = DEBUG() logging.info("\033[1;32mdone")
# evaluate search kwargs = dict(score_thresh=0.5, base_iou_thresh=0.5, dump_json=os.path.join(cfg.expr_dir, 'results.json')) if "ssm" == cfg.benchmark: kwargs.update({"gallery_size": cfg.gallery_size}) ap, topk, accs, recall = imdb.evaluate_search(gallery_boxes, gallery_features, probe_features['feat'], **kwargs) logger.msg('search ranking:') logger.msg(' recall = {:.2%}'.format( recall)) # does the true_positive of a probe been detected. logger.msg(' mAP = {:.2%}'.format(ap)) for i, k in enumerate(topk): logger.msg(' top-{:2d} = {:.2%}'.format(k, accs[i])) end = time.time() print("test time: %0.1fmin" % ((end - start) / 60)) if __name__ == '__main__': cfg = Config().parse() if cfg.is_test: with torch.no_grad(): evaluate(cfg) else: shutil.copy(inspect.getfile(main), cfg.expr_dir) main(cfg)
def __init__(self, filename): Config.__init__(self, filename) self.fs = Filesystem("/") logging.info("Reading and checking MusicDB Configuration") # [meta] self.meta = META() self.meta.version = self.Get(int, "meta", "version", 1) if self.meta.version < 2: logging.warning("Version of musicdb.ini is too old. Please update the MusicDB Configuration!") # [server] self.server = SERVER() self.server.pidfile = self.Get(str, "server", "pidfile", "/opt/musicdb/data/musicdb.pid") self.server.statedir = self.Get(str, "server", "statedir", "/opt/musicdb/data/mdbstate") self.server.fifofile = self.Get(str, "server", "fifofile", "/opt/musicdb/data/musicdb.fifo") # [websocket] self.websocket = WEBSOCKET() self.websocket.address = self.Get(str, "websocket","address", "127.0.0.1") self.websocket.port = self.Get(int, "websocket","port", 9000) self.websocket.url = self.Get(str, "websocket","url", "wss://localhost:9000") self.websocket.opentimeout = self.Get(int, "websocket","opentimeout", 10) self.websocket.closetimeout = self.Get(int, "websocket","closetimeout", 5) self.websocket.apikey = self.Get(str, "websocket","apikey", None) if not self.websocket.apikey: logging.warning("Value of [websocket]->apikey is not set!") # [TLS] self.tls = TLS() self.tls.cert = self.GetFile( "tls", "cert", "/dev/null") self.tls.key = self.GetFile( "tls", "key", "/dev/null") if self.tls.cert == "/dev/null" or self.tls.key == "/dev/null": logging.warning("You have to set a valid TLS certificate and key!") # [database] self.database = DATABASE() self.database.path = self.GetFile( "database", "path", "/opt/musicdb/data/music.db") # [music] self.music = MUSIC() self.music.path = self.GetDirectory("music", "path", "/var/music") self.music.owner = self.Get(str, "music", "owner", "user") self.music.group = self.Get(str, "music", "group", "musicdb") try: pwd.getpwnam(self.music.owner) except KeyError: logging.warning("The group name for [music]->owner is not an existing UNIX user!") try: grp.getgrnam(self.music.group) except KeyError: logging.warning("The group name for [music]->group is not an existing UNIX group!") ignorelist = self.Get(str, "music", "ignoreartists","lost+found") ignorelist = ignorelist.split("/") self.music.ignoreartists = [item.strip() for item in ignorelist] ignorelist = self.Get(str, "music", "ignorealbums", "") ignorelist = ignorelist.split("/") self.music.ignorealbums = [item.strip() for item in ignorelist] ignorelist = self.Get(str, "music", "ignoresongs", ".directory / desktop.ini / Desktop.ini / .DS_Store / Thumbs.db") ignorelist = ignorelist.split("/") self.music.ignoresongs = [item.strip() for item in ignorelist] # [artwork] self.artwork = ARTWORK() self.artwork.path = self.GetDirectory("artwork", "path", "/opt/musicdb/data/artwork") self.artwork.scales = self.Get(int, "artwork", "scales", "50, 150, 500", islist=True) for s in [50, 150, 500]: if not s in self.artwork.scales: logging.error("Missing scale in [artwork]->scales: The web UI expects a scale of %d (res: %dx%d)", s, s, s) self.artwork.manifesttemplate=self.GetFile( "artwork", "manifesttemplate", "/opt/musicdb/server/manifest.txt", logging.warning) # a missing manifest does not affect the main functionality self.artwork.manifest = self.Get(str, "artwork", "manifest", "/opt/musicdb/server/webui/manifest.appcache") # [extern] self.extern = EXTERN() self.extern.configtemplate = self.GetFile( "extern", "configtemplate","/opt/musicdb/server/share/extconfig.ini") self.extern.statedir = self.Get(str, "extern", "statedir", ".mdbstate") self.extern.configfile = self.Get(str, "extern", "configfile", "config.ini") self.extern.songmap = self.Get(str, "extern", "songmap", "songmap.csv") # [tracker] self.tracker = TRACKER() self.tracker.dbpath = self.GetFile( "tracker", "dbpath", "/opt/musicdb/data/tracker.db") self.tracker.cuttime = self.Get(int, "tracker", "cuttime", "30") # [lycra] self.lycra = LYCRA() self.lycra.dbpath = self.GetFile( "lycra", "dbpath", "/opt/musicdb/data/lycra.db") # [Icecast] self.icecast = ICECAST() self.icecast.port = self.Get(int, "Icecast", "port", "6666") self.icecast.user = self.Get(str, "Icecast", "user", "source") self.icecast.password = self.Get(str, "Icecast", "password", "hackme") self.icecast.mountname = self.Get(str, "Icecast", "mountname","/stream") # [MusicAI] self.musicai = MUSICAI() self.musicai.modelpath = self.GetDirectory("MusicAI", "modelpath", "/opt/musicdb/data/musicai/models") self.musicai.tmppath = self.GetDirectory("MusicAI", "tmppath", "/opt/musicdb/data/musicai/tmp") self.musicai.logpath = self.GetDirectory("MusicAI", "logpath", "/opt/musicdb/data/musicai/log") self.musicai.specpath = self.GetDirectory("MusicAI", "spectrogrampath", "/opt/musicdb/data/musicai/spectrograms") self.musicai.slicesize = self.Get(int, "MusicAI", "slicesize", 128) self.musicai.epoch = self.Get(int, "MusicAI", "epoch", 20) self.musicai.batchsize = self.Get(int, "MusicAI", "batchsize", 128) self.musicai.usegpu = self.Get(bool,"MusicAI", "usegpu", True) self.musicai.modelname = self.Get(str, "MusicAI", "modelname", "MusicGenre") self.musicai.genrelist = self.Get(str, "MusicAI", "genrelist", None, islist=True) # [Randy] self.randy = RANDY() self.randy.nodisabled = self.Get(bool, "Randy", "nodisabled", True) self.randy.nohated = self.Get(bool, "Randy", "nohated", True) self.randy.minsonglen = self.Get(int, "Randy", "minsonglen", 120) self.randy.maxsonglen = self.Get(int, "Randy", "maxsonglen", 600) self.randy.songbllen = self.Get(int, "Randy", "songbllen", 50) self.randy.albumbllen = self.Get(int, "Randy", "albumbllen", 20) self.randy.artistbllen = self.Get(int, "Randy", "artistbllen", 10) self.randy.maxblage = self.Get(int, "Randy", "maxblage", 24) # [log] self.log = LOG() self.log.logfile = self.Get(str, "log", "logfile", "stderr") self.log.loglevel = self.Get(str, "log", "loglevel", "WARNING") if not self.log.loglevel in ["DEBUG", "INFO", "WARNING", "ERROR"]: logging.error("Invalid loglevel for [log]->loglevel. Loglevel must be one of the following: DEBUG, INFO, WARNING, ERROR") self.log.debugfile = self.Get(str, "log", "debugfile", None) if self.log.debugfile == "/dev/null": self.log.debugfile = None self.log.ignore = self.Get(str, "log", "ignore", None, islist=True) # [debug] self.debug = DEBUG() self.debug.disablestats = self.Get(int, "debug", "disablestats", 0) self.debug.disabletracker = self.Get(int, "debug", "disabletracker", 0) self.debug.disableai = self.Get(int, "debug", "disableai", 1) self.debug.disabletagging = self.Get(int, "debug", "disabletagging", 0) logging.info("\033[1;32mdone")