def setUp(self):
     """Setup shared by all tests"""
     self.train_parser = train.get_parser()
     self.predict_parser = predict.get_parser()
     self.ckpt_dir = '/BrainSeg/tmp_checkpoints'
     self.log_dir = '/BrainSeg/tmp_tf_logs'
     self.save_dir = '/BrainSeg/tmp_outputs'
     keras.backend.clear_session()  # For easy reset of keras state
Exemple #2
0
def main():
    parser = train.get_parser()
    args = parser.parse_args()
    os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu
    if args.SAVE_DIR is None:
        args.SAVE_DIR = os.environ['HOME']

    test_class = TestFramework(args)
    test_class.prepare_for_test()
    if args.quant == 1:
        test_class.run_quantitative_test()
    else:
        test_class.run_qualitative_test()
Exemple #3
0
          log_interval=50,
          save_interval=int(num_timesteps / timesteps_per_batch),
          max_episode_len=max_episode_len)
    logger.Logger.CURRENT.close()
    env.close()


def main(args):
    args.exp_name += "-{}".format(args.exp_id)
    if args.slurm_task_id is not None:
        args.exp_name += "/{}".format(str(args.slurm_task_id))

    from datetime import datetime
    timestr = datetime.today().strftime("%Y-%m-%d_%H-%M-%S")

    logdir = os.path.join(args.local_dir, args.exp_name,
                          str(args.slurm_task_id), "MACK_mpe_0" + timestr)

    train(logdir, args.scenario, args.num_timesteps, args.lr,
          args.train_batch_size, args.run_id, args.num_envs_per_worker,
          args.max_episode_len)


if __name__ == "__main__":
    import sys
    sys.path.insert(0, "/final_log/PycharmProjects/marl-rllib")
    from train import get_parser
    parser = get_parser()
    args = parse_args(parser)
    main(args)
import numpy as np
import matplotlib.pyplot as plt
from train import get_parser
from ssd.config.defaults import cfg
from ssd.data.build import make_data_loader
from vizer.draw import draw_boxes
from ssd.modeling.box_head.prior_box import PriorBox
from ssd.utils import box_utils

args = get_parser().parse_args()

cfg.merge_from_file(args.config_file)
cfg.merge_from_list(args.opts)
cfg.freeze()

data_loader = make_data_loader(cfg, is_train=True)

mean = np.array([cfg.INPUT.PIXEL_MEAN]).reshape(1, 1, -1)
std = np.array([cfg.INPUT.PIXEL_STD])
priors = PriorBox(cfg)()
if isinstance(data_loader, list):
    data_loader = data_loader[0]
for img, batch, *_ in data_loader:
    boxes = batch["boxes"]
    # SSD Target transform transfers target boxes into prior locations
    # Have to revert the transformation
    boxes = box_utils.convert_locations_to_boxes(boxes, priors,
                                                 cfg.MODEL.CENTER_VARIANCE,
                                                 cfg.MODEL.SIZE_VARIANCE)
    boxes = box_utils.center_form_to_corner_form(boxes)
Exemple #5
0
#!/usr/bin/env python
"""PokerNet simulation suite"""

from __future__ import print_function

from train import run_simulation, get_parser

# Initialize args with program defaults
INIT_ARGS = vars(get_parser().parse_args())


def table_one():
    """Table 1: Training results for different neuron numbers"""
    simulation_num = 1
    print('\n** Running simulation {} **\n'.format(simulation_num))
    table_header = [
        'hidden_neurons', 'learning_rate', 'max_epochs', 'activation', 'hits',
        'mse'
    ]

    args = INIT_ARGS.copy()
    args.update({
        'method': 'gdm',
        'activation': 'purelin',
        'max_epochs': 100,
        'learning_rate': 0.001
    })
    for i in (10, 30, 50):
        args['hidden_neurons'] = i
        run_simulation(args, sim_num=simulation_num, header=table_header)
 def wrap(parser):
     return get_parser(parser, required=False)
Exemple #7
0
  return tf.keras.Model(inputs=model.input, outputs=output_img)


def predict(img, model):
  pil_img = Image.open(img).convert("RGB").resize((224, 224))
  np_imgs = (np.asarray(pil_img) - 127.5) / 128

  roi = model.predict(np_imgs.reshape((1, 224, 224, 3)))

  res = roi[0]
  space = int((16*7 - 2)/(7 - 1))
  x = [space*i for i in range(7)]
  y = [space*i for i in range(7)]
  x[-1] = 223
  y[-1] = 223
  f = interp2d(x, y, res)
  xx = [i for i in range(224)]
  yy = [i for i in range(224)]
  res = f(xx, yy)

  plt.figure()
  plt.imshow((np_imgs*128 + 127.5).astype(np.int16))
  plt.imshow(res, cmap="seismic", alpha=0.3)
  plt.show()

if __name__ == "__main__":
  args = train.get_parser().parse_args()
  model = ACoL_predict(args)

  predict("/home/yudai/Pictures/raw-img/validation/cow/OIP-0SwWnZTgIxQGLEKAqkSrdwHaFc.jpeg", model)