Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import caffe
import surgery, score
import numpy as np
import os
import sys
try:
import setproctitle
setproctitle.setproctitle(os.path.basename(os.getcwd()))
except:
pass
weights = '../ilsvrc-nets/vgg16-fcn.caffemodel'
# init
caffe.set_device(int(sys.argv[1]))
caffe.set_mode_gpu()
solver = caffe.SGDSolver('solver.prototxt')
solver.net.copy_from(weights)
# surgeries
interp_layers = [k for k in solver.net.params.keys() if 'up' in k]
surgery.interp(solver.net, interp_layers)
def set_process_title(config):
setproctitle("%s" % (get_process_name()))
def main_loop():
setproctitle('webshelld')
dispatcher = SimpleXMLRPCDispatcher()
SOCKFILE = '/var/run/webshell.sock'
if os.path.exists(SOCKFILE):
os.unlink(SOCKFILE)
server = socketserver.UnixStreamServer(SOCKFILE, XMLRPCHandler)
os.chmod(SOCKFILE, 0o700)
dispatcher.register_instance(
Multiplex("/usr/local/bin/bash", "xterm-color"))
server.dispatcher = dispatcher
server.serve_forever()
def _run_plugins_parallel_helper(timeout):
setproctitle.setproctitle('Plugin-Runner')
processes = []
queue_lock = mp.Lock()
for Plugin in plugins:
process = mp.Process(target=self.run_plugin, name=Plugin.get_name(), args=(Plugin, output_queue, queue_lock))
process.start()
processes.append(process)
start_time = time.time()
should_end = False
while len(processes) > 0:
time_spent = time.time() - start_time
should_end = time_spent > timeout
try:
def main():
import argparse
import logging
import setproctitle
from kolejka.client.client import config_parser as client_parser
setproctitle.setproctitle('kolejka-client')
parser = argparse.ArgumentParser(description='KOLEJKA client')
parser.add_argument('-v', '--verbose', action='store_true', default=False, help='show more info')
parser.add_argument('-d', '--debug', action='store_true', default=False, help='show debug info')
parser.add_argument('--config-file', help='config file')
parser.add_argument('--config', help='config')
client_parser(parser)
args = parser.parse_args()
level=logging.WARNING
if args.verbose:
level = logging.INFO
if args.debug:
level = logging.DEBUG
logging.basicConfig(level = level)
args.execute(args)
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--save', type=str, default='work/mse')
parser.add_argument('--nEpoch', type=float, default=50)
# parser.add_argument('--trainBatchSz', type=int, default=25)
parser.add_argument('--trainBatchSz', type=int, default=70)
# parser.add_argument('--testBatchSz', type=int, default=2048)
parser.add_argument('--nGdIter', type=int, default=30)
parser.add_argument('--noncvx', action='store_true')
parser.add_argument('--seed', type=int, default=42)
# parser.add_argument('--valSplit', type=float, default=0)
args = parser.parse_args()
setproctitle.setproctitle('bamos.icnn.comp.mse')
npr.seed(args.seed)
tf.set_random_seed(args.seed)
save = os.path.expanduser(args.save)
if os.path.isdir(save):
shutil.rmtree(save)
os.makedirs(save)
ckptDir = os.path.join(save, 'ckpt')
args.ckptDir = ckptDir
if not os.path.exists(ckptDir):
os.makedirs(ckptDir)
data = olivetti.load("data/olivetti")
nTrain = data['trainX'].shape[0]
def main():
(opts, args) = parse_arguments(sys.argv[1:])
# Rename this process so 'ps' output looks like this is a native
# executable. Can not seperate command-line arguments from actual name of
# the executable by NUL bytes, so only show the name of the executable
# instead. setproctitle.setproctitle("\x00".join(sys.argv))
setproctitle.setproctitle(sys.argv[0])
setup_logging(opts)
# Special case for the clean up queues action
if opts.purge_queues:
purge_queues()
return
# Special case for the clean up exch action
if opts.purge_exchanges:
purge_exchanges()
return
if opts.drain_queue:
drain_queue(opts.drain_queue)
return
parser.add_argument('--batch_size', type=int, default=50)
parser.add_argument('--epochs', type=int, default=20)
parser.add_argument('--seed', type=int, default=0)
parser.add_argument("--lr", type=float, default=1e-3)
parser.add_argument("--epsilon", type=float, default=0.05)
parser.add_argument("--starting_epsilon", type=float, default=None)
parser.add_argument('--prefix')
parser.add_argument('--baseline', action='store_true')
parser.add_argument('--verbose', type=int, default=1)
parser.add_argument('--alpha_grad', action='store_true')
parser.add_argument('--scatter_grad', action='store_true')
parser.add_argument('--old_weights', action='store_true')
parser.add_argument('--l1_proj', type=int, default=None)
args = parser.parse_args()
args.prefix = args.prefix or 'har_conv_{:.4f}_{:.4f}_0'.format(args.epsilon, args.lr).replace(".","_")
setproctitle.setproctitle(args.prefix)
train_log = open(args.prefix + "_train.log", "w")
test_log = open(args.prefix + "_test.log", "w")
train_loader, test_loader = pblm.har_loaders(args.batch_size)
torch.manual_seed(args.seed)
torch.cuda.manual_seed(args.seed)
model = pblm.har_500_model().cuda()
# model = pblm.har_resnet_model().cuda()
opt = optim.Adam(model.parameters(), lr=args.lr)
for t in range(args.epochs):
if args.baseline:
train_baseline(train_loader, model, opt, t, train_log, args.verbose)
import caffe
import surgery, score
import numpy as np
import os
import setproctitle
setproctitle.setproctitle(os.path.basename(os.getcwd()))
proto = 'path-to-VGG_ILSVRC_16_layers_deploy.prototxt'
weights = 'path-to-VGG_ILSVRC_16_layers.caffemodel'
caffe.set_device(0)
caffe.set_mode_gpu()
solver = caffe.SGDSolver('Dilated_FCN-2s_VGG16/solver.prototxt')
# surgeries
custom_net = caffe.Net(proto, weights, caffe.TEST)
surgery.transplant(solver.net, custom_net)
del custom_net
interp_layers = [k for k in solver.net.params.keys() if 'up' in k]
surgery.interp(solver.net, interp_layers)
import caffe
import surgery, score
import numpy as np
import os
import sys
try:
import setproctitle
setproctitle.setproctitle(os.path.basename(os.getcwd()))
except:
pass
weights = '../pascalcontext-fcn16s/pascalcontext-fcn16s.caffemodel'
# init
caffe.set_device(int(sys.argv[1]))
caffe.set_mode_gpu()
solver = caffe.SGDSolver('solver.prototxt')
solver.net.copy_from(weights)
# surgeries
interp_layers = [k for k in solver.net.params.keys() if 'up' in k]
surgery.interp(solver.net, interp_layers)