def main(): try: # Setup argument parser parser = ArgumentParser( description="GoogleNet for image classification") parser.add_argument("-p", "--port", default=9999, help="listen port") parser.add_argument("-C", "--use_cpu", action="store_true") parser.add_argument("--parameter_file", default="bvlc_googlenet.pickle", help="relative path") # Process arguments args = parser.parse_args() port = args.port # start to train agent = Agent(port) serve(agent, args.use_cpu, args.parameter_file) agent.stop() except SystemExit: return except: traceback.print_exc() sys.stderr.write(" for help use --help \n\n") return 2
def main(): try: # Setup argument parser parser = ArgumentParser(description=\ "InceptionV3 and V4 for image classification") parser.add_argument("--model", choices=['v3', 'v4'], default='v4') parser.add_argument("-p", "--port", default=9999, help="listen port") parser.add_argument("-C", "--use_cpu", action="store_true") parser.add_argument("--parameter_file", default="inception_v4.pickle", help="relative path") # Process arguments args = parser.parse_args() port = args.port # start to train agent = Agent(port) serve(agent, args.model, args.use_cpu, args.parameter_file) agent.stop() except SystemExit: return except Exception: traceback.print_exc() sys.stderr.write(" for help use --help \n\n") return 2
def main(): try: # Setup argument parser parser = ArgumentParser(description=\ "InceptionV3 and V4 for image classification") parser.add_argument("--model", choices=['v3', 'v4'], default='v4') parser.add_argument("-p", "--port", default=9999, help="listen port") parser.add_argument("-C", "--use_cpu", action="store_true") parser.add_argument("--parameter_file", default="inception_v4.pickle", help="relative path") # Process arguments args = parser.parse_args() port = args.port # start to train agent = Agent(port) serve(agent, args.model, args.use_cpu, args.parameter_file) agent.stop() except SystemExit: return except: traceback.print_exc() sys.stderr.write(" for help use --help \n\n") return 2
def main(): try: # Setup argument parser parser = ArgumentParser(description="VGG inference") parser.add_argument("--port", default=9999, help="listen port") parser.add_argument("--use_cpu", action="store_true", help="If set, load models onto CPU devices") parser.add_argument("--parameter_file", default="") parser.add_argument("--depth", type=int, choices=[11, 13, 16, 19], default='11') parser.add_argument("--batchnorm", action='store_true', help='use batchnorm or not') # Process arguments args = parser.parse_args() port = args.port # start to train agent = Agent(port) net = model.create_net(args.depth, 1000, args.batchnorm, args.use_cpu) if args.use_cpu: print('Using CPU') dev = device.get_default_device() else: print('Using GPU') dev = device.create_cuda_gpu() net.to_device(dev) model.init_params(net, args.parameter_file) print('Finish loading models') labels = np.loadtxt('synset_words.txt', str, delimiter='\t ') serve(net, labels, dev, agent) # acc = evaluate(net, '../val_list.txt', 'image/val', dev) # print acc # wait the agent finish handling http request agent.stop() except SystemExit: return except: traceback.print_exc() sys.stderr.write(" for help use --help \n\n") return 2
def main(): try: # Setup argument parser parser = ArgumentParser(description="Wide residual network") parser.add_argument("--port", default=9999, help="listen port") parser.add_argument("--use_cpu", action="store_true", help="If set, load models onto CPU devices") parser.add_argument("--parameter_file", default="wrn-50-2.pickle") parser.add_argument("--model", choices=['resnet', 'wrn', 'preact', 'addbn'], default='wrn') parser.add_argument("--depth", type=int, choices=[18, 34, 50, 101, 152, 200], default='50') # Process arguments args = parser.parse_args() port = args.port # start to train agent = Agent(port) net = model.create_net(args.model, args.depth, args.use_cpu) if args.use_cpu: print('Using CPU') dev = device.get_default_device() else: print('Using GPU') dev = device.create_cuda_gpu() net.to_device(dev) model.init_params(net, args.parameter_file) print('Finish loading models') labels = np.loadtxt('synset_words.txt', str, delimiter='\t ') serve(net, labels, dev, agent) # acc = evaluate(net, '../val_list.txt', 'image/val', dev) # print acc # wait the agent finish handling http request agent.stop() except SystemExit: return except: traceback.print_exc() sys.stderr.write(" for help use --help \n\n") return 2
def main(): '''Command line options''' try: # Setup argument parser parser = ArgumentParser(description="Train CNN Readmission Model") parser.add_argument('-inputfolder', type=str, help='inputfolder') parser.add_argument('-outputfolder', type=str, help='outputfolder') parser.add_argument('-visfolder', type=str, help='visfolder') parser.add_argument('-trainratio', type=float, help='ratio of train samples') parser.add_argument('-validationratio', type=float, help='ratio of validation samples') parser.add_argument('-testratio', type=float, help='ratio of test samples') parser.add_argument('-p', '--port', default=9989, help='listening port') parser.add_argument('-C', '--use_cpu', action="store_true") parser.add_argument('--max_epoch', default=100) # Process arguments args = parser.parse_args() port = args.port use_cpu = args.use_cpu if use_cpu: print("runing with cpu") dev = device.get_default_device() else: print("runing with gpu") dev = device.create_cuda_gpu() # start to train agent = Agent(port) train(args.inputfolder, args.outputfolder, args.visfolder, args.trainratio, args.validationratio, args.testratio, dev, agent, args.max_epoch, use_cpu) # wait the agent finish handling http request agent.stop() except SystemExit: return except: # p.terminate() traceback.print_exc() sys.stderr.write(" for help use --help \n\n")
def main(): try: # Setup argument parser parser = ArgumentParser(description='DenseNet inference') parser.add_argument("--port", default=9999, help="listen port") parser.add_argument("--use_cpu", action="store_true", help="If set, load models onto CPU devices") parser.add_argument("--parameter_file", default="densenet-121.pickle") parser.add_argument("--depth", type=int, choices=[121, 169, 201, 161], default=121) parser.add_argument('--nb_classes', default=1000, type=int) # Process arguments args = parser.parse_args() port = args.port # start to train agent = Agent(port) net = model.create_net(args.depth, args.nb_classes, 0, args.use_cpu) if args.use_cpu: print('Using CPU') dev = device.get_default_device() else: print('Using GPU') dev = device.create_cuda_gpu() net.to_device(dev) print('start to load parameter_file') model.init_params(net, args.parameter_file) print('Finish loading models') labels = np.loadtxt('synset_words.txt', str, delimiter='\t ') serve(net, labels, dev, agent) # wait the agent finish handling http request agent.stop() except SystemExit: return except: traceback.print_exc() sys.stderr.write(" for help use --help \n\n") return 2