def __init__(self, config, vhost, path, logpath, logfile, db, redirecturl="error"): self.index = "" self.vhost = vhost self.path = path self.logpath = logpath self.logfile = logfile self.redirecturl = redirecturl self.config = config self.loadIndex() self.display = Display() self.display.setLogPath(self.logpath) self.db = db # build list of "bad" ips and networks based on https://gist.github.com/curi0usJack/971385e8334e189d93a6cb4671238b10 self.bannedIP = Utils.listToIpAddresses( Utils.fileToList("misc/ips.redirect")) self.bannedCIDR = Utils.listToIpNetworks( Utils.fileToList("misc/ranges.redirect")) Resource.__init__(self)
def __init__(self, fold, conf, data_conf, cache_manager, args, inference=False, verbose=True): self._args = args self._fold = fold self._conf = conf self._data_conf = data_conf self._inference = inference self._verbose = verbose self.tmp_dir = self._data_conf['tmp'] # we save output with this folder structure: # output/ # -> tensorboard/ (tensorboard results) # -> results/ (output files: images, illuminant, GT, etc...) # -> checkpoint.pth.tar (checkpoint to continue training in case of failure) # -> model_best.pth.tar (best checkpoint, for inference) self._pretrained_model = None if not self._inference: output_dir = os.path.join(self._args.outputfolder, str(self._fold)) self._tensorboard_dir = os.path.join(output_dir, 'tensorboard') self._results_dir = os.path.join(output_dir, 'results') self._best_checkpoint_file = os.path.join(output_dir, 'model_best.pth.tar') self._checkpoint_file = os.path.join(output_dir, 'checkpoint.pth.tar') self._pretrained_model = self._args.pretrainedmodel # create all directories os.makedirs(self._tensorboard_dir, exist_ok=True) else: # for inference all results are saved under the output directory # (images, illuminant, GT, etc...) self._results_dir = self._args.outputfolder if isinstance(self._args.checkpointfile, list): self._checkpoint_file = self._args.checkpointfile[fold] else: self._checkpoint_file = self._args.checkpointfile self._display = Display(self._conf) self._factory = Factory(self._conf, self._data_conf, cache_manager, self._args, verbose) self._cache_manager = cache_manager # create output directory os.makedirs(self._results_dir, exist_ok=True) os.environ['TORCH_HOME'] = os.path.join( os.path.dirname(os.path.realpath(__file__)), os.pardir, 'torch_model_zoo')
def __init__(self, config, vhost, path, logpath, logfile, db, redirecturl="error"): self.index = "" self.vhost = vhost self.path = path self.logpath = logpath self.logfile = logfile self.redirecturl = redirecturl self.config = config self.loadIndex() self.display = Display() self.display.setLogPath(self.logpath) self.db = db Resource.__init__(self)
def __init__(self): self._memory = Memory(0x1000) self._display = Display(64, 32) self._delay_timer = Timer(freq=60) self._sound_timer = Timer(freq=60) self._sound = Sound(self._sound_timer) self._cpu = Cpu(self._memory, self._display, delay_timer=self._delay_timer, sound_timer=self._sound_timer) self._fps_time = datetime.now() pygame.init()
def do(conf, caps): ## # Extract cameras ## front = camera_setup(caps['front_camera'], conf['calibration']['front_camera']) top = camera_setup(caps['top_camera'], conf['calibration']['top_camera']) menu = camera_setup(caps['top_camera'], conf['calibration']['menu_camera']) ## # Init Menu ## menu_conf = conf['menu'] def process_color(c): if c is None: return None elif type(c) is str: return c else: return tuple(c) menu_buttons = {(button['bottom'], button['upper']): process_color(button['color']) for button in menu_conf} menu_lines = {button['upper'] for button in menu_conf} menu_lines.remove(max(menu_lines)) ## # Init display ## state = DataClass({ 'ph': PointHolder(), 'color': colors['black'], 'setcolor': None, 'menu': { 'buttons': menu_buttons, 'lines': menu_lines, } }) def colorset(c): nonlocal state if c is None or type(c) is tuple: state.color = c state.ph.color = c state.setcolor = colorset displayer = Display(front.cropper.dimensions, state) ## # Main Loop ## fps = 25 period = 1000 // fps main_loop(period, displayer, (front, top, menu), state) print()
# You should have received a copy of the GNU General Public License # # along with CDER. If not, see <http://www.gnu.org/licenses/>. # ############################################################################# import pyglet from core import config #################################################### ## Instantiate calorimeter and beamline calorimeters = [] if config.em_display: from core.calorimeter import em calorimeters.append(em.EM_Calorimeter()) if config.had_display: from core.calorimeter import had calorimeters.append(had.HAD_Calorimeter()) from core.particle import beamline beam = beamline.Beamline() #################################################### ## Instantiate Display from core.display import Display display = Display(calorimeters, beam) display.clear() #################################################### ## Run pyglet: if __name__ == '__main__': pyglet.app.run()