def bootup (): try: opts, args = getopt.getopt (sys.argv[1:], "hc:p:", ["config=", "pid-file="]) except getopt.GetoptError: # print help information and exit: usage() sys.exit(2) verbose = False config_file = None pidfile = None for o, a in opts: if o == "-v": verbose = True if o in ("-h", "--help"): usage() sys.exit() if o in ("-c", "--config"): config_file = a if o in ("-p", "--pid-file"): pidfile = a if config_file == None: # print help information and exit: usage() sys.exit(2) config.initialise(config_file) if pidfile is not None: #Command line override config.set('dbAlerter', 'pid_file', pidfile) if (config.has_option('dbAlerter', 'pid_file')): pidfile = config.get('dbAlerter', 'pid_file') try: pf = file(pidfile,'r') pid = int(pf.read().strip()) pf.close() except IOError: pid = None if pid: message = "pidfile %s already exists. dbAlerter may already be running,\ncheck the process / task list and dbAlerter log file for any\nouststanding issues before removing the existing pidfile.\n" sys.stderr.write(message % pidfile) sys.exit(1) daemonize('/dev/null', config.get('dbAlerter','dbalerter_log'), config.get('dbAlerter','dbalerter_log')) main()
import torch import torch.nn as nn from torch.nn import functional as F from utils.ops import unpixel_shuffle from models.lr_net import SmoothDilatedResidualAtrousGuidedBlock, LRNet from models.model_utils import AdaptiveInstanceNorm from sacred import Experiment from config import initialise ex = Experiment("DAGF") ex = initialise(ex) class ConvGuidedFilter(nn.Module): """ Adapted from https://github.com/wuhuikai/DeepGuidedFilter """ def __init__(self, radius=1, norm=nn.BatchNorm2d, conv_a_kernel_size: int = 1): super(ConvGuidedFilter, self).__init__() self.box_filter = nn.Conv2d(3, 3, kernel_size=3, padding=radius, dilation=radius, bias=False,